public async Task Can_get_all_Orders_in_database() { using (var context = new ProcurementDbContext(ContextOptions)) { PurchaseOrdersController ordersController = new PurchaseOrdersController(context); var result = await ordersController.GetPurchaseOrders(); var viewResult = Assert.IsType <ActionResult <IEnumerable <PurchaseOrder> > >(result); var orders = Assert.IsType <List <PurchaseOrder> >(viewResult.Value); Assert.Single(orders); } }
public async Task GetPurchaseOrders_ActionExecute_ReturnAllPurchaseOrders() { // Arrange _mockrepo.Setup(repo => repo.PurchaseOrder.GetPurchaseOrdersAsync()) .ReturnsAsync(GetTestPurchaseOrders()); // Act var result = await _controller.GetPurchaseOrders(); // Assert var okresult = Assert.IsType <OkObjectResult>(result); var purchaseOrders = Assert.IsAssignableFrom <IEnumerable <PurchaseOrderViewModel> >(okresult.Value); purchaseOrders.Should().HaveCount(2); //Assert.Equal(2, purchaseOrders.Should().HaveCount(2)); }