public async Task Handle_GivenValidId_ShouldUpdatePersistedWeddingDescription() { var command = new UpdateWeddingDescriptionCommand { Id = 1, GroomDescription = "Test Update GroomDescription", BrideDescription = "Test Update BrideDescription", CeremonyDateTimeLocation = "Test Update CeremonyDateTimeLocation", CeremonyDescription = "Test Update CeremonyDescription", ReceptionDateTimeLocation = "Test Update ReceptionDateTimeLocation", ReceptionDescription = "Test Update ReceptionDescription" }; var handler = new UpdateWeddingDescriptionCommand.UpdateWeddingDescriptionCommandHandler(Context); await handler.Handle(command, CancellationToken.None); var entity = Context.WeddingDescriptions.Find(command.Id); entity.ShouldNotBeNull(); entity.GroomDescription.ShouldBe(command.GroomDescription); entity.BrideDescription.ShouldBe(command.BrideDescription); entity.CeremonyDateTimeLocation.ShouldBe(command.CeremonyDateTimeLocation); entity.CeremonyDescription.ShouldBe(command.CeremonyDescription); entity.ReceptionDateTimeLocation.ShouldBe(command.ReceptionDateTimeLocation); entity.ReceptionDescription.ShouldBe(command.ReceptionDescription); }
public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet() { var command = new UpdateWeddingDescriptionCommand(); var validator = new UpdateWeddingDescriptionCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }
public async Task <ActionResult> Update(long id, UpdateWeddingDescriptionCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public void Handle_GivenInvalidId_ThrowsException() { var command = new UpdateWeddingDescriptionCommand { Id = 99, GroomDescription = "Test Update GroomDescription", BrideDescription = "Test Update BrideDescription", CeremonyDateTimeLocation = "Test Update CeremonyDateTimeLocation", CeremonyDescription = "Test Update CeremonyDescription", ReceptionDateTimeLocation = "Test Update ReceptionDateTimeLocation", ReceptionDescription = "Test Update ReceptionDescription" }; var handler = new UpdateWeddingDescriptionCommand.UpdateWeddingDescriptionCommandHandler(Context); Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public void IsValid_ShouldBeTrue_WhenRequiredFieldsAreSet() { var command = new UpdateWeddingDescriptionCommand { GroomDescription = "test", BrideDescription = "test", CeremonyDateTimeLocation = "test", CeremonyDescription = "test", ReceptionDateTimeLocation = "test", ReceptionDescription = "test" }; var validator = new UpdateWeddingDescriptionCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public async Task GivenValidUpdateWeddingDescriptionCommand_ReturnsSuccessCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateWeddingDescriptionCommand { Id = 1, GroomDescription = "Test Update", BrideDescription = "Test Update", CeremonyDateTimeLocation = "Test Update", CeremonyDescription = "Test Update", ReceptionDateTimeLocation = "Test Update", ReceptionDescription = "Test Update", }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/WeddingDescription/{command.Id}", content); response.EnsureSuccessStatusCode(); }