public void Index_Retrive_All_Data() { var actionResult = _warehouseController.Index(); var viewResult = actionResult as ViewResult; var viewResultModel = (Warehouse[]) viewResult.Model; var warehouses = viewResultModel.ToList(); Assert.AreEqual(2, warehouses.Count); }
public async Task Index_Success() { //Arrange var parts = new List <Part> { new Part(), new Part() }; warehouseService.Setup(x => x.GetParts()).Returns(Task.FromResult(parts)); //Act var action = await warehouseController.Index(reference, productId) as ViewResult; var model = action.Model as PartsViewModel; //Assert Assert.Equal(reference, model.Reference); Assert.Equal(productId, model.ProductId); Assert.Equal(parts.Count, model.Parts.Count); }