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_Return_New_EmployeeId(int expectedEmployeeId) { //Arrange var employeeCreate = EmployeesDataMock.FirstOrDefault(); employeeCreate.Id = expectedEmployeeId; //Act int actualEmployeeId = await _dataAccessUnderTest.CreateEmployee(employeeCreate); //Assert Assert.Equal(expectedEmployeeId, actualEmployeeId); }
public async Task Should_Return_BadRequest_Result(int employeeId) { //Arrange _employeeServiceMock.Setup(x => x.GetEmployeeById(employeeId)) .ReturnsAsync(EmployeesDataMock.FirstOrDefault(x => x.Id == employeeId)); //Act var actionResult = await _controllerUnderTest.GetEmployeeById(employeeId); //Assert Assert.IsInstanceOfType(actionResult, typeof(BadRequestObjectResult)); Assert.IsNotNull(((BadRequestObjectResult)actionResult).Value); }
public async Task Should_Get_Employee_By_Id(int employeeId) { //Arrange _employeeServiceMock.Setup(x => x.GetEmployeeById(employeeId)) .ReturnsAsync(EmployeesDataMock.FirstOrDefault(x => x.Id == employeeId)); //Act var actionResult = await _controllerUnderTest.GetEmployeeById(employeeId); //Assert Assert.IsInstanceOfType(actionResult, typeof(OkObjectResult)); Assert.AreEqual(employeeId, ((Employees)((OkObjectResult)actionResult).Value).Id); }
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_Return_BadRequest_Result(int employeeId) { //Arrange _employeeServiceMock.Setup(x => x.GetEmployeeById(employeeId)) .ReturnsAsync(EmployeesDataMock.FirstOrDefault(x => x.Id == employeeId)); //Act var actionResult = await _controllerUnderTest.GetEmployeeById(employeeId); //Assert var result = Assert.IsType <BadRequestObjectResult>(actionResult); Assert.NotNull(result.Value); }
public async Task Should_Get_Employee_By_Id(int employeeId) { //Arrange _employeeServiceMock.Setup(x => x.GetEmployeeById(employeeId)) .ReturnsAsync(EmployeesDataMock.FirstOrDefault(x => x.Id == employeeId)); //Act var actionResult = await _controllerUnderTest.GetEmployeeById(employeeId); //Assert var result = Assert.IsType <OkObjectResult>(actionResult); Assert.Equal(employeeId, ((Employees)result.Value).Id); }
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); } }