예제 #1
0
        public void ShowGoodsTest()
        {
            var os = new OrderService();

            os.AddGood("a", 12);
            os.AddGood("b", 1);
            Assert.IsTrue(os.ShowGoods() == "ProductName:a, unit price:12\nProductName:b, unit price:1\n");
        }
예제 #2
0
        public void ExportAndImportTest()
        {
            var os = new OrderService();

            os.AddGood("a", 12.0);
            os.AddGood("b", 11.11);
            os.AddOrder(1, "Alice");
            var goods  = os.ShowGoods();
            var orders = os.ShowOrder(1);

            os.Export();
            os.Import();
            Assert.IsTrue(os.ShowGoods() == goods && os.ShowOrder(1) == orders);
        }
예제 #3
0
        public void TestMethod15()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            string name = "car";

            or.SortGood(name);
            Assert.IsNotNull(name);
        }
예제 #4
0
        public void TestMethod14()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            int n = 0; int num = 20;

            or.ChangeGoodDetailsNumber("car", num, n);
            Assert.IsTrue(n <= or.ListNum && num > 0);
        }
예제 #5
0
        public void TestMethod13()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            int n = 0;

            or.ChangeGoodDetailsName("car", "wawaw", n);
            Assert.IsTrue(n <= or.ListNum);
        }
예제 #6
0
        public void TestMethod12()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            int n1 = 0, n2 = 0;

            or.DeleteGoodByGoodNumber(n1, n2);
            Assert.IsTrue(n1 <= or.ListNum && n2 <= or.OrderList[n1].listNumber);
        }
예제 #7
0
        public void TestMethod11()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            int n = 0;

            or.DeleteGoodByGoodName("car", n);
            Assert.IsTrue(n <= or.ListNum);
        }
예제 #8
0
        public void TestMethod16()
        {
            OrderService or = new OrderService();

            or.AddOrder();
            or.AddGood("apple", 10, 0);
            or.AddGood("banana", 10, 0);
            or.AddGood("ipone", 10, 0);
            or.AddGood("car", 10, 0);
            or.AddGood("water", 10, 0);
            int num      = 1;
            int orderNum = 0;

            or.SortGood(num, orderNum);
            Assert.IsTrue(num >= 0 && orderNum >= 0);
        }
예제 #9
0
        public void AddGoodTest()
        {
            var os = new OrderService();

            os.AddGood("a", 12.0);
            try
            {
                os.AddGood("a", 12.0);
                Assert.Fail();
            }
            catch (Exception e)
            {
                if (e.Message != "multiple good name")
                {
                    Assert.Fail();
                }
            }
        }