예제 #1
0
        public void BuildWithValidLifetime(DependencyLifetime lifetime)
        {
            var factory = new GenericFactory(_genericContract, _genericImplementation, lifetime);

            var dependency = factory.BuildDependency(_genericContract.MakeGenericType(typeof(int)), _engine);

            dependency.Lifetime.Should().Be(lifetime);
        }
예제 #2
0
        public void BuildDependency(Type type)
        {
            var contract = _genericContract.MakeGenericType(type);

            var dependency = _factory.BuildDependency(contract, _engine);

            dependency.Implementation.Should().Be(_genericImplementation.MakeGenericType(type));
        }
예제 #3
0
        public void BuildWithoutImplementation(Type type)
        {
            var factory = new GenericFactory(_genericImplementation, null, DependencyLifetime.Singleton);

            var contract = _genericImplementation.MakeGenericType(type);

            factory.Applicable(contract).Should().BeTrue();

            var dependency = factory.BuildDependency(contract, _engine);

            dependency.Implementation.Should().Be(contract);
        }