Ejemplo n.º 1
0
        public async Task GivenInvalidCreateSaleItemCommand_ReturnsBadRequest()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            var command = new CreateSaleItemCommand
            {
                ArticleNumber    = "This description of this thing will exceed the maximum length. This description of this thing will exceed the maximum length. This description of this thing will exceed the maximum length. This description of this thing will exceed the maximum length.",
                SalesPriceInEuro = 139.66m
            };

            var content = IntegrationTestHelper.GetRequestContent(command);

            var response = await client.PostAsync($"/api/saleitems", content);

            response.StatusCode.ShouldBe(HttpStatusCode.BadRequest);
        }
Ejemplo n.º 2
0
        public async Task GivenValidCreateSaleItemCommand_ReturnsSuccessCode()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            var command = new CreateSaleItemCommand
            {
                ArticleNumber    = "GMzECR1jyuVOk32pekQeOZsYfMcukhfV",
                SalesPriceInEuro = 18.99m
            };

            var content = IntegrationTestHelper.GetRequestContent(command);

            var response = await client.PostAsync($"/api/saleitems", content);

            response.EnsureSuccessStatusCode();
        }
Ejemplo n.º 3
0
        public async Task Handle_ShouldPersistSaleItem()
        {
            var command = new CreateSaleItemCommand
            {
                ArticleNumber    = ArticleNumber,
                SalesPriceInEuro = SalesPriceInEuro,
                DateTimeOffset   = DateTimeOffset.Now.AddDays(-3)
            };

            var handler = new CreateSaleItemCommand.CreateSaleItemCommandHandler(_context, _mapper);

            var result = await handler.Handle(command);

            var entity = _context.SaleItems.Find(result.id);

            entity.ShouldNotBeNull();
            entity.ArticleItem.ArticleNumber.ShouldBe(command.ArticleNumber);
            entity.SalesPriceInEuro.ShouldBe(command.SalesPriceInEuro);
        }
 public async Task <ActionResult <SaleItemDto> > Create(CreateSaleItemCommand command)
 {
     return(await Mediator.Send(command));
 }