Ejemplo n.º 1
0
        public void InstanceCreationTest()
        {
            var factory = new MultipleInstanceFactory(() => new object());

            var instanceA = factory.CreateInstance();
            var instanceB = factory.CreateInstance();

            instanceA.ShouldNotBeSameAs(instanceB);
        }
Ejemplo n.º 2
0
        public void InstanceInjectionParameterTest()
        {
            var factory = new MultipleInstanceFactory(() => new FactoryTest());

            var instance = (FactoryTest)factory.CreateInstance(
                new InjectProperty("TestProperty", "abc"),
                new InjectProperty("Test42", "xyz"),
                new InjectProperty("RandomProperty", 42));

            instance.TestProperty.ShouldBe("abc");
            instance.TestPropertyWithName.ShouldBe("xyz");
            instance.RandomProperty.ShouldNotBe(42);

            instance = (FactoryTest)factory.CreateInstance(
                new InjectProperty("TestPropertyWithName", "xyz"));

            instance.TestProperty.ShouldBeNull();
            instance.TestPropertyWithName.ShouldBeNull();
            instance.RandomProperty.ShouldNotBe(42);
        }