protected AbstractValueGenerator(string generatorName, bool isTakingValueFromOtherColumn = false)
 {
     _generatorName                = generatorName;
     GeneratorParameters           = new GeneratorParameterCollection();
     GeneratorHelpText             = GeneratorHelpTextManager.GetGeneratorHelpText(generatorName);
     _isTakingValueFromOtherColumn = isTakingValueFromOtherColumn;
 }
예제 #2
0
        public void ShouldBeAbleToCloneGeneratorParameterCollection()
        {
            GeneratorParameterCollection coll = new GeneratorParameterCollection();
            var gp1 = new GeneratorParameter("Date", DateTime.Now, GeneratorParameterParser.DateTimeParser);

            coll.Add(gp1);

            var coll2 = coll.Clone();

            //CollectionAssert.AreEqual(coll, coll2);
        }
예제 #3
0
        public void ShouldParseTheParameterToCorrectTypeEvenIfInputIsNotOfSameType()
        {
            GeneratorParameterCollection coll = new GeneratorParameterCollection();
            var gp1 = new GeneratorParameter("Date", DateTime.Now.ToString(), GeneratorParameterParser.DateTimeParser);
            var gp2 = new GeneratorParameter("Decimal", 1000, GeneratorParameterParser.DecimalParser);

            coll.Add(gp1);
            coll.Add(gp2);

            Decimal  dec  = coll.GetValueOf <Decimal>("Decimal");
            DateTime date = coll.GetValueOf <DateTime>("Date");
        }
예제 #4
0
        public void ShouldGetParameterFromCollection()
        {
            GeneratorParameterCollection coll = new GeneratorParameterCollection();
            var gp1 = new GeneratorParameter("Date", DateTime.Now, GeneratorParameterParser.DateTimeParser);
            var gp2 = new GeneratorParameter("Decimal", new Decimal(10), GeneratorParameterParser.DecimalParser);

            coll.Add(gp1);
            coll.Add(gp2);

            Decimal got = coll.GetValueOf <Decimal>("Decimal");

            DateTime got2 = coll.GetValueOf <DateTime>("Date");
        }
예제 #5
0
        public void ShouldGetExceptionIfParameterIsMissing()
        {
            GeneratorParameterCollection coll = new GeneratorParameterCollection();
            bool exceptionHappened            = false;

            try
            {
                coll.GetValueOf <string>("unknown");
            }
            catch (Exception)
            {
                exceptionHappened = true;
            }
            Assert.That(exceptionHappened);
        }
예제 #6
0
        public void ShouldGetNullIfParameteHasNullValue()
        {
            bool exceptionHappened = false;

            try
            {
                GeneratorParameterCollection coll = new GeneratorParameterCollection();
                coll.Add(new GeneratorParameter("Date", null, GeneratorParameterParser.DateTimeParser));
                coll.GetValueOf <DateTime>("Date");
            }
            catch (ArgumentNullException)
            {
                exceptionHappened = true;
            }
            Assert.That(exceptionHappened);
        }
예제 #7
0
        public void ShouldGetExceptionWhenTryingToGetWrongDataTypeFromParameterCollection()
        {
            GeneratorParameterCollection coll = new GeneratorParameterCollection();
            var gp1 = new GeneratorParameter("Date", DateTime.Now, GeneratorParameterParser.DateTimeParser);
            var gp2 = new GeneratorParameter("Decimal", "peter", GeneratorParameterParser.StringParser);

            coll.Add(gp1);
            coll.Add(gp2);

            bool gotException = false;

            try
            {
                Decimal got = coll.GetValueOf <Decimal>("Decimal");
            }
            catch (Exception)
            {
                gotException = true;
            }
            Assert.That(gotException, Is.True);
        }
 protected abstract object InternalGenerateValue(long n, GeneratorParameterCollection paramas);