public async Task Should_Get_All_Employees() { //Arrange _employeeDataAccessMock.Setup(x => x.GetEmployees()).ReturnsAsync(EmployeesDataMock.AsQueryable()); //Act var employees = await _serviceUnderTest.GetEmployees(); //Assert Assert.True(employees.Any()); }
public async Task Should_Get_All_Employees() { //Arrange _employeeServiceMock.Setup(x => x.GetEmployees()).ReturnsAsync(EmployeesDataMock.AsQueryable()); //Act var result = await _controllerUnderTest.GetEmployees(); //Assert Assert.IsInstanceOfType(result, typeof(OkObjectResult)); Assert.IsNotNull(((OkObjectResult)result).Value); Assert.IsTrue(((IEnumerable <Employees>)((OkObjectResult)result).Value).Any()); }
public async Task Should_Return_Delete_Status(int employeeId, bool?expectedResult) { //Arrange _employeeDataAccessMock.Setup(x => x.GetEmployees()).ReturnsAsync(EmployeesDataMock.AsQueryable()); _employeeDataAccessMock.Setup(x => x.DeleteEmployee(employeeId)) .ReturnsAsync(Convert.ToBoolean(expectedResult)); //Act bool?actualResult = await _serviceUnderTest.DeleteEmployee(employeeId); //Assert Assert.Equal(expectedResult, actualResult); }
public async Task Should_Get_All_Employees() { //Arrange _employeeServiceMock.Setup(x => x.GetEmployees()).ReturnsAsync(EmployeesDataMock.AsQueryable()); //Act var result = await _controllerUnderTest.GetEmployees(); //Assert var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult.Value); Assert.True(((IEnumerable <Employees>)okObjectResult.Value).Any()); }
public async Task Should_Return_Employee_Data(int employeeId, int?expectedResult) { //Assert _employeeDataAccessMock.Setup(x => x.GetEmployees()).ReturnsAsync(EmployeesDataMock.AsQueryable()); //Act var actualResult = await _serviceUnderTest.GetEmployeeById(employeeId); //Assert if (expectedResult == null) { Assert.Null(actualResult); } else { Assert.Equal(employeeId, actualResult.Id); } }