Пример #1
0
        public void GetProduct_ShouldNotFindProduct()
        {
            var controller = new WebApi_UnitTestController(GetTestProducts());

            var result = controller.GetProduct(999);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Пример #2
0
        public async Task GetAllProductsAsync_ShouldReturnAllProducts()
        {
            var testProducts = GetTestProducts();
            var controller   = new WebApi_UnitTestController(testProducts);

            var result = await controller.GetAllProductsAsync() as List <WebApi_Test>;

            Assert.AreEqual(testProducts.Count, result.Count);
        }
Пример #3
0
        public void GetAllProducts_ShouldReturnAllProducts()
        {
            var testProducts = GetTestProducts();
            var controller   = new WebApi_UnitTestController(testProducts);

            var result = controller.GetAllProducts() as List <WebApi_Test>;

            Assert.AreEqual(testProducts.Count, result.Count);
        }
Пример #4
0
        public async Task GetProductAsync_ShouldReturnCorrectProduct()
        {
            var testProducts = GetTestProducts();
            var controller   = new WebApi_UnitTestController(testProducts);

            var result = await controller.GetProductAsync(4) as OkNegotiatedContentResult <WebApi_Test>;

            Assert.IsNotNull(result);
            Assert.AreEqual(testProducts[3].Name, result.Content.Name);
        }