//[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()); }
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); }
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); }
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); }
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); }
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); }
public TestConcreteDefinitionsForCorrectParsing() { _sut = new AendringDefintionParser(); }
public ApplyAendringAktioner() { _paragrafIndledningParser = new ParagrafIndledningParser(); _aendringDefinitiontParser = new AendringDefintionParser(); _aendringAendringAktionHandlerFactory = new AendringAktionHandlerFactory(); }