Example #1
0
        public async Task GivenInvalidCreateBidItem_ReturnsBadRequest()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            var command = new CreateBidItemCommand
            {
                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.PostAsync("/api/bid", content);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Example #2
0
        public async Task GivenValidCreateBidItem_ReturnsSuccessStatusCode()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            var command = new CreateBidItemCommand
            {
                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.PostAsync("/api/bid", content);

            response.EnsureSuccessStatusCode();
        }
        public async Task Handle_ShouldPersistBidItem()
        {
            var command = new CreateBidItemCommand
            {
                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 handler = new CreateBidItemCommand.CreateBidItemCommandHandler(dbContext, mapper);

            await handler.Handle(command, CancellationToken.None);

            var entity = dbContext.BidList.Last();

            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);
        }
 public async Task <ActionResult <int> > Create(CreateBidItemCommand command)
 {
     return(await Mediator.Send(command));
 }