public async Task Handle_GivenValidId_ShouldUpdatePersistedFamily() { var command = new UpdateFamilyCommand { Id = 1, GuestId = 1, ConfirmationCode = "Test ConfirmationCode Update", Address1 = "Test Address1 Update", Address2 = "Test Address2 Update", City = "Test City Update", StateId = 1, Zip = "Test Zip Update" }; var handler = new UpdateFamilyCommand.UpdateFamilyCommandHandler(Context); await handler.Handle(command, CancellationToken.None); var entity = Context.Families.Find(command.Id); entity.ShouldNotBeNull(); entity.GuestId.ShouldBe(command.GuestId); entity.ConfirmationCode.ShouldBe(command.ConfirmationCode); entity.Address1.ShouldBe(command.Address1); entity.Address2.ShouldBe(command.Address2); entity.City.ShouldBe(command.City); entity.StateId.ShouldBe(command.StateId); entity.Zip.ShouldBe(command.Zip); }
public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet() { var command = new UpdateFamilyCommand(); var validator = new UpdateFamilyCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }
public async Task <ActionResult> Update(long id, UpdateFamilyCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public void Handle_GivenInvalidId_ThrowsException() { var command = new UpdateFamilyCommand { Id = 99, GuestId = 1, ConfirmationCode = "Test ConfirmationCode Update", Address1 = "Test Address1 Update", Address2 = "Test Address2 Update", City = "Test City Update", StateId = 1, Zip = "Test Zip Update" }; var handler = new UpdateFamilyCommand.UpdateFamilyCommandHandler(Context); Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public void IsValid_ShouldBeTrue_WhenRequiredFieldsAreSet() { var command = new UpdateFamilyCommand { Id = 1, GuestId = 1, ConfirmationCode = "Test ConfirmationCode Update", Address1 = "Test Address1 Update", Address2 = "Test Address2 Update", City = "Test City Update", StateId = 1, Zip = "Test Zip Update" }; var validator = new UpdateFamilyCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public async Task GivenValidUpdateFamilyCommand_ReturnsSuccessCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateFamilyCommand { Id = 1, GuestId = 1, ConfirmationCode = "Test ConfirmationCode Update", Address1 = "Test Address1 Update", Address2 = "Test Address2 Update", City = "Test City Update", StateId = 1, Zip = "Test Zip Update" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/Family/{command.Id}", content); response.EnsureSuccessStatusCode(); }