示例#1
0
        public async Task ShouldRequireMinimumFields()
        {
            var command = new CreateRaceCommand();

            var result = await SendAsync(command);

            result.IsBadRequest.Should().BeTrue();
            result.ValidationFailures.Should().ContainNotEmptyValidationErrorForProperty(nameof(CreateRaceCommand.Name));
        }
示例#2
0
        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 }));
        }
示例#3
0
        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);
                }
            }
        }
示例#5
0
        public void Post(Race race)
        {
            var command = new CreateRaceCommand();

            command.CreateRace(race);
        }