public async Task <ActionResult> Update(int id, UpdateCurvePointItemCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task Handle_InvalidId_ThrowsException() { var command = new UpdateCurvePointItemCommand { Id = 22, AsOfDate = new DateTime(2019, 01, 20), CurveId = 2, Term = 4, Value = 5 }; var handler = new UpdateCurvePointItemCommand.UpdateCurvePointItemCommandHandler(dbContext, mapper); await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public async Task GivenInvalidUpdateCurveItemCommand_ReturnsBadRequest() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateCurvePointItemCommand { Id = 1, AsOfDate = new DateTime(2020, 01, 10), CurveId = 1, Term = 1, Value = -2 }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/curvepoint/{command.Id}", content); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task GivenValidUpdateCurveItemCommand_ReturnsSuccessCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateCurvePointItemCommand { Id = 1, AsOfDate = new DateTime(2020, 01, 10), CurveId = 1, Term = 1, Value = 2 }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/curvepoint/{command.Id}", content); response.EnsureSuccessStatusCode(); }
public async Task Handle_ValidId_ShouldUpdatePersistedCurvePointItem() { var command = new UpdateCurvePointItemCommand { Id = 1, AsOfDate = new DateTime(2019, 01, 20), CurveId = 2, Term = 4, Value = 5 }; var handler = new UpdateCurvePointItemCommand.UpdateCurvePointItemCommandHandler(dbContext, mapper); await handler.Handle(command, CancellationToken.None); var entity = dbContext.CurvePoint.Find(command.Id); Assert.NotNull(entity); Assert.Equal(command.AsOfDate, entity.AsOfDate); Assert.Equal(command.CurveId, entity.CurveId); Assert.Equal(command.Term, entity.Term); Assert.Equal(command.Value, entity.Value); }