Пример #1
0
        public void Said()
        {
            var families = new VocabularyWordFamily[]
            {
                new VocabularyWordFamily(0, "a", "the"),
                new VocabularyWordFamily(1, "get"),
                new VocabularyWordFamily(2, "key"),
                new VocabularyWordFamily(3, "box"),
            };
            var vocabulary = new VocabularyResource(families);

            this.interpreter.ResourceManager = new ResourceManager();
            this.interpreter.ResourceManager.VocabularyResource = vocabulary;

            this.interpreter.State.Flags[Flags.SaidAccepted] = false;
            this.interpreter.ParseText("get key");
            this.kernel.Said(new int[] { 1, 2 });
            this.interpreter.State.Flags[Flags.SaidAccepted].Should().BeTrue();

            this.interpreter.State.Flags[Flags.SaidAccepted] = false;
            this.interpreter.ParseText("get the key");
            this.kernel.Said(new int[] { 1, 2 });
            this.interpreter.State.Flags[Flags.SaidAccepted].Should().BeTrue();

            this.interpreter.State.Flags[Flags.SaidAccepted] = false;
            this.interpreter.ParseText("get");
            this.kernel.Said(new int[] { 1, 2 });
            this.interpreter.State.Flags[Flags.SaidAccepted].Should().BeFalse();

            this.interpreter.State.Flags[Flags.SaidAccepted] = false;
            this.interpreter.ParseText("get key box");
            this.kernel.Said(new int[] { 1, 2 });
            this.interpreter.State.Flags[Flags.SaidAccepted].Should().BeFalse();
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Parser"/> class.
 /// </summary>
 /// <param name="vocabulary">Vocabulary resource to use to search for words.</param>
 public Parser(VocabularyResource vocabulary)
 {
     this.Vocabulary = vocabulary ?? throw new ArgumentNullException(nameof(vocabulary));
 }