예제 #1
0
        public void Validate(string configuration)
        {
            var parser = new StringConfigurer();

            var errors = parser.Validate(configuration);

            Assert.Empty(errors);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }