Пример #1
0
        public void GetUsersFromDepartment_ContainsResult()
        {
            // Arrange
            var userService = new UserService(context);
            var user        = userService.FindUserByEmail("*****@*****.**");

            user.Department = new DepartmentService(context).FindDepartmentByDepartmentCode("ENGL");
            userService.Save(user);

            var expected   = "Admin ";
            var controller = new UserApiController
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            IHttpActionResult actionResult = controller.GetUsersFromDepartment("ENGL");
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <EmailNameViewModel> >;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsTrue(contentResult.Content.Select(x => x.Name).Contains(expected));
        }
Пример #2
0
        public void GetUsersFromDepartment_ReturnsNotFound()
        {
            // Arrange
            var controller = new UserApiController()
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            // Act
            IHttpActionResult actionResult = controller.GetUsersFromDepartment("XXXX");

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }