public void TestCloseOrderStatus()
        {
            // Arrange
            Order           order;
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(2, parts[1]);
            orderController.AddPart(2, parts[2]);

            orderController.CloseOrder(3, partRepository);

            order = orderController.Retrieve(3);

            string expected = "Closed";

            // Act
            string actual = order.Status;


            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestRemovePart()
        {
            // Arrange
            Order           order;
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(2, parts[1]);
            orderController.AddPart(2, parts[2]);
            orderController.RemovePart(2, 2);
            order = orderController.Retrieve(2);

            List <Part> orderedPart = order.Parts;

            int expected = 1;

            // Act
            int actual = orderedPart.Count;


            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestAddPart()
        {
            // Arrange
            Part            part;
            Order           order;
            PartCategory    partCategory;
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(2, parts[1]);
            order = orderController.Retrieve(2);

            List <Part> orderedPart = order.Parts;

            part         = orderedPart[0];
            partCategory = part.Category;

            string expected = "Brakes";


            // Act
            string actual = partCategory.Decription;


            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            InfoDisplay     infoDisplay     = new InfoDisplay();
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();
            ReportGenerator reportGenerator = new ReportGenerator(orderController);

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            infoDisplay.ShowPartsInStock(partRepository);

            orderController.AddPart(1, parts[1]);
            orderController.AddPart(1, parts[2]);
            orderController.AddPart(2, parts[3]);
            orderController.AddPart(2, parts[4]);
            orderController.AddPart(3, parts[5]);
            orderController.AddPart(3, parts[0]);

            infoDisplay.ShowAvailablePartsInStock(orderController, partRepository);

            orderController.CloseOrder(3, partRepository);

            infoDisplay.ShowAllOrders(reportGenerator);

            infoDisplay.ShowPartsInStock(partRepository);

            Console.ReadLine();
        }
Exemplo n.º 5
0
        public void TestGenerateReportByOrderId()
        {
            // Arrange
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();
            ReportGenerator reportGenerator = new ReportGenerator(orderController);

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(1, parts[1]);
            orderController.AddPart(1, parts[2]);
            orderController.AddPart(2, parts[3]);
            orderController.AddPart(2, parts[4]);
            orderController.AddPart(3, parts[5]);
            orderController.AddPart(3, parts[0]);

            int expected = 1;

            // Act
            int actual = reportGenerator.GenerateReport(2).Count;

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestCheckOrPartIsReserved()
        {
            // Arrange
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(2, parts[1]);
            orderController.AddPart(2, parts[2]);

            orderController.CloseOrder(2, partRepository);

            int expected = 6;

            // Act
            int actual = orderController.GetAvailableParts(partRepository).Count;

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void TestOrPartsIsRemovedFromPartsListAfterClosingOrder()
        {
            // Arrange
            OrderController orderController = new OrderController();
            PartRepository  partRepository  = new PartRepository();
            List <Part>     parts           = partRepository.Retrieve();

            orderController.CreateNewOrder(1, "UAB EAMV");
            orderController.CreateNewOrder(2, "UAB Rasmitas");
            orderController.CreateNewOrder(3, "UAB TRT Shop");

            orderController.AddPart(2, parts[1]);
            orderController.AddPart(2, parts[2]);

            orderController.CloseOrder(2, partRepository);

            int expected = 6;

            // Act
            int actual = partRepository.Retrieve().Count;

            // Assert
            Assert.AreEqual(expected, actual);
        }