Пример #1
0
        public void ItShouldReturnANewInstance()
        {
            constructorResolver.Setup(r => r.GetConstructor(It.IsAny <Type>())).Returns(ParameterClass.GetParameterlessConstructor());
            dependencyResolver.Setup(r => r.Resolve(ParameterClass.GetParameterlessConstructor())).Returns(new object[] { });
            var factory = new TransientFactory(typeof(ParamaterLessClass), constructorResolver.Object, dependencyResolver.Object);

            var object1 = factory.Build();
            var object2 = factory.Build();

            Assert.NotSame(object1, object2);
        }
Пример #2
0
        public void ItShouldRequestParametersForConstructor()
        {
            constructorResolver.Setup(r => r.GetConstructor(It.IsAny <Type>())).Returns(ParameterClass.GetParameterlessConstructor());
            dependencyResolver.Setup(r => r.Resolve(It.IsAny <ConstructorInfo>())).Returns(new object[] { }).Verifiable();
            var factory = new TransientFactory(typeof(ParameterClass), constructorResolver.Object, dependencyResolver.Object);

            factory.Build();

            dependencyResolver.Verify(r => r.Resolve(It.IsAny <ConstructorInfo>()));
        }