示例#1
0
        public void DeleteUserTest()
        {
            //Arrange
            var repoMock     = new Mock <IUserRepo>();
            var returnedList = new List <UserDto> {
                new UserDto
                {
                    id       = 1,
                    name     = "test1",
                    surname  = "test1",
                    email    = "test1",
                    verified = false,
                    admin    = false
                }
            };

            repoMock.Setup(p => p.RemoveUserById(2)).Returns(returnedList);
            var service = new AdminManageUserServices(repoMock.Object);
            var ctl     = new AdminManageUserController(service);

            // Act
            var result = ctl.removeUser(2).Result as OkObjectResult;

            // Assert
            result.Value.Should().BeEquivalentTo(returnedList, options => options.ComparingByMembers <UserDto>());
        }
示例#2
0
        public void UpdateUserTest()
        {
            // Arrange
            var repoMock = new Mock <IUserRepo>();
            var userDTO  = new UserDto
            {
                id       = 1,
                name     = "test1",
                surname  = "test1",
                email    = "test1",
                verified = false,
                admin    = false
            };
            var inputDTO = new UserInputDto
            {
                name     = "test1",
                surname  = "test1",
                email    = "test1",
                verified = false,
                admin    = false
            };

            repoMock.Setup(p => p.UpdateUserById(1, inputDTO)).Returns(userDTO);
            var service = new AdminManageUserServices(repoMock.Object);
            var ctl     = new AdminManageUserController(service);

            // Act
            var result = ctl.updateUser(1, inputDTO).Result as OkObjectResult;

            // Assert
            result.Value.Should().BeEquivalentTo(userDTO, options => options.ComparingByMembers <UserDto>());
        }