Ejemplo n.º 1
0
        public void ParseLineWithConfigurationForDataTypeSetsHasOperationToTrue()
        {
            //setup
            var objectUnderTest = new TotalTempLineProcessor();

            objectUnderTest.SetHeader(GetValidHeader());
            var moqInstructions = new Mock <ILineProcessInstructions>();
            var testInstruction = new LineProcessor()
            {
                Period        = periodChoice.LastValue,
                OperationType = statisticCalculation.Average,
                VariableType  = "CashPrem"
            };

            moqInstructions.Setup(x => x.Processors).Returns(new Dictionary <string, ILineProcessor>()
            {
                { testInstruction.Key, testInstruction }
            });
            moqInstructions.Setup(t => t.ExtractPeriodValueOfInterest(It.IsAny <List <PeriodValue> >(), It.IsAny <string>()))
            .Returns(new List <RelevantValue>()
            {
                new RelevantValue()
                {
                    Value = _testValues[4]
                }
            });

            //execute
            var lines = objectUnderTest.ParseLine(GetCashPrem(), moqInstructions.Object);

            //assert
            Assert.IsTrue(lines.First().HasOperation);
            Assert.AreEqual(_testValues[4], lines.First().ValueOfRelevance);
        }
Ejemplo n.º 2
0
        public void HeaderWithout3PartsThrowsException()
        {
            //setup
            var objectUnderTest = new TotalTempLineProcessor();

            //execute
            objectUnderTest.SetHeader("x");
        }
Ejemplo n.º 3
0
        public void ValidHeaderIsCorrectlyParsed()
        {
            //setup // execute
            var objectUnderTest = new TotalTempLineProcessor();

            objectUnderTest.SetHeader(GetValidHeader());



            //assert
            Assert.AreEqual(5, objectUnderTest.PeriodDefinitions.Count);
        }
Ejemplo n.º 4
0
        public void InvalidFormatReturnsObjectInError()
        {
            //setup
            var objectUnderTest = new TotalTempLineProcessor();

            objectUnderTest.SetHeader(GetValidHeader());
            //execute
            var lines = objectUnderTest.ParseLine(GetBadLine(), null);

            //assert
            Assert.AreEqual(true, lines.Any(e => e.InError));
            Assert.AreEqual(1, lines.First().Errors.Count);
            Assert.AreEqual(2, lines.First().Errors.First().ErrorCode);
        }
Ejemplo n.º 5
0
        public void GetLineWithoutInstructionReturnsEmptyCollection()
        {
            //setup
            var objectUnderTest = new TotalTempLineProcessor();

            objectUnderTest.SetHeader(GetValidHeader());
            var moqInstructions = new Mock <ILineProcessInstructions>();

            moqInstructions.Setup(x => x.Processors).Returns(new Dictionary <string, ILineProcessor>());

            //execute
            var lines = objectUnderTest.ParseLine(GetCashPrem(), moqInstructions.Object);

            //assert
            Assert.AreEqual(0, lines.Count());
        }
Ejemplo n.º 6
0
        public void InvalidSceneIdCausesError()
        {
            var objectUnderTest = new TotalTempLineProcessor();

            objectUnderTest.SetHeader(GetValidHeader());
            var moqInstructions = new Mock <ILineProcessInstructions>();
            var testInstruction = new LineProcessor()
            {
                Period        = periodChoice.LastValue,
                OperationType = statisticCalculation.Average,
                VariableType  = "CashPrem"
            };

            //execute
            var lines = objectUnderTest.ParseLine(GetCashPrem(true), moqInstructions.Object);

            //assert
            Assert.IsTrue(lines.First().InError);
            Assert.AreEqual(1, lines.First().Errors.First().ErrorCode);
        }