public async Task GivenInvalidUpdateBidItemCommand_ReturnsBadRequest() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateBidItemCommand { BidListId = 1, Account = "This String Will Exceed The Maximum Lenght.", Ask = 1, AskQuantity = 2, Benchmark = "Benchmark", Bid = 3, BidListDate = new DateTime(2020, 01, 09), BidQuantity = 4, Book = "Book", Commentary = "Commentary", DealName = "DealName", DealType = "DealType", Security = "Security", Side = "Side", SourceListId = "SourceListId", Status = "Status", Trader = "Trader", Type = "Type" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/bid/{command.BidListId}", content); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task GivenValidUpdateBidItemCommand_ReturnsSuccessStatusCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateBidItemCommand { BidListId = 1, Account = "Account", Ask = 1, AskQuantity = 2, Benchmark = "Benchmark", Bid = 3, BidListDate = new DateTime(2020, 01, 09), BidQuantity = 4, Book = "Book", Commentary = "Commentary", DealName = "DealName", DealType = "DealType", Security = "Security", Side = "Side", SourceListId = "SourceListId", Status = "Status", Trader = "Trader", Type = "Type" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/bid/{command.BidListId}", content); response.EnsureSuccessStatusCode(); }
public async Task Handle_InvalidId_ThrowsException() { var command = new UpdateBidItemCommand { BidListId = 34, Account = "Accounts", Ask = 2, AskQuantity = 3, Benchmark = "Benchmarks", Bid = 4, BidListDate = new DateTime(2020, 01, 10), BidQuantity = 5, Book = "Books", Commentary = "Commentarys", DealName = "DealNames", DealType = "DealTypes", Security = "Securitys", Side = "Sides", SourceListId = "SourceListIds", Status = "Statuss", Trader = "Traders", Type = "Types" }; var handler = new UpdateBidItemCommand.UpdateBidItemCommandHandler(dbContext, mapper); await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public async Task <ActionResult> Update(int id, UpdateBidItemCommand command) { if (id != command.BidListId) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task Hande_ValidId_ShouldUpdatePersistedBidItem() { var command = new UpdateBidItemCommand { BidListId = 1, Account = "Accounts", Ask = 2, AskQuantity = 3, Benchmark = "Benchmarks", Bid = 4, BidListDate = new DateTime(2020, 01, 10), BidQuantity = 5, Book = "Books", Commentary = "Commentarys", DealName = "DealNames", DealType = "DealTypes", Security = "Securitys", Side = "Sides", SourceListId = "SourceListIds", Status = "Statuss", Trader = "Traders", Type = "Types" }; var handler = new UpdateBidItemCommand.UpdateBidItemCommandHandler(dbContext, mapper); await handler.Handle(command, CancellationToken.None); var entity = dbContext.BidList.Find(command.BidListId); Assert.NotNull(entity); Assert.Equal(command.Account, entity.Account); Assert.Equal(command.Ask, entity.Ask); Assert.Equal(command.AskQuantity, entity.AskQuantity); Assert.Equal(command.Benchmark, entity.Benchmark); Assert.Equal(command.Bid, entity.Bid); Assert.Equal(command.BidListDate, entity.BidListDate); Assert.Equal(command.BidQuantity, entity.BidQuantity); Assert.Equal(command.Book, entity.Book); Assert.Equal(command.Commentary, entity.Commentary); Assert.Equal(command.DealName, entity.DealName); Assert.Equal(command.DealType, entity.DealType); Assert.Equal(command.Security, entity.Security); Assert.Equal(command.Side, entity.Side); Assert.Equal(command.SourceListId, entity.SourceListId); Assert.Equal(command.Status, entity.Status); Assert.Equal(command.Trader, entity.Trader); Assert.Equal(command.Type, entity.Type); }