public async void TestApiPostForOrder()
        {
            ModelAddToCart model = new ModelAddToCart();

            model.InventoryId = 2;
            model.Numdays     = 5;
            model.Token       = token;

            //add to cart
            ApiInventoryController inventoryController = new ApiInventoryController(null);
            var jsonResult = await inventoryController.Post(model);

            Assert.NotNull(jsonResult);
            Assert.True(jsonResult.Success);

            //submit the order
            var submitted = controller.SubmitOrder();

            Assert.NotNull(submitted);

            //check order
            var             mockOrderRepository    = new Mock <IApiOrderRepository>();
            var             mockLogger             = new Mock <ILogger <OrderController> >();
            var             mockCustomerRepository = new Mock <IApiCustomerRepository>();
            OrderController orderController        = new OrderController(null, mockLogger.Object, mockOrderRepository.Object, mockCustomerRepository.Object, memoryCache);

            var result = await orderController.Order(token) as ViewResult;

            var viewResult  = Assert.IsType <ViewResult>(result);
            var modelResult = Assert.IsAssignableFrom <ViewResult>(viewResult);

            Assert.NotNull(modelResult);
        }
Example #2
0
        public async void TestApiPostInventory()
        {
            ModelAddToCart model = new ModelAddToCart();

            model.InventoryId = 1;
            model.Numdays     = 3;
            model.Token       = token;

            var jsonResult = await controller.Post(model);

            Assert.NotNull(jsonResult);
            Assert.Equal("", jsonResult.Message);
            Assert.True(jsonResult.Success);

            var result = await controller.Get(token);

            Assert.NotNull(result);
            Assert.Equal(5, result.Item1.Count);
            Assert.Equal(1, result.Item2);
        }