public void GetAll_Positive_ReturnsList() { var dataRepo = new Mock <IDatabaseRepository>(); List <Technology> technologies = GetMockDatabase(); dataRepo.Setup(d => d.GetAllData()).Returns(technologies); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.GetAll(); var okObjectResult = actionResult as OkObjectResult; Assert.NotNull(okObjectResult); var model = okObjectResult.Value as List <Technology>; Assert.NotNull(model); Assert.Equal(technologies.Count, model.Count); }
public void GetAll_Negative_ReturnsEmptyList() { var dataRepo = new Mock <IDatabaseRepository>(); List <Technology> list = null; dataRepo.Setup(d => d.GetAllData()).Returns(list); SMEController sMEController = new SMEController(dataRepo.Object); var actionResult = sMEController.GetAll(); var okObjectResult = actionResult as OkObjectResult; Assert.NotNull(okObjectResult); var model = okObjectResult.Value as List <Technology>; Assert.NotNull(model); int expected = 0; Assert.Equal(expected, model.Count); }