public void InstanceCreationTest() { var factory = new MultipleInstanceFactory(() => new object()); var instanceA = factory.CreateInstance(); var instanceB = factory.CreateInstance(); instanceA.ShouldNotBeSameAs(instanceB); }
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); }