public async Task GivenInvalidCurveItem_ReturnsBadRequest() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new CreateCurvePointItemCommand { AsOfDate = new DateTime(2020, 01, 10), CurveId = (byte)2, Term = 1, Value = -2 }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync("/api/curvepoint", content); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task GivenValidCreateCurveItem_ReturnsSuccessStatusCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new CreateCurvePointItemCommand { AsOfDate = new DateTime(2020, 01, 10), CurveId = 1, Term = 1, Value = 2 }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync("api/curvepoint", content); response.EnsureSuccessStatusCode(); }
public async Task Handle_ShouldPersistCurvePointItem() { var command = new CreateCurvePointItemCommand { AsOfDate = new DateTime(2020, 01, 10), CurveId = 1, Term = 1, Value = 2 }; var handler = new CreateCurvePointItemCommand.CreateCurvePointItemCommandHandler(dbContext, mapper); await handler.Handle(command, CancellationToken.None); var entity = dbContext.CurvePoint.Last(); 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); }
public async Task <ActionResult <int> > Create(CreateCurvePointItemCommand command) { return(await Mediator.Send(command)); }