public async Task AddStadiumCommand_Can_Add_Stadium() { using (var dbContext = GetDbContext("AddStadiumCommand_Can_Add_Stadium")) { var fakePlayerRepo = new PlayerRepository(dbContext); await fakePlayerRepo.AddAsync(new Domain.Entities.Player { Name = "FirstPlayer", Surname = "LastName", Height = 1.98, EmailAddress = "*****@*****.**" }); await fakePlayerRepo.AddAsync(new Domain.Entities.Player { Name = "SecondPlayer", Surname = "LastName", Height = 1.98, EmailAddress = "*****@*****.**" }); var fakeTeamRepo = new TeamRepository(dbContext); var players = fakePlayerRepo.GetAll(); await fakeTeamRepo.AddAsync(new Domain.Entities.Team { Name = "FirstTeam", Players = players.ToList() }); } using (var dbContext = GetDbContext("AddStadiumCommand_Can_Add_Stadium")) { var fakeStadiumRepo = new StadiumRepository(dbContext); var fakeTeamRepo = new TeamRepository(dbContext); var fakeLogger = new Mock <ILogger <AddStadiumCommandHandler> >(); var handler = new AddStadiumCommandHandler(fakeStadiumRepo, fakeTeamRepo, GetMapper(), fakeLogger.Object); var command = new AddStadiumCommand { Name = "TestStadiumName", TeamId = 1 }; var result = await handler.Handle(command, default); Assert.False(result.Notifications.HasErrors()); Assert.Equal(command.Name, result.StadiumLookupModel.Name); Assert.Equal(command.TeamId, result.StadiumLookupModel.Team.Id); } }
public async Task <ActionResult <StadiumViewModel> > Add([FromBody] AddStadiumCommand addStadiumCommand) { return(ResolveResult(await Mediator.Send(addStadiumCommand))); }