<commit_before>//
//  ContainerSpec.swift
//  Swinject
//
//  Created by <NAME> on 7/23/15.
//  Copyright © 2015 DevSwinject. All rights reserved.
//

import Quick
import Nimble
@testable import Swinject

class ContainerSpec: QuickSpec {
    override func spec() {
        var container: Container!
        beforeEach {
            container = Container()
        }
        
        describe("Basic resolution") {
            it("resolves multiple initializers with some arguments passed.") {
                container.register(AnimalType.self) { _ in Cat() }
                container.register(AnimalType.self) { container, arg in Cat(name: arg) }
                container.register(AnimalType.self) { container, arg1, arg2 in Cat(name: arg1, mature: arg2) }
                
                let noname = container.resolve(AnimalType.self) as! Cat
                let mimi = container.resolve(AnimalType.self, arg1: "Mimi") as! Cat
                let mew = container.resolve(AnimalType.self, arg1: "Mew", arg2: true) as! Cat
                expect(noname.name).to(beNil())
                expect(mimi.name) == "Mimi"
                expect(mew.name) == "Mew"
                expect(mew.mature) == true
            }
            it("resolves named services.") {
                container.register(AnimalType.self, name: "RegMimi") { _ in Cat(name: "Mimi") }
                container.register(AnimalType.self, name: "RegMew") { _ in Cat(name: "Mew") }
                container.register(AnimalType.self) { _ in Cat() }
                
                let mimi = container.resolve(AnimalType.self, name: "RegMimi") as! Cat
                let mew = container.resolve(AnimalType.self, name: "RegMew") as! Cat
                let noname = container.resolve(AnimalType.self) as! Cat
                expect(mimi.name) == "Mimi"
                expect(mew.name) == "Mew"
                expect(noname.name).to(beNil())
            }
        }
        describe("Container hierarchy") {
            it("resolves a service registered on the parent container.") {<commit_msg>Rename some spec names for better understanding.<commit_after>//
//  ContainerSpec.swift
//  Swinject
//
//  Created by <NAME> on 7/23/15.
//  Copyright © 2015 DevSwinject. All rights reserved.
//

import Quick
import Nimble
@testable import Swinject

class ContainerSpec: QuickSpec {
    override func spec() {
        var container: Container!
        beforeEach {
            container = Container()
        }
        
        describe("Resolution of the same service") {
            it("resolves by arguments.") {
                container.register(AnimalType.self) { _ in Cat() }
                container.register(AnimalType.self) { container, arg in Cat(name: arg) }
                container.register(AnimalType.self) { container, arg1, arg2 in Cat(name: arg1, mature: arg2) }
                
                let noname = container.resolve(AnimalType.self) as! Cat
                let mimi = container.resolve(AnimalType.self, arg1: "Mimi") as! Cat
                let mew = container.resolve(AnimalType.self, arg1: "Mew", arg2: true) as! Cat
                expect(noname.name).to(beNil())
                expect(mimi.name) == "Mimi"
                expect(mew.name) == "Mew"
                expect(mew.mature) == true
            }
            it("resolves by the registered name.") {
                container.register(AnimalType.self, name: "RegMimi") { _ in Cat(name: "Mimi") }
                container.register(AnimalType.self, name: "RegMew") { _ in Cat(name: "Mew") }
                container.register(AnimalType.self) { _ in Cat() }
                
                let mimi = container.resolve(AnimalType.self, name: "RegMimi") as! Cat
                let mew = container.resolve(AnimalType.self, name: "RegMew") as! Cat
                let noname = container.resolve(AnimalType.self) as! Cat
                expect(mimi.name) == "Mimi"
                expect(mew.name) == "Mew"
                expect(noname.name).to(beNil())
            }
        }
        describe("Container hierarchy") {
            it("resolves a service registered on the parent container.") {
{'fraction_non_alphanumeric': 0.11672683513838748, 'fraction_numerical': 0.007701564380264741, 'mean_word_length': 1.8721492743607464, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5810296', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1140, 'n_words': 289}