當前位置: 首頁>>代碼示例>>C#>>正文


C# StandardKernel.ReceiveMoney方法代碼示例

本文整理匯總了C#中Ninject.StandardKernel.ReceiveMoney方法的典型用法代碼示例。如果您正苦於以下問題:C# StandardKernel.ReceiveMoney方法的具體用法?C# StandardKernel.ReceiveMoney怎麽用?C# StandardKernel.ReceiveMoney使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ninject.StandardKernel的用法示例。


在下文中一共展示了StandardKernel.ReceiveMoney方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: StandardKernel

        public void _連続購入()
        {
            var ctx = new StandardKernel().BindNoChangeContext().Get<PurchaseContext>();

            ctx.ReceiveMoney(Money.Coin100, 6);
            ctx.ReceiveMoney(Money.Coin50, 3);

            Assert.That(ctx.Racks[2].State, Is.EqualTo(ItemRackState.CanPurchase));
            ctx.Purchase(2);
            Assert.That(ctx.Racks[2].State, Is.EqualTo(ItemRackState.CanPurchase));
            ctx.Purchase(2);
            Assert.That(ctx.Racks[2].State, Is.EqualTo(ItemRackState.CanPurchase));
            ctx.Purchase(2);
            Assert.That(ctx.Racks[2].State, Is.EqualTo(ItemRackState.CanNotPurchase));
        }
開發者ID:posaunehm,項目名稱:Codersation,代碼行數:15,代碼來源:PurchaseContextTest.cs

示例2:

        public void _金銭を投入して商品を受け取る_丁度の場合()
        {
            var ctx = new Ninject.StandardKernel()
                .BindPurchaseContext()
                .Get<PurchaseContext>()
            ;

            Assert.That(ctx.CanPurchase(0), Is.False);

            ctx.ReceiveMoney(Money.Coin100);
            ctx.ReceiveMoney(Money.Coin10);
            ctx.ReceiveMoney(Money.Coin10);

            Assert.That(ctx.CanPurchase(0), Is.True, "should be purchased");

            var item = ctx.Purchase(0);
            Assert.That(item.Name, Is.EqualTo("Item0"));
            Assert.That(ctx.ReceivedTotal, Is.EqualTo(0));

            Assert.That(ctx.Eject().Any(), Is.False);
        }
開發者ID:springaki,項目名稱:Codersation,代碼行數:21,代碼來源:PurchaseContextTest.cs

示例3: foreach

        public void _金銭を投入して商品を受け取る_釣り銭が発生する場合()
        {
            var ctx = new Ninject.StandardKernel()
                .BindPurchaseContext()
                .Get<PurchaseContext>()
            ;

            Assert.That(ctx.CanPurchase(0), Is.False);

            ctx.ReceiveMoney(Money.Coin100);
            ctx.ReceiveMoney(Money.Coin100);

            var item = ctx.Purchase(0);
            Assert.That(item.Name, Is.EqualTo("Item0"));
            Assert.That(ctx.ReceivedTotal, Is.EqualTo(80));

            var changes = ctx.Eject()
                .GroupBy(m => m)
                .ToDictionary(g => g.Key, g => g.Count())
            ;
            var expected = new Dictionary<Money, int> {
                {Money.Coin10, 3},
                {Money.Coin50, 1},
            };

            foreach (var m in expected) {
                Assert.That(changes.ContainsKey(m.Key), Is.True);
                Assert.That(changes[m.Key], Is.EqualTo(m.Value));
            }

            var notContained = Enum.GetValues(typeof(Money))
                .Cast<Money>()
                .Where(m => ! expected.ContainsKey(m))
            ;

            foreach (var m in notContained) {
                Assert.That(changes.ContainsKey(m), Is.False);
            }
        }
開發者ID:springaki,項目名稱:Codersation,代碼行數:39,代碼來源:PurchaseContextTest.cs

示例4: foreach

        public void _金銭を投入して商品を受け取る_お劄を投入する場合()
        {
            var ctx = new Ninject.StandardKernel()
                .BindPurchaseContext()
                    .Get<PurchaseContext>()
                    ;

            Assert.That(ctx.Racks[0].State, Is.EqualTo(ItemRackState.CanNotPurchase));

            ctx.ReceiveMoney(Money. Bill1000, 1);

            var item = ctx.Purchase(0);
            Assert.That(item.Name, Is.EqualTo("Item0"));
            Assert.That(ctx.ReceivedTotal, Is.EqualTo(880));

            var changes = ctx.Eject()
                .Credits
                    .Where(c => c.Value > 0)
                    .ToDictionary(g => g.Key, g => g.Value)
                    ;
            var expected = new Dictionary<Money, int> {
                {Money.Coin10, 3},
                {Money.Coin50, 1},
                {Money.Coin500, 1},
                {Money.Coin100, 3},
            };

            foreach (var m in expected) {
                Assert.That(changes.ContainsKey(m.Key), Is.True);
                Assert.That(changes[m.Key], Is.EqualTo(m.Value));
            }

            var notContained = EnumHeler.Values<Money>()
                .Where(m => ! expected.ContainsKey(m))
                    ;

            foreach (var m in notContained) {
                Assert.That(changes.ContainsKey(m), Is.False);
            }
        }
開發者ID:posaunehm,項目名稱:Codersation,代碼行數:40,代碼來源:PurchaseContextTest.cs

示例5:

        public void _金銭を投入して商品を受け取る_丁度の場合()
        {
            var ctx = new Ninject.StandardKernel()
                .BindPurchaseContext()
                .Get<PurchaseContext>()
            ;

            Assert.That(ctx.Racks[0].State, Is.EqualTo(ItemRackState.CanNotPurchase));

            ctx.ReceiveMoney(Money.Coin100, 1);
            ctx.ReceiveMoney(Money.Coin10, 1);
            ctx.ReceiveMoney(Money.Coin10, 1);

            Assert.That(ctx.Racks[0].State, Is.EqualTo(ItemRackState.CanPurchase), "should be purchased");

            var item = ctx.Purchase(0);
            Assert.That(item.Name, Is.EqualTo("Item0"));
            Assert.That(ctx.ReceivedTotal, Is.EqualTo(0));

            Assert.That(ctx.Eject().Credits.Where(c => c.Value > 0).Any(), Is.False);
        }
開發者ID:posaunehm,項目名稱:Codersation,代碼行數:21,代碼來源:PurchaseContextTest.cs


注:本文中的Ninject.StandardKernel.ReceiveMoney方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。