FindParser() публичный Метод

public FindParser ( string inCommand ) : Func
inCommand string
Результат Func
Пример #1
0
        private bool ProcessCommand()
        {
            var command = ReadCommand();

            if (command == TerminateCommand)
            {
                return(false);
            }

            var parser      = mParserRepo.FindParser(command);
            var parseResult = parser();

            var runner = mRunnerRepo.FindRunner(parseResult, this.LogUpdated);

            runner();

            return(true);
        }
Пример #2
0
        public void _未定義のコマンドをパースする(
            [ValueSource(typeof(_コマンドパーサに渡すTestFixture), "InvalidCommandParams")] _コマンドパーサに渡すTestFixture.Parameter inParameter)
        {
            var repo = new CommandParserRepository();
            var parser = repo.FindParser(inParameter.Input);
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(inParameter.Expected.Status));

            Assert.That(result, Is.InstanceOf(inParameter.Expected.GetType()));
        }
Пример #3
0
        public void _陳列された商品の表示依頼をパースする()
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser("show item");
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(ShowItemParseResult)));
        }
Пример #4
0
        public void _商品の購入依頼をパースする_複数券同時の場合(string inPositions)
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser("buy " + inPositions);
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(PurchaseParseResult)));

            var actual = (PurchaseParseResult)result;
            var expected = inPositions.Split(' ');
            Assert.That(actual.Positions.Length, Is.EqualTo(expected.Length));

            for (var i = 0; i < expected.Length; ++i) {
                Assert.That(actual.Positions[i].ToString(), Is.EqualTo(expected[i]));
            }
        }
Пример #5
0
        public void _投入合計金額表示依頼をパースする()
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser("show amount");
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(ShowAmountParseResult)));
        }
Пример #6
0
        public void _商品の購入依頼をパースする_一件の場合(string inPosition)
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser("buy " + inPosition);
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(PurchaseParseResult)));

            var actual = (PurchaseParseResult)result;

            Assert.That(actual.Positions.Length, Is.EqualTo(1));
            Assert.That(actual.Positions[0].ToString(), Is.EqualTo(inPosition));
        }
Пример #7
0
        public void _商品の購入依頼をパースする_インデックス未指定の場合(string inPosition)
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser("buy " + inPosition);
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.InvalidArgs));
            Assert.That(result, Is.InstanceOf(typeof(ParseErrorResult)));
        }
Пример #8
0
        public void _ヘルプ表示依頼をパースする_コマンド指定()
        {
            var repo = new CommandParserRepository();
            var parser = repo.FindParser("help ins");
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(HelpParseResult)));

            var actual = (HelpParseResult)result;

            Assert.That(actual.Command, Is.EqualTo("ins"));
        }
Пример #9
0
        public void _お金投入の入力をパースする_成功の場合(
            [ValueSource(typeof(_コマンドパーサに渡すTestFixture), "InsMoneyParams")] _コマンドパーサに渡すTestFixture.Parameter inParameter)
        {
            var repo = new CommandParserRepository();

            var parser = repo.FindParser(inParameter.Input);
            var result = parser();
            Assert.That(result.Status, Is.EqualTo(inParameter.Expected.Status));

            Assert.That(result, Is.InstanceOf(inParameter.Expected.GetType()));
            var actual = (MoneyInsertionParseResult)result;
            var expected = (MoneyInsertionParseResult)inParameter.Expected;

            Assert.That(actual.Money, Is.EqualTo(expected.Money));
            Assert.That(actual.Count, Is.EqualTo(expected.Count));
        }
Пример #10
0
        public void _お金の排出依頼をパースする()
        {
            var repo = new CommandParserRepository();
            var parser = repo.FindParser("eject");
            var result = parser();

            Assert.That(result.Status, Is.EqualTo(ParseResultStatus.Success));
            Assert.That(result, Is.InstanceOf(typeof(MoneyEjectParseResult)));
        }