public async Task ShouldRequireMinimumFields() { var command = new CreateRaceCommand(); var result = await SendAsync(command); result.IsBadRequest.Should().BeTrue(); result.ValidationFailures.Should().ContainNotEmptyValidationErrorForProperty(nameof(CreateRaceCommand.Name)); }
public async Task <ActionResult <int> > PostRace(CreateRaceCommand race) { var result = await _mediator.Send(race); return(ResponseHelpers.BuildCreatedAtResponse( this, result, nameof(GetRace), () => new { id = result.Content })); }
public async Task ShouldCreateRace() { var command = new CreateRaceCommand() { Name = "Tour de France 2020", }; var result = await SendAsync(command); var race = await FindAsync <Race>(result.Content); race.Should().NotBeNull(); race.Name.Should().Be("Tour de France 2020"); }
public void Seed() { using (var db = new LiteDatabase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyData.db"))) { if (db.CollectionExists("Race")) { return; } var command = new CreateRaceCommand(); foreach (var data in SeedData()) { command.CreateRace(data); } } }
public void Post(Race race) { var command = new CreateRaceCommand(); command.CreateRace(race); }