public void Validate(string configuration) { var parser = new StringConfigurer(); var errors = parser.Validate(configuration); Assert.Empty(errors); }
public void IdentifySecondSentenceError() { var parser = new StringConfigurer(); var errors = parser.Validate("Replace \"o\" with \"ó\". Convert to nonsense case."); Assert.Single(errors); var error = errors[0]; Assert.Equal(33, error.StartIndex); Assert.Equal(8, error.Length); Assert.Equal("Unexpected case value: nonsense", error.Message); }
public void IdentifyUnfinishedSentenceError() { var parser = new StringConfigurer(); var errors = parser.Validate("Convert to upper case. Convert to lower case"); Assert.Single(errors); var error = errors[0]; Assert.Equal(43, error.StartIndex); Assert.Equal(1, error.Length); Assert.Equal("The last sentence is unfinished.", error.Message); }
public void ReportUnrecognisedSentence() { var parser = new StringConfigurer(); var errors = parser.Validate("This sentence matches no parser."); Assert.Single(errors); var error = errors[0]; Assert.Equal(0, error.StartIndex); Assert.Equal(31, error.Length); Assert.Equal("Sentence doesn't match any known rules.", error.Message); }
public void ModifyText(string configuration, string input, string output) { var parser = new StringConfigurer(); var data = new StringHolder { Value = input, }; var errors = parser.Configure(configuration, data); Assert.Empty(errors); Assert.Equal(output, data.Value); }
public void IdentifyMultipleErrors() { var parser = new StringConfigurer(); var errors = parser.Validate("Replace \"\" with \"ó\". Convert to nonsense case."); Assert.Equal(2, errors.Count); var error = errors[0]; Assert.Equal(8, error.StartIndex); Assert.Equal(2, error.Length); Assert.Equal("Match text cannot be empty.", error.Message); error = errors[1]; Assert.Equal(32, error.StartIndex); Assert.Equal(8, error.Length); Assert.Equal("Unexpected case value: nonsense", error.Message); }