public void Test_RegisterTwice_ShouldStoreSecond() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); registry.Register <FakeBO, BOTestFactoryFakeBO>(); //---------------Assert Precondition---------------- Assert.IsNotNull(registry.Resolve <FakeBO>()); //---------------Execute Test ---------------------- registry.Register <FakeBO, BOTestFactory <FakeBO> >(); Assert.IsNotInstanceOf <BOTestFactoryFakeBO>(registry.Resolve <FakeBO>()); }
public void Test_RegisterTwice_WhenInstanceThenType_ShouldStoreSecond() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); BOTestFactoryFakeBO origFactory = new BOTestFactoryFakeBO(); registry.Register <FakeBO>(origFactory); //---------------Assert Precondition---------------- Assert.IsNotNull(registry.Resolve <FakeBO>()); //---------------Execute Test ---------------------- registry.Register <FakeBO, BOTestFactory <FakeBO> >(); BOTestFactory boTestFactory = registry.Resolve <FakeBO>(); Assert.AreNotSame(origFactory, boTestFactory); }
public void Test_Resolve_WithType_WhenNoFactoryRegistered_AndNoSpecialisedFactory_ShouldRetGenericFactory() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); //---------------Execute Test ---------------------- var boTestFactory = registry.Resolve(typeof(RelatedFakeBo)); Assert.IsInstanceOf <BOTestFactory <RelatedFakeBo> >(boTestFactory); }
public void Test_Resolve_WithType_WhenNoFactoryRegistered_AndHasSpecialisedFactory_ShouldRetSpecialisedFactory() { //---------------Set up test pack------------------- var boTestFactoryRegistry = new BOTestFactoryRegistry(); //---------------Execute Test ---------------------- BOTestFactory boTestFactory = boTestFactoryRegistry.Resolve(typeof(FakeBO)); Assert.IsInstanceOf <BOTestFactoryFakeBO>(boTestFactory); Assert.IsInstanceOf <BOTestFactory <FakeBO> >(boTestFactory); }
public void Test_RegisterCustomBOTestFactory_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); //---------------Assert Precondition---------------- registry.Register <FakeBO, BOTestFactoryFakeBO>(); //---------------Execute Test ---------------------- Assert.IsInstanceOf <BOTestFactoryFakeBO>(registry.Resolve <FakeBO>()); }
public void Test_Register_WhenCustomBOTestFactory_WithFactoryType_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); registry.Register<FakeBO>(typeof(BOTestFactoryFakeBO)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- BOTestFactory boTestFactory = registry.Resolve<FakeBO>(); //---------------Test Result ----------------------- Assert.IsInstanceOf<BOTestFactoryFakeBO>(boTestFactory); }
public void Test_Register_WhenCustomBOTestFactory_WithFactoryType_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); registry.Register <FakeBO>(typeof(BOTestFactoryFakeBO)); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- BOTestFactory boTestFactory = registry.Resolve <FakeBO>(); //---------------Test Result ----------------------- Assert.IsInstanceOf <BOTestFactoryFakeBO>(boTestFactory); }
public void Test_RegisterInstance_ShouldRegister() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); BOTestFactoryFakeBO boTestFactoryFakeBO = new BOTestFactoryFakeBO(); //---------------Assert Precondition---------------- registry.Register <FakeBO>(boTestFactoryFakeBO); //---------------Execute Test ---------------------- BOTestFactory boTestFactory = registry.Resolve <FakeBO>(); Assert.AreSame(boTestFactoryFakeBO, boTestFactory); }
public void Test_Resolve_WithTypeNull_ShouldThrowError() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); try { registry.Resolve(null); Assert.Fail("expected ArgumentNullException"); } catch (ArgumentNullException ex) { StringAssert.Contains("Value cannot be null", ex.Message); StringAssert.Contains("typeOfBO", ex.ParamName); } }
public void Test_Resolve_WithType_WhenNoFactoryRegistered_AndNoSpecialisedFactory_ShouldRetGenericFactory() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); //---------------Execute Test ---------------------- var boTestFactory = registry.Resolve(typeof(RelatedFakeBo)); Assert.IsInstanceOf<BOTestFactory<RelatedFakeBo>>(boTestFactory); }
public void Test_Resolve_WithType_WhenNoFactoryRegistered_AndHasSpecialisedFactory_ShouldRetSpecialisedFactory() { //---------------Set up test pack------------------- var boTestFactoryRegistry = new BOTestFactoryRegistry(); //---------------Execute Test ---------------------- BOTestFactory boTestFactory = boTestFactoryRegistry.Resolve(typeof(FakeBO)); Assert.IsInstanceOf<BOTestFactoryFakeBO>(boTestFactory); Assert.IsInstanceOf<BOTestFactory<FakeBO>>(boTestFactory); }
public void Test_RegisterTwice_WhenTypeThenInstance_ShouldStoreSecond() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); registry.Register<FakeBO, BOTestFactory<FakeBO>>(); //---------------Assert Precondition---------------- Assert.IsNotNull(registry.Resolve<FakeBO>()); BOTestFactoryFakeBO secondFactory = new BOTestFactoryFakeBO(); //---------------Execute Test ---------------------- registry.Register<FakeBO>(secondFactory); BOTestFactory boTestFactory = registry.Resolve<FakeBO>(); Assert.AreSame(secondFactory, boTestFactory); }
public void Test_RegisterTwice_ShouldStoreSecond() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); registry.Register<FakeBO, BOTestFactoryFakeBO>(); //---------------Assert Precondition---------------- Assert.IsNotNull(registry.Resolve<FakeBO>()); //---------------Execute Test ---------------------- registry.Register<FakeBO, BOTestFactory<FakeBO>>(); Assert.IsNotInstanceOf<BOTestFactoryFakeBO>(registry.Resolve<FakeBO>()); }
public void Test_RegisterInstance_ShouldRegister() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); BOTestFactoryFakeBO boTestFactoryFakeBO = new BOTestFactoryFakeBO(); //---------------Assert Precondition---------------- registry.Register<FakeBO>(boTestFactoryFakeBO); //---------------Execute Test ---------------------- BOTestFactory boTestFactory = registry.Resolve<FakeBO>(); Assert.AreSame(boTestFactoryFakeBO, boTestFactory); }
public void Test_RegisterCustomBOTestFactory_ShouldReturnWhenResolved() { //---------------Set up test pack------------------- BOTestFactoryRegistry registry = new BOTestFactoryRegistry(); //---------------Assert Precondition---------------- registry.Register<FakeBO, BOTestFactoryFakeBO>(); //---------------Execute Test ---------------------- Assert.IsInstanceOf<BOTestFactoryFakeBO>(registry.Resolve<FakeBO>()); }