//[Theory]
        //[InlineData("2017")]
        //[InlineData("2016")]
        public void AllCST_AendringsDefinitioner(int year)
        {
            var file        = new FileInfo($"AendringsDefinitionParser/RealTestData/{year}-cst-aendringsdefinitioner.txt");
            var definitions = File.ReadAllLines(file.FullName);
            var sut         = new AendringDefintionParser();
            var errors      = definitions
                              .Select(line => line.Split(new[] { ';' }))
                              .Select((def, no) => new
            {
                LineNo    = no,
                SourceDok = def[0],
                Text      = def[1],
                Result    = sut.Parse(def[1])
            })
                              .Where(r => r.Result.ErrorResult.Errors.Any())
                              .ToArray();


            _logger.WriteLine($"COMPLETE: Parsed {definitions.Length} defintions from year {year} and found {errors.Length} errors:");

            foreach (var error in errors)
            {
                _logger.WriteLine("");
                _logger.WriteLine($"LineNo. {error.LineNo} - [{error.Text}]");
                foreach (var errorResultError in error.Result.ErrorResult.Errors)
                {
                    _logger.WriteLine($"   From source document {error.SourceDok}");
                    _logger.WriteLine($"   {errorResultError}");
                }
            }



            Assert.Equal(definitions.Length, definitions.Length - errors.Count());
        }
示例#2
0
        public void WhenInvalidString_ErrorsAreReported(string description, string inputString)
        {
            var parser = new AendringDefintionParser();
            var result = parser.Parse(inputString);

            Assert.NotEqual(Enumerable.Empty <string>(), result.ErrorResult.Errors);
        }
示例#3
0
        public void WhenSpecialCaseWithMulitpleElements_ElementStructureIsCorrect(string inputString, string expectedTarget, string expectedReplacement)
        {
            //ændres »abc 987« til: »xyz 123«.
            var parser = new AendringDefintionParser();
            var result = parser.Parse(inputString);

            Assert.Equal((new string[] { }).ToList(), result.ErrorResult.Errors);

            Assert.Equal(expectedTarget, result.Result.Target.SubElementTarget.Target);
            Assert.Equal(expectedReplacement, result.Result.Target.SubElementTarget.Replacement);
        }
示例#4
0
        public void WhenContainsQuotedTextChanged_QuotedTextArePreserved(string inputString, string expectedTarget, string expectedReplacement)
        {
            //ændres »abc 987« til: »xyz 123«.
            var parser = new AendringDefintionParser();
            var result = parser.Parse(inputString);

            Assert.Equal(new string[] { }.ToList(), result.ErrorResult.Errors);

            Assert.Equal(expectedTarget, result.Result.Target.SubElementTarget.Target);
            Assert.Equal(expectedReplacement, result.Result.Target.SubElementTarget.Replacement);
        }
示例#5
0
        public void WhenContainsSingleQuotedTextAndAutomationIsPossible_QuotedTextAreSetInSubElementTarget(string inputString, string expectedTarget)
        {
            //ændres »abc 987« til: »xyz 123«.
            var parser = new AendringDefintionParser();
            var result = parser.Parse(inputString);

            Assert.Equal((new string[] { }).ToList(), result.ErrorResult.Errors);

            Assert.Equal(expectedTarget, result.Result.Target.SubElementTarget.Target);
            Assert.Null(result.Result.Target.SubElementTarget.Replacement);
        }
示例#6
0
        public void WhenValidString_ParserReturnsObject(string inputString
                                                        , Type expectedTargetType
                                                        , object expectednumber
                                                        , AktionType expectedAktionType)
        {
            var parser = new AendringDefintionParser();
            var result = parser.Parse(inputString);

            Assert.Equal((new string[] { }).ToList(), result.ErrorResult.Errors);


            Assert.Equal(expectedAktionType, result.Result.AktionType);

            Assert.Equal(expectednumber, result.Result.Target.Nummer);
            Assert.IsType(expectedTargetType, result.Result.Target);
        }
示例#7
0
 public TestConcreteDefinitionsForCorrectParsing()
 {
     _sut = new AendringDefintionParser();
 }
示例#8
0
 public ApplyAendringAktioner()
 {
     _paragrafIndledningParser             = new ParagrafIndledningParser();
     _aendringDefinitiontParser            = new AendringDefintionParser();
     _aendringAendringAktionHandlerFactory = new AendringAktionHandlerFactory();
 }