Ejemplo n.º 1
0
        public async Task Test_GetAll_EmployeesAsync()
        {
            var result = await _employeeController.GetAll(CancellationToken.None);

            // ensure the repository returns some data
            Assert.IsNotNull(result);

            // ensure OkObjectResult
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));

            var okObj = result as OkObjectResult;

            Assert.IsInstanceOfType(okObj.Value, typeof(QueryViewModel <EmployeeDetailsViewModel>));

            var data = okObj.Value as QueryViewModel <EmployeeDetailsViewModel>;

            Assert.IsNotNull(data);
            Assert.IsNotNull(data.QueryResponse);
            Assert.IsNotNull(data.QueryResponse.Employee);
            Assert.AreEqual(data.QueryResponse.MaxResults, 1);
            Assert.AreEqual(data.QueryResponse.StartPosition, 1);

            // check that returned data is correct
            TestEmployeeDataHelper.AssertEmployee(data.QueryResponse.Employee.FirstOrDefault());
        }
Ejemplo n.º 2
0
        public async Task Test_GetById_With_CorrectIdAsync()
        {
            var data = await _employeeRepository.GetById("Test123", CancellationToken.None);

            // ensure data is not null
            Assert.IsNotNull(data);

            // check that returned data is correct
            TestEmployeeDataHelper.AssertEmployee(data);
        }
Ejemplo n.º 3
0
        public async Task Test_GetAll_EmployeesAsync()
        {
            var data = await _employeeRepository.GetAll(CancellationToken.None);

            // ensure the repository returns some data
            Assert.IsNotNull(data);

            // ensure the result count is 1
            Assert.AreEqual(data.Count, 1);

            // test returned employee data
            TestEmployeeDataHelper.AssertEmployee(data.FirstOrDefault());
        }