public async void LunchRepository_AddUserToTeamAsync_ReturnsWithoutErrorWhenComboAlreadyExists() { // arrange LunchContext context = GetContext(); LunchRepository target = new LunchRepository(context); TeamEntity team = context.Teams.Add(new TeamEntity { Name = "bob's team" }).Entity; UserEntity user = context.Users.Add(new UserEntity { Name = "bob" }).Entity; context.UserTeams.Add(new UserTeamEntity { UserId = user.Id, TeamId = team.Id }); context.SaveChanges(); // act await target.AddUserToTeamAsync(user.Id, team.Id); // assert // no exception thrown }
public async void LunchRepository_AddUserToTeamAsync_AddsUserToTeam() { // arrange LunchContext context = GetContext(); LunchRepository target = new LunchRepository(context); TeamEntity team = context.Teams.Add(new TeamEntity { Name = "bob's team" }).Entity; UserEntity user = context.Users.Add(new UserEntity { Name = "bob" }).Entity; context.SaveChanges(); // act await target.AddUserToTeamAsync(user.Id, team.Id); // assert var userTeam = context.UserTeams.First(); Assert.Equal(team.Id, userTeam.TeamId); Assert.Equal(user.Id, userTeam.UserId); }