Exemplo n.º 1
0
        public void Validate(string configuration)
        {
            var parser = new StringConfigurer();

            var errors = parser.Validate(configuration);

            Assert.Empty(errors);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }