Exemple #1
0
        public void TestApproveOrder()
        {
            var order = new Contracts.Order();

            order.RequiredDate = DateTime.Today.AddDays(14);
            order.CustomerID   = "VINET";
            order.EmployeeID   = 5;
            order.ShipCountry  = "RU";
            order.OrderDetails.Add(new Contracts.OrderDetail()
            {
                ProductID = 1,
                Quantity  = 10,
                UnitPrice = 15
            });

            order = client.CreateOrder(order);
            var orderId = order.OrderID;

            Assert.IsTrue(order.Status == Contracts.OrderStatus.Draft);
            Assert.IsTrue(order.OrderDetails.Count == 1);

            order = client.ApproveOrder(orderId);
            Assert.IsTrue(order.Status == Contracts.OrderStatus.InProgress);
            Assert.IsTrue(order.OrderDate != null);

            try
            {
                var actual = client.UpdateOrder(order);
                Assert.Fail("UpdateOrder should throw FaultException when in progress order is updating");
            }
            catch (FaultException ex)
            {
                Assert.IsNotNull(ex, "UpdateOrder should throw FaultException when in progress order is updating");
            }

            client.DeleteOrder(orderId);
            var orders = client.GetOrders();

            Assert.IsFalse(orders.Any(e => e.OrderID == orderId), "Approved order should be deleted.");
        }