Ejemplo n.º 1
0
        public void Test_Registry_WhenCallTwice_ShouldReturnSameSingletonRegistry()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            BOPropValueGeneratorRegistry origRegistry = BOPropValueGeneratorRegistry.Instance;
            var registry = BOPropValueGeneratorRegistry.Instance;

            //---------------Test Result -----------------------
            Assert.AreSame(origRegistry, registry);
        }
Ejemplo n.º 2
0
        public void Test_SetRegistry_WithNull_ShouldReturnNewSingleton()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            BOPropValueGeneratorRegistry.Instance = null;
            BOPropValueGeneratorRegistry boDefaultValueRegistry = BOPropValueGeneratorRegistry.Instance;

            //---------------Test Result -----------------------
            Assert.IsNotNull(boDefaultValueRegistry);
        }
Ejemplo n.º 3
0
        public void Test_IsRegister_WhenNotRegistered_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            var stringPropDef = GetStringPropDef();
            var registry      = new BOPropValueGeneratorRegistry();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            bool isRegistered = registry.IsRegistered(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsFalse(isRegistered);
        }
 public void Test_RegisterCustomBOTestFactory_ForAPropDef_ShouldReturnWhenResolved()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<ValidValueGeneratorString>(registry.Resolve(stringPropDef));
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef, typeof(ValidValueGeneratorIncrementalInt));
     ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorIncrementalInt>(validValueGenerator);
 }
 public void Test_RegisterTwice_ForAPropDef_ShouldStoreSecond()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     registry.Register(stringPropDef, typeof(ValidValueGeneratorEnum));
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<ValidValueGeneratorEnum>(registry.Resolve(stringPropDef));
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal));
     ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator);
 }
 public void Test_RegisterCustomGenForTypeAndForPropDef_ShouldReturnPropDefRegistration()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     registry.Register(stringPropDef, typeof(ValidValueGeneratorInt));
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef));
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal));
     ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator);
 }
Ejemplo n.º 7
0
        public void Test_RegisterCustomBOTestFactory_ForAPropDef_ShouldReturnWhenResolved()
        {
            //---------------Set up test pack-------------------
            var registry      = new BOPropValueGeneratorRegistry();
            var stringPropDef = GetStringPropDef();

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <ValidValueGeneratorString>(registry.Resolve(stringPropDef));
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorIncrementalInt));
            ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorIncrementalInt>(validValueGenerator);
        }
Ejemplo n.º 8
0
        public void Test_IsRegister_WhenRegistered_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            var stringPropDef = GetStringPropDef();

            var registry = new BOPropValueGeneratorRegistry();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorLong));
            bool isRegistered = registry.IsRegistered(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsTrue(isRegistered);
        }
Ejemplo n.º 9
0
        public void Test_Resolve_WhenNoPropDefRegistered_ShouldReturnForType()
        {
            //---------------Set up test pack-------------------
            var registry = new BOPropValueGeneratorRegistry();

            var stringPropDef1 = GetStringPropDef();

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <ValidValueGeneratorString>(registry.Resolve(stringPropDef1));
            //---------------Execute Test ----------------------
            ValidValueGeneratorRegistry.Instance.Register <string, ValidValueGeneratorInt>();
            ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorInt>(validValueGenerator1);
        }
Ejemplo n.º 10
0
        public void Test_RegisterTwice_ForAPropDef_ShouldStoreSecond()
        {
            //---------------Set up test pack-------------------
            var registry      = new BOPropValueGeneratorRegistry();
            var stringPropDef = GetStringPropDef();

            registry.Register(stringPropDef, typeof(ValidValueGeneratorEnum));
            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <ValidValueGeneratorEnum>(registry.Resolve(stringPropDef));
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal));
            ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator);
        }
Ejemplo n.º 11
0
        public void Test_RegisterCustomBOTestFactory_AdditionalParameter_PassedToGenerator()
        {
            //---------------Set up test pack-------------------
            var randomParameter = RandomValueGen.GetRandomString();
            var registry        = new BOPropValueGeneratorRegistry();
            var stringPropDef   = GetStringPropDef();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorTextFile), randomParameter);
            var validValueGenerator = registry.Resolve(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorTextFile>(validValueGenerator);
            Assert.AreEqual(randomParameter, ((ValidValueGeneratorTextFile)validValueGenerator).FileName);
        }
Ejemplo n.º 12
0
        public void Test_RegisterCustomGenForTypeAndForPropDef_ShouldReturnPropDefRegistration()
        {
            //---------------Set up test pack-------------------
            var registry      = new BOPropValueGeneratorRegistry();
            var stringPropDef = GetStringPropDef();

            registry.Register(stringPropDef, typeof(ValidValueGeneratorInt));
            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef));
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorDecimal));
            ValidValueGenerator validValueGenerator = registry.Resolve(stringPropDef);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator);
        }
Ejemplo n.º 13
0
        public void Test_RegisterCustomBOTestFactory_ForAPropDef_WithInvalidGeneratorType_ShouldRaiseErr()
        {
            //---------------Set up test pack-------------------
            var registry      = new BOPropValueGeneratorRegistry();
            var stringPropDef = GetStringPropDef();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                registry.Register(stringPropDef, typeof(FakeEnum));
                Assert.Fail("Expected to throw an HabaneroApplicationException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroApplicationException ex)
            {
                StringAssert.Contains("A ValidValueGenerator is being Registered for", ex.Message);
                StringAssert.Contains("but the ValidValueGenerator is not of Type ValidValueGenerator", ex.Message);
            }
        }
Ejemplo n.º 14
0
        public void Test_RegisterCustomBOTestFactory_AdditionalParameter_ExceptionIfSuitableConstructorNotFound()
        {
            //---------------Set up test pack-------------------
            var randomParameter = RandomValueGen.GetRandomString();
            var registry        = new BOPropValueGeneratorRegistry();
            var stringPropDef   = GetStringPropDef();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(GeneratorStub), randomParameter);
            try
            {
                registry.Resolve(stringPropDef);
                //---------------Test Result -----------------------
                Assert.Fail("Expected to throw an ArgumentException");
            }
            catch (ArgumentException ex)
            {
                StringAssert.Contains("An extra parameter was provided for a valid value generator type (GeneratorStub), but no suitable constructor was found with a second parameter.", ex.Message);
            }
        }
Ejemplo n.º 15
0
        public void Test_ResolveForDifPropDefShouldReturnDefaultValidValGen()
        {
            //---------------Set up test pack-------------------
            var registry = new BOPropValueGeneratorRegistry();

            ValidValueGeneratorRegistry.Instance.Register <string, ValidValueGeneratorInt>();
            var stringPropDef1 = GetStringPropDef();
            var stringPropDef2 = GetStringPropDef();

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef1));
            Assert.IsInstanceOf <ValidValueGeneratorInt>(registry.Resolve(stringPropDef2));
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef1, typeof(ValidValueGeneratorDecimal));
            ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1);
            ValidValueGenerator validValueGenerator2 = registry.Resolve(stringPropDef2);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <ValidValueGeneratorDecimal>(validValueGenerator1);
            Assert.IsInstanceOf <ValidValueGeneratorInt>(validValueGenerator2);
        }
 public void Test_Resolve_WhenNoPropDefRegistered_ShouldReturnForType()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     
     var stringPropDef1 = GetStringPropDef();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<ValidValueGeneratorString>(registry.Resolve(stringPropDef1));
     //---------------Execute Test ----------------------
     ValidValueGeneratorRegistry.Instance.Register<string, ValidValueGeneratorInt>();
     ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorInt>(validValueGenerator1);
 }
 public void Test_ResolveForDifPropDefShouldReturnDefaultValidValGen()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     ValidValueGeneratorRegistry.Instance.Register<string, ValidValueGeneratorInt>();
     var stringPropDef1 = GetStringPropDef();
     var stringPropDef2 = GetStringPropDef();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef1));
     Assert.IsInstanceOf<ValidValueGeneratorInt>(registry.Resolve(stringPropDef2));
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef1, typeof(ValidValueGeneratorDecimal));
     ValidValueGenerator validValueGenerator1 = registry.Resolve(stringPropDef1);
     ValidValueGenerator validValueGenerator2 = registry.Resolve(stringPropDef2);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorDecimal>(validValueGenerator1);
     Assert.IsInstanceOf<ValidValueGeneratorInt>(validValueGenerator2);
 }
 public void Test_RegisterCustomBOTestFactory_ForAPropDef_WithInvalidGeneratorType_ShouldRaiseErr()
 {
     //---------------Set up test pack-------------------
     var registry= new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     try
     {
         registry.Register(stringPropDef, typeof(FakeEnum));
         Assert.Fail("Expected to throw an HabaneroApplicationException");
     }
     //---------------Test Result -----------------------
     catch (HabaneroApplicationException ex)
     {
         StringAssert.Contains("A ValidValueGenerator is being Registered for", ex.Message);
         StringAssert.Contains("but the ValidValueGenerator is not of Type ValidValueGenerator", ex.Message);
     }
 }
 public void Test_RegisterCustomBOTestFactory_AdditionalParameter_PassedToGenerator()
 {
     //---------------Set up test pack-------------------
     var randomParameter = RandomValueGen.GetRandomString();
     var registry = new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef, typeof(ValidValueGeneratorTextFile), randomParameter);
     var validValueGenerator = registry.Resolve(stringPropDef);
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<ValidValueGeneratorTextFile>(validValueGenerator);
     Assert.AreEqual(randomParameter, ((ValidValueGeneratorTextFile)validValueGenerator).FileName);
 }
 public void Test_IsRegister_WhenNotRegistered_ShouldReturnFalse()
 {
     //---------------Set up test pack-------------------
     var stringPropDef = GetStringPropDef();
     var registry= new BOPropValueGeneratorRegistry();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     bool isRegistered = registry.IsRegistered(stringPropDef);
     //---------------Test Result -----------------------
     Assert.IsFalse(isRegistered);
 }
        public void Test_IsRegister_WhenRegistered_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            var stringPropDef = GetStringPropDef();
 
            var registry= new BOPropValueGeneratorRegistry();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            registry.Register(stringPropDef, typeof(ValidValueGeneratorLong));
            bool isRegistered = registry.IsRegistered(stringPropDef);
            //---------------Test Result -----------------------
            Assert.IsTrue(isRegistered);
        }
 public void Test_RegisterCustomBOTestFactory_AdditionalParameter_ExceptionIfSuitableConstructorNotFound()
 {
     //---------------Set up test pack-------------------
     var randomParameter = RandomValueGen.GetRandomString();
     var registry = new BOPropValueGeneratorRegistry();
     var stringPropDef = GetStringPropDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     registry.Register(stringPropDef, typeof(GeneratorStub), randomParameter);
     try
     {
         registry.Resolve(stringPropDef);
         //---------------Test Result -----------------------
         Assert.Fail("Expected to throw an ArgumentException");
     }
     catch (ArgumentException ex)
     {
         StringAssert.Contains("An extra parameter was provided for a valid value generator type (GeneratorStub), but no suitable constructor was found with a second parameter.", ex.Message);
     }
 }