Inheritance: AbstractCommandParseResult
Example #1
0
        public void _商品の購入依頼を処理する_正しくないインデックスを含む一件の場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindPurchaseContext()
                    .BindRunnerRepository()
                    .Get<IRunnerRepository>()
                    ;

            var fixtures = new _コマンドパーサに渡すTestFixture().InsMoneyParams
                .Select(f => f.Expected)
                    .Cast<MoneyInsertionParseResult>()
                    ;

            Action runner;
            foreach (var f in fixtures) {
                runner = repo.FindRunner(f, null);

                runner();
            }

            var result = new PurchaseParseResult {
                Positions = new int[] {-1}
            };

            var expected = new string[] {
                "Item is not placed.",
            };
            var it = expected.GetEnumerator();

            runner = repo.FindRunner(result, (message) => {
                Assert.That(it.MoveNext(), Is.True);
                Assert.That(message, Is.Not.Null.And.Not.Empty);
                Assert.That(message, Is.EqualTo(it.Current));
            });

            runner();

            Assert.That(it.MoveNext(), Is.False);
        }
Example #2
0
        public void _商品の購入依頼を処理する_釣り銭不足で購入できない商品を選択した場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindNoChangeContext()
                    .BindRunnerRepository()
                    .Get<IRunnerRepository>()
                    ;

            Action runner;
            runner = repo.FindRunner( new MoneyInsertionParseResult {Money = Money.Coin500, Count=1}, null);
            runner();

            var result = new PurchaseParseResult {
                Positions = new int[] {1}
            };

            var expected = new string[] {
                "Sorry, can not purchase this item because of lack of changes.",
            };
            var it = expected.GetEnumerator();

            runner = repo.FindRunner(result, (message) => {
                Assert.That(it.MoveNext(), Is.True);
                Assert.That(message, Is.Not.Null.And.Not.Empty);
                Assert.That(message, Is.EqualTo(it.Current));
            });

            runner();

            Assert.That(it.MoveNext(), Is.False);
        }
Example #3
0
        public void _商品の購入依頼を処理する_未入金で複数件同時の場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindPurchaseContextContainingSoldout()
                .BindRunnerRepository()
                .Get<IRunnerRepository>()
            ;

            Assert.That(repo.PurchaseContext.ReceivedTotal, Is.EqualTo(0));

            var result = new PurchaseParseResult {
                Positions = new int[] {4, 1}
            };

            var expected = new string[] {
                "Money enough to purchase is not inserted. (left: 600)",
                "Money enough to purchase is not inserted. (left: 300)",
            };
            var it = expected.GetEnumerator();

            var runner = repo.FindRunner(result, (message) => {
                Assert.That(it.MoveNext(), Is.True);
                Assert.That(message, Is.Not.Null.And.Not.Empty);
                Assert.That(message, Is.EqualTo(it.Current));
            });

            runner();

            Assert.That(it.MoveNext(), Is.False);
        }