当前位置: 首页>>代码示例>>C#>>正文


C# Solution.Order方法代码示例

本文整理汇总了C#中Solution.Order方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.Order方法的具体用法?C# Solution.Order怎么用?C# Solution.Order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solution的用法示例。


在下文中一共展示了Solution.Order方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test_CK_einProduktZweiMal

        public void Test_CK_einProduktZweiMal()
        {
            var sut = new Solution();

            var products = new Products { { "Apfel", 10 } };

            var success = false;

            sut.Setup(products, new ProductPackages());

            var price = 0;
            sut.SendPrice += p =>
            {
                price = p;
                Debug.WriteLine("{0},", price);
            };

            sut.Order("Apfel");
            price.Should().Be(10);
            sut.Order("Apfel");
            price.Should().Be(20);
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:22,代码来源:Test.cs

示例2: Test_CK_einProduktZweiMal_InsPaket

        public void Test_CK_einProduktZweiMal_InsPaket()
        {
            var sut = new Solution();

            var products = new Products { { "Apfel", 10 } };

            var success = false;

            var productPackages = new ProductPackages
            {
                new ProductPackage(){ Price = 15, Products = { "Apfel", "Apfel" }},

            };

            sut.Setup(products, productPackages);

            var price = 0;
            sut.SendPrice += p =>
            {
                price = p;
                Debug.WriteLine("{0},", price);
            };

            sut.Order("Apfel");
            price.Should().Be(10);
            sut.Order("Apfel");
            price.Should().Be(15);
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:28,代码来源:Test.cs

示例3: Test_switch_to_another_package

        public void Test_switch_to_another_package()
        {
            var sut = new Solution();

            var products = new Products {{"A", 10}, {"B", 20}, {"C", 30}};
            var productPackages = new ProductPackages
            {
                new ProductPackage {Price = 29, Products = new List<string> {"A", "B"}},
                new ProductPackage {Price = 48, Products = new List<string> {"B", "C"}},
            };

            sut.Setup(products, productPackages);

            var price = 0;
            sut.SendPrice += p => price = p;

            sut.Order("A");
            sut.Order("B");
            price.Should().Be(29, "there is a package for A and B with price 29.");

            sut.Order("C");

            price.Should().Be(10 + 48, "it is cheaper to take package B & C");
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:24,代码来源:Test.cs

示例4: Test_quantity_discount

        public void Test_quantity_discount()
        {
            var sut = new Solution();

            var products = new Products {{"A", 10}};
            var productPackages = new ProductPackages
            {
                new ProductPackage {Price = 19, Products = new List<string> {"A", "A"}},
                new ProductPackage {Price = 27, Products = new List<string> {"A", "A", "A"}},
            };

            sut.Setup(products, productPackages);

            var price = 0;
            sut.SendPrice += p => price = p;

            sut.Order("A");
            price.Should().Be(10);

            sut.Order("A");
            price.Should().Be(19);

            sut.Order("A");
            price.Should().Be(27);

            sut.Order("A");
            price.Should().Be(27 + 10);

            sut.Order("A");
            price.Should().Be(27 + 19);

            sut.Order("A");
            price.Should().Be(2 * 27);
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:34,代码来源:Test.cs

示例5: Test_order_single_product_twice

        public void Test_order_single_product_twice()
        {
            var sut = new Solution();

            var products = new Products {{"A", 10}};
            var price = 0;

            sut.Setup(products, new ProductPackages());

            sut.SendPrice += p => price = p;

            sut.Order("A");
            sut.Order("A");

            price.Should().Be(20);
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:16,代码来源:Test.cs

示例6: Test_impossible_product

        public void Test_impossible_product()
        {
            var sut = new Solution();

            var products = new Products {{"A", 10}, {"B", 20}, {"C", 30}};

            var success = false;

            sut.Setup(products, new ProductPackages());

            sut.SendPrice += p => success = true;

            sut.Order("D");

            success.Should().BeFalse();
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:16,代码来源:Test.cs

示例7: Test_if_pitfall_package_is_ignored

        public void Test_if_pitfall_package_is_ignored()
        {
            var sut = new Solution();

            var products = new Products {{"A", 10}};
            var productPackages = new ProductPackages
            {
                new ProductPackage {Price = 21, Products = new List<string> {"A", "A"}}
            };

            sut.Setup(products, productPackages);

            var price = 0;
            sut.SendPrice += p => price = p;

            sut.Order("A");
            price.Should().Be(10);

            sut.Order("A");
            price.Should().Be(2 * 10, "package is a pitfall");
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:21,代码来源:Test.cs

示例8: Test_Forum

        public void Test_Forum()
        {
            var sut = new Solution();

            var products = new Products {
                { "VegMac", 4 },
                { "BurgerMac", 1 },
                { "WoodMac", 3 },
                { "MacMac", 5 },
                { "PommesPommes", 2 },
                { "Pommes", 1 },
                { "PommesGr", 1 },
                { "Cola", 3 }
            };

            var productPackages = new ProductPackages
            {
                new ProductPackage(){ Price = 1, Products = { "MacMac", "Cola" }},
                new ProductPackage(){ Price = 10, Products = { "BurgerMac", "WoodMac", "Pommes", "Cola" }},
                new ProductPackage(){ Price = 7, Products = { "VegMac", "Cola", "Pommes" }},
                new ProductPackage(){ Price = 7, Products = { "VegMac", "Cola", "PommesGr" }},
                new ProductPackage(){ Price = 2, Products = { "Cola", "PommesGr" }},
                new ProductPackage(){ Price = 1, Products = { "VegMac", "Cola", "Pommes", "Pommes" }}
            };

            sut.Setup(products, productPackages);

            var price = 0;
            sut.SendPrice += p =>
            {
                price = p;
                Debug.WriteLine("{0},",price);
            };

            sut.Order("VegMac");
            price.Should().Be(4);
            sut.Order("VegMac");
            price.Should().Be(8);
            sut.Order("VegMac");
            price.Should().Be(12);
            sut.Order("Pommes");
            price.Should().Be(13);
            sut.Order("Cola");
            price.Should().Be(15); // P3 + 2xVegMac
            sut.Order("Pommes");
            price.Should().Be(9); // P3 + P6 + 1xVegMac
            sut.Order("PommesGr");
            price.Should().Be(10); // P4 + P6 + 1xPommes
            sut.Order("MacMac");
            price.Should().Be(15); // P4 + P6 + 1xPommes + 1xMacMac
            sut.Order("WoodMac");
            price.Should().Be(18); // P4 + P6 + 1xPommes + 1xMacMac + 1xWoodMac
            sut.Order("BurgerMac");
            price.Should().Be(19); // P4 + P6 + 1xPommes + 1xMacMac + 1xWoodMac + 1xBurgeMac
            sut.Order("MacMac");
            price.Should().Be(24); // P4 + P6 + 1xPommes + 2xMacMac + 1xWoodMac + 1xBurgeMac
            sut.Order("PommesPommes");
            price.Should().Be(26); // P4 + P6 + 1xPommes + 2xMacMac + 1xWoodMac + 1xBurgeMac + PommesPommes
            sut.Order("Pommes");
            price.Should().Be(27); // P4 + P6 + 2xPommes + 2xMacMac + 1xWoodMac + 1xBurgeMac + PommesPommes
            sut.Order("Cola");
            price.Should().Be(23); // P1 + P4 + P6 + 2xPommes + 1xMacMac + 1xWoodMac + 1xBurgeMac + PommesPommes
        }
开发者ID:chrkon,项目名称:dotnetpro_Contests,代码行数:63,代码来源:Test.cs


注:本文中的Solution.Order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。