Пример #1
0
        public void CreateNewValidOrder_OrderIsAddedInDatabase_ObjectIsInDatabase()
        {
            //Arrange
            var   viewModel = new OrderViewModel();
            Order order     = OrderCreator.CreateOrder("Client", 124, "Roll", 1, 12.2m);

            //Action
            viewModel.AddNewOrder(order);
            int numberOfOrders = viewModel.GetNumberOfOrders();

            //Assert
            Assert.AreEqual(1, numberOfOrders);
        }
Пример #2
0
        public void GetAveragePriceOfOrderOfSpecificClient_OrdersExistInDatabase_AveragePriceIsReturned()
        {
            //Arrange
            var    viewModel   = new OrderViewModel();
            string clientId    = "id1";
            var    ordersToAdd = OrderCreator.CreateOrders_ForSpecificCLient_TwoOrdersWithSameRequestId(clientId);
            var    orderWithDifferentRequestIdForSameClient = OrderCreator.CreateOrder(clientId, 2, "Roll", 2, 4m);

            viewModel.AddNewOrder(orderWithDifferentRequestIdForSameClient);
            viewModel.AddNewOrders(ordersToAdd);
            decimal average = 127.2m;    // calculated based on the orders added into database for specific client
                                         // first request => 12 * 12.2 + 10 * 10 = 246.4 because first and second order have same request_id
                                         // second request => 2 * 4 = 8
                                         // average = 127.2

            //Action
            decimal averagePrice = viewModel.GetAveragePriceOfOrderOfSpecificClient("id1");

            //Assert
            Assert.AreEqual(average, averagePrice);
        }