示例#1
0
            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());
            }
示例#2
0
            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());
            }
示例#3
0
            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);
            }
示例#4
0
            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());
            }
示例#5
0
            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);
                }
            }