示例#1
0
        public void ShouldApproveWhenOrderHasLines()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This order has an order item",
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            order.Approve();

            Assert.IsTrue(order.Valid);
            Assert.AreEqual(OrderStatus.Approved, order.Status);
            Assert.AreEqual(0, order.Notifications.Count);
        }
示例#2
0
        public void ShouldReturnErrorWhenEditOrderWithPostingDateBiggerThanDeliveryDate()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : string.Empty,
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            DateTime updatedDeliveryDate = DateTime.Today.AddDays(7);
            DateTime updatedPostingDate  = updatedDeliveryDate.AddMonths(1);
            string   updatedObservation  = "This order has Posting Date bigger than Delivery Date. When Edited";

            order.Edit(
                postingDate: updatedPostingDate,
                deliveryDate: updatedDeliveryDate,
                observation: updatedObservation);

            Assert.IsFalse(order.Valid);
            Assert.AreEqual(1, order.Notifications.Count);
        }
示例#3
0
        public void ShouldReturnSucessWhenRemoveAllOrderLines()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This sales order has no items",
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            order.RemoveOrderLine(orderLine);

            Assert.IsTrue(order.Valid);
            Assert.AreEqual(0, order.OrderLines.Count);
        }
示例#4
0
        public void ShouldReturnSucessWhenEditOrderWithCorrectInputsData()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : string.Empty,
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            DateTime updatedPostingDate  = DateTime.Today.AddDays(7);
            DateTime updatedDeliveryDate = updatedPostingDate.AddMonths(1);
            string   updatedObservation  = "Sorry, this sales order should be created next week.";


            order.Edit(
                postingDate: updatedPostingDate,
                deliveryDate: updatedDeliveryDate,
                observation: updatedObservation);

            Assert.AreEqual(order.PostingDate, updatedPostingDate);
            Assert.AreEqual(order.DeliveryDate, updatedDeliveryDate);
            Assert.AreEqual(order.Observation, updatedObservation);
            Assert.IsTrue(order.Valid);
        }
示例#5
0
        public void ShouldNotBeAbleToBillWhenOrderHasAnLineAndWasNotApproved()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This sales order can be invoiced",
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            bool expected = false;
            bool actual   = order.CanBillThisOrder();

            Assert.IsTrue(order.Valid);
            Assert.AreEqual(OrderStatus.Open, order.Status);
            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void ShouldReturnErrorWhenTryCancelAnOrderWithApprovedStatus()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "Canceled Order",
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            order.AddOrderLine(orderLine);

            order.Approve();
            order.Cancel();

            Assert.IsFalse(order.Valid);
            Assert.AreEqual(OrderStatus.Approved, order.Status);
            Assert.AreEqual(1, order.Notifications.Count);
        }
示例#7
0
        public void ShouldCalculateTotalOrderWhenAddSomeLines(int quantityOrderItem)
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This order has some order item",
                customer : CustomerTests.GetCustomer());

            var product = ProductTests.GetProduct();

            var orderLine = new OrderLine(
                quantity: product.CombinedQuantity,
                unitaryPrice: product.CombinedPrice,
                additionalCosts: product.AdditionalCosts,
                product: product);

            for (int i = 0; i < quantityOrderItem; i++)
            {
                order.AddOrderLine(orderLine);
            }

            decimal expected = quantityOrderItem * (product.CombinedQuantity * (product.CombinedPrice + product.AdditionalCosts));

            Assert.IsTrue(order.Valid);
            Assert.AreEqual(expected, order.TotalOrder);
            Assert.AreEqual(0, order.Notifications.Count);
        }
示例#8
0
        public void ShouldReturnSuccessWhenOrderIsValid()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This sales order has no items, but may include items in the future",
                customer : CustomerTests.GetCustomer());

            Assert.IsNotNull(order);
            Assert.IsTrue(order.Valid);
        }
示例#9
0
        public void ShouldReturnErrorWhenPostingDateIsBiggerThanDeliveryDate()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order orderWithIncorrrectDeliveryDate = new(
                postingDate : nextMonth,
                deliveryDate : DateTime.Today,
                observation : "This order has an incorrect Delivery date",
                customer : CustomerTests.GetCustomer());

            Assert.IsFalse(orderWithIncorrrectDeliveryDate.Valid);
            Assert.IsFalse(orderWithIncorrrectDeliveryDate.PostingDate <= orderWithIncorrrectDeliveryDate.DeliveryDate);
            Assert.AreEqual(1, orderWithIncorrrectDeliveryDate.Notifications.Count);
        }
示例#10
0
        public void ShouldReturnErrorWhenTryApproveAnOrderWithoutLines()
        {
            var nextMonth = DateTime.Today.AddMonths(1);

            Order order = new(
                postingDate : DateTime.Today,
                deliveryDate : nextMonth,
                observation : "This order has Open status",
                customer : CustomerTests.GetCustomer());

            order.Approve();

            Assert.IsFalse(order.Valid);
            Assert.AreEqual(OrderStatus.Open, order.Status);
            Assert.AreEqual(1, order.Notifications.Count);
        }