コード例 #1
0
        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>());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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>());
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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>());
 }
コード例 #15
0
 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);
 }
コード例 #16
0
 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>());
 }