public async void AddMembersToTeam_Invalid_UserId_Or_TeamId() { //Given int teamId = 0; List <User> users = new List <User>(); //When var controller = new TeamController(logger.Object, teamServiceMoq.Object); var response = await controller.AddMembersToTeam(users, teamId) as BadRequestObjectResult; //Then Assert.IsType <BadRequestObjectResult>(response); Assert.Equal($"Invalid Users : {users} or TeamId : {teamId}", response.Value); }
public async void AddMembersToTeam_UnSuccessfull() { //Given int teamId = 1, usersAddedToTeam = 0; User user = new User() { UserId = 1, FirstName = "John" }; List <User> users = new List <User>() { user }; teamServiceMoq.Setup(e => e.AddMembersToTeam(users, teamId)).ReturnsAsync(usersAddedToTeam); //When var controller = new TeamController(logger.Object, teamServiceMoq.Object); var response = await controller.AddMembersToTeam(users, teamId) as NotFoundObjectResult; //Then Assert.IsType <NotFoundObjectResult>(response); Assert.Equal("Unsuccessfull while adding members to team ", response.Value); teamServiceMoq.Verify(e => e.AddMembersToTeam(users, teamId), Times.Once); }