public async Task <IActionResult> UpdateBabySitter(int id, [FromBody] UpdateBabySitterArgs args) { args = args.WithId(id); await _commandBus.Execute(args); return(NoContent()); }
public async Task ShouldThrowValidationException() { var sitter = _context.Add(ModelFactory.CreateSitter()).Entity; _context.SaveChanges(); var args = new UpdateBabySitterArgs(sitter.Id, null, null, 3, 2, 1); await Assert.ThrowsAsync <ValidationException>(() => _command.Execute(args)); }
public async Task UpdateBabySitter(int sitterId, string firstName, string lastName, int hourlyRate, int hourlyRateBetweenBedtimeAndMidnight, int hourlyRateAfterMidnight) { var updateArgs = new UpdateBabySitterArgs(sitterId, firstName, lastName, hourlyRate, hourlyRateBetweenBedtimeAndMidnight, hourlyRateAfterMidnight); using (var client = CreateClient()) { await client.PutJsonAsync($"babysitters/{sitterId}", updateArgs); } }
public async Task ShouldUpdateSitter() { var sitter = _context.Add(ModelFactory.CreateSitter()).Entity; _context.SaveChanges(); var args = new UpdateBabySitterArgs( sitter.Id, "Bob", "John", 45, 12, 100); await _command.Execute(args); Assert.Equal("Bob", sitter.FirstName); Assert.Equal("John", sitter.LastName); Assert.Equal(45, sitter.HourlyRates.Standard); Assert.Equal(12, sitter.HourlyRates.BetweenBedtimeAndMidnight); Assert.Equal(100, sitter.HourlyRates.AfterMidnight); }
public async Task ShouldThrowEntityNotFoundException() { var args = new UpdateBabySitterArgs(int.MaxValue, "12", "3", 1, 1, 1); await Assert.ThrowsAsync <EntityNotFoundException <Sitter> >(() => _command.Execute(args)); }