Beispiel #1
0
        public void _投入合計金額表示を処理する_受け付けない金種を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                       .BindPurchaseContext()
                       .BindRunnerRepository()
                       .Get <IRunnerRepository>()
            ;

            Action runner;
            var    fixtures = new _コマンドパーサに渡すTestFixture().InvalidInsMoneyParams;

            foreach (var param in fixtures.Select(f => f.Expected))
            {
                runner = repo.FindRunner(param, null);
                runner();

                var passed = false;
                runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                    Assert.That(message, Is.EqualTo("Not received."));
                    passed = true;
                });
                runner();

                Assert.That(repo.PurchaseContext.ReceivedTotal, Is.EqualTo(0));
                Assert.That(passed, Is.True);
            }
        }
Beispiel #2
0
        public void _投入合計金額表示を処理する_お金を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                       .BindPurchaseContext()
                       .BindRunnerRepository()
                       .Get <IRunnerRepository>()
            ;

            Action runner;
            var    fixtures = new _コマンドパーサに渡すTestFixture().InsMoneyParams;

            foreach (var param in fixtures.Select(f => f.Expected))
            {
                runner = repo.FindRunner(param, null);
                runner();
            }

            var expected = fixtures
                           .Select(f => f.Expected)
                           .Cast <MoneyInsertionParseResult>()
                           .Sum(r => r.Money.Value() * r.Count)
            ;

            var passed = false;

            runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                Assert.That(message, Is.EqualTo(string.Format("total money is {0}.", expected)));
                Assert.That(message, Is.EqualTo(string.Format("total money is {0}.", repo.PurchaseContext.ReceivedTotal)));
                passed = true;
            });
            runner();
            Assert.That(passed, Is.True);

            runner = repo.FindRunner(new MoneyEjectParseResult(), null);
            runner();

            passed = false;
            runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                Assert.That(message, Is.EqualTo("Not received."));
                passed = true;
            });
            runner();
            Assert.That(passed, Is.True);
        }
Beispiel #3
0
        public void _陳列された商品の表示依頼を処理する_受け付けない金種を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                       .BindPurchaseContextContainingSoldout()
                       .BindRunnerRepository()
                       .Get <IRunnerRepository>()
            ;

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

            Action runner;
            var    fixtures = new _コマンドパーサに渡すTestFixture().InvalidInsMoneyParams;

            foreach (var param in fixtures.Select(f => f.Expected))
            {
                var expected = new string[] {
                    "       # Name                     Price",
                    "-----+--+------------------------+------",
                    " [ ]   1 Item0...................   300",
                    " [ ]   2 Item1...................  1200",
                    " [-]   3 Item2...................   900",
                    " [ ]   4 Item3...................   600"
                };
                var it = expected.GetEnumerator();

                runner = repo.FindRunner(param, null);
                runner();

                runner = repo.FindRunner(new ShowItemParseResult(), (message) => {
                    Assert.That(it.MoveNext(), Is.True);
                    Assert.That(message, Is.EqualTo(it.Current));
                });
                runner();

                Assert.That(it.MoveNext(), Is.False);
                Assert.That(repo.PurchaseContext.ReceivedTotal, Is.EqualTo(0));
            }
        }
Beispiel #4
0
        public void _陳列された商品の表示依頼を処理する_受け付けない金種を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindPurchaseContextContainingSoldout()
                .BindRunnerRepository()
                .Get<IRunnerRepository>()
            ;

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

            Action runner;
            var fixtures = new _コマンドパーサに渡すTestFixture().InvalidInsMoneyParams;
            foreach (var param in fixtures.Select(f => f.Expected)) {
                var expected = new string[] {
                    "       # Name                     Price",
                    "-----+--+------------------------+------",
                    " [ ]   1 Item0...................   300",
                    " [ ]   2 Item1...................  1200",
                    " [-]   3 Item2...................   900",
                    " [ ]   4 Item3...................   600"
                };
                var it = expected.GetEnumerator();

                runner = repo.FindRunner(param, null);
                runner();

                runner = repo.FindRunner(new ShowItemParseResult(), (message) => {
                    Assert.That(it.MoveNext(), Is.True);
                    Assert.That(message, Is.EqualTo(it.Current));
                });
                runner();

                Assert.That(it.MoveNext(), Is.False);
                Assert.That(repo.PurchaseContext.ReceivedTotal, Is.EqualTo(0));
            }
        }
Beispiel #5
0
        public void _投入合計金額表示を処理する_受け付けない金種を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindPurchaseContext()
                    .BindRunnerRepository()
                    .Get<IRunnerRepository>()
                ;

            Action runner;
            var fixtures = new _コマンドパーサに渡すTestFixture().InvalidInsMoneyParams;
            foreach (var param in fixtures.Select(f => f.Expected)) {
                runner = repo.FindRunner(param, null);
                runner();

                var passed = false;
                runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                    Assert.That(message, Is.EqualTo("Not received."));
                    passed = true;
                });
                runner();

                Assert.That(repo.PurchaseContext.ReceivedTotal, Is.EqualTo(0));
                Assert.That(passed, Is.True);
            }
        }
Beispiel #6
0
        public void _投入合計金額表示を処理する_お金を投入した場合()
        {
            var repo = new Ninject.StandardKernel()
                .BindPurchaseContext()
                    .BindRunnerRepository()
                    .Get<IRunnerRepository>()
                    ;

            Action runner;
            var fixtures = new _コマンドパーサに渡すTestFixture().InsMoneyParams;
            foreach (var param in fixtures.Select(f => f.Expected)) {
                runner = repo.FindRunner(param, null);
                runner();

            }

            var expected = fixtures
                .Select(f => f.Expected)
                    .Cast<MoneyInsertionParseResult>()
                    .Sum(r => r.Money.Value() * r.Count)
            ;

            var passed = false;
            runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                Assert.That(message, Is.EqualTo(string.Format("total money is {0}.", expected)));
                Assert.That(message, Is.EqualTo(string.Format("total money is {0}.", repo.PurchaseContext.ReceivedTotal)));
                passed = true;
            });
            runner();
            Assert.That(passed, Is.True);

            runner = repo.FindRunner(new MoneyEjectParseResult(), null);
            runner();

            passed = false;
            runner = repo.FindRunner(new ShowAmountParseResult(), (message) => {
                Assert.That(message, Is.EqualTo("Not received."));
                passed = true;
            });
            runner();
            Assert.That(passed, Is.True);
        }