Exemplo n.º 1
0
        public async Task CreateGoodsReceivedNoteItemAsync_Returns_New_GetGoodsReceivedNoteItemDto()
        {
            //Arrange
            _fixture.MockGoodsReceivedNoteItemService.Setup(x => x.AddGoodsReceivedNoteItemAsync(It.IsAny <GoodsReceivedNoteItem>()))
            .ReturnsAsync(_fixture.CreatedNewGoodsReceivedNoteItem);

            var repository = new GoodsReceivedNoteItemRepository(AutoMapperSingleton.Mapper, _fixture.MockGoodsReceivedNoteItemService.Object);

            //Act
            var result = await repository.CreateGoodsReceivedNoteItemAsync(_fixture.CreateGoodsReceivedNoteItemDto);

            //Assert
            result.Should().BeOfType(typeof(GetGoodsReceivedNoteItemDto));
            result.Id.Should().Be(5);
            result.ItemTypeName.Should().Be("Grocery");
            result.ItemName.Should().Be("Rice");
            result.ItemUnitPrice.Should().Be(350);
            result.Quantity.Should().Be(5);
        }
Exemplo n.º 2
0
        public async Task CreateGoodsReceivedNoteItemAsync_Throws_ConflictException()
        {
            //Arrange
            _fixture.MockGoodsReceivedNoteItemService.Setup(x => x.GetGoodsReceivedNoteItemAsync(It.IsAny <Expression <Func <GoodsReceivedNoteItem, bool> > >()))
            .Returns <Expression <Func <GoodsReceivedNoteItem, bool> > >(expression => Task.FromResult(_fixture.GoodsReceivedNoteItems.AsQueryable().FirstOrDefault(expression)));

            var repository = new GoodsReceivedNoteItemRepository(AutoMapperSingleton.Mapper, _fixture.MockGoodsReceivedNoteItemService.Object);

            //Act
            var exception = await Assert.ThrowsAsync <RestException>(() => repository.CreateGoodsReceivedNoteItemAsync(new CreateGoodsReceivedNoteItemDto
            {
                GoodsReceivedNoteId = 202,
                ItemId        = 20024,
                ItemUnitPrice = 350,
                Quantity      = 5
            }));

            //Assert
            exception.ErrorCode.Should().Be(HttpStatusCode.Conflict);
            exception.ErrorMessage.Should().Be("Item already available for this goods received note.");
            exception.ErrorType.Should().Be(HttpStatusCode.Conflict.ToString());
        }