public void ChoiceParseTests() { Chat c = CreateParentChat("c"); Choice choice; string[] expected; string text; text = "you ($miss1 | $miss2.Cap() | ok) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "$miss1", "$miss2.Cap()", "ok" }; Assert.That(choice.text, Is.EqualTo("($miss1 | $miss2.Cap() | ok)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (a |) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "a", "" }; Assert.That(choice.text, Is.EqualTo("(a |)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (hello|) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "hello", "" }; Assert.That(choice.text, Is.EqualTo("(hello|)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (hello|hello) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "hello", }; Assert.That(choice.text, Is.EqualTo("(hello|hello)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (hello|hello|) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "hello", "" }; Assert.That(choice.text, Is.EqualTo("(hello|hello|)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you ($miss1 | $miss2) blah"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "$miss1", "$miss2" }; Assert.That(choice.text, Is.EqualTo("($miss1 | $miss2)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you(a | b) a "; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "a", "b" }; Assert.That(choice.text, Is.EqualTo("(a | b)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (a | b).ToUpper() and ..."; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "a", "b" }; Assert.That(choice.text, Is.EqualTo("(a | b).ToUpper()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (a|b) are"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "a", "b" }; Assert.That(choice.text, Is.EqualTo("(a|b)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); text = "you (a|b).ToUpper() are"; choice = Choice.Parse(text, c, false)[0]; expected = new[] { "a", "b" }; Assert.That(choice.text, Is.EqualTo("(a|b).ToUpper()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); Assert.That(choice._TransArray(), Is.EquivalentTo(new[] { "ToUpper" })); //Resolver.DBUG = true; choice = Choice.Parse("you (a|b).ToUpper().Articlize() are", c)[0]; expected = new[] { "a", "b" }; Assert.That(choice.text, Is.EqualTo("(a|b).ToUpper().Articlize()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); Assert.That(choice._TransArray(), Is.EquivalentTo(new[] { "ToUpper", "Articlize" })); choice = Choice.Parse("you (a | b |c). are", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("(a | b |c)")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); //Resolver.DBUG = true; choice = Choice.Parse("you (a | b |c).ToUpper(). are", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("(a | b |c).ToUpper()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); choice = Choice.Parse("you (a | b |c).ToUpper().Articlize(). are", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("(a | b |c).ToUpper().Articlize()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); choice = Choice.Parse("you [d=(a | b | c)]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[d=(a | b | c)]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("d")); Assert.That(choice.options, Is.EqualTo(expected)); //Resolver.DBUG = true; choice = Choice.Parse("you [d=(a | b | c).ToUpper()]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[d=(a | b | c).ToUpper()]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("d")); Assert.That(choice.options, Is.EqualTo(expected)); choice = Choice.Parse("you [d=(a | b | c).ToUpper().Articlize()]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[d=(a | b | c).ToUpper().Articlize()]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("d")); Assert.That(choice.options, Is.EqualTo(expected)); choice = Choice.Parse("you [d=(a | b | c)].ToUpper(). The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[d=(a | b | c)].ToUpper()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); Assert.That(choice.alias, Is.EqualTo("d")); choice = Choice.Parse("you [d=(a | b | c)].ToUpper().Articlize(). The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[d=(a | b | c)].ToUpper().Articlize()")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.options, Is.EqualTo(expected)); Assert.That(choice.alias, Is.EqualTo("d")); choice = Choice.Parse("you [selected=(a | b | c)]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[selected=(a | b | c)]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("selected")); Assert.That(choice.options, Is.EqualTo(expected)); //Resolver.DBUG = true; choice = Choice.Parse("you [selected=(a | b | c).ToUpper()]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[selected=(a | b | c).ToUpper()]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("selected")); Assert.That(choice.options, Is.EqualTo(expected)); choice = Choice.Parse("you [selected=(a | b | c).ToUpper().Articlize()]. The", c)[0]; expected = new[] { "a", "b", "c" }; Assert.That(choice.text, Is.EqualTo("[selected=(a | b | c).ToUpper().Articlize()]")); Assert.That(choice.options.Length, Is.EqualTo(expected.Length)); Assert.That(choice.alias, Is.EqualTo("selected")); Assert.That(choice.options, Is.EqualTo(expected)); }