Exemplo n.º 1
0
        public async Task UpdateGoodsReceivedNoteItemAsync_Throws_ConflictException()
        {
            //Arrange
            var id = 2;

            _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)));

            _fixture.MockGoodsReceivedNoteItemService.Setup(x => x.UpdateGoodsReceivedNoteItemAsync(It.IsAny <GoodsReceivedNoteItem>()));

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

            //Act
            var exception = await Assert.ThrowsAsync <RestException>(() => repository.UpdateGoodsReceivedNoteItemAsync(id, new EditGoodsReceivedNoteItemDto
            {
                GoodsReceivedNoteId = 202,
                ItemId        = 20024,
                ItemUnitPrice = 260,
                Quantity      = 6
            }));

            //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());
        }
Exemplo n.º 2
0
        public async Task UpdateGoodsReceivedNoteItemAsync_Throws_NotFoundException()
        {
            //Arrange
            var id = 201;

            _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)));

            _fixture.MockGoodsReceivedNoteItemService.Setup(x => x.UpdateGoodsReceivedNoteItemAsync(It.IsAny <GoodsReceivedNoteItem>()));

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

            //Act
            var exception = await Assert.ThrowsAsync <RestException>(() => repository.UpdateGoodsReceivedNoteItemAsync(id, _fixture.EditGoodsReceivedNoteItemDto));

            //Assert
            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound);
            exception.ErrorMessage.Should().Be("Goods received note item not found.");
            exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString());
        }
Exemplo n.º 3
0
        public async Task UpdateGoodsReceivedNoteItemAsync_Returns_Updated_GetGoodsReceivedNoteItemDto()
        {
            //Arrange
            var id = 1;

            _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)));

            _fixture.MockGoodsReceivedNoteItemService.Setup(x => x.UpdateGoodsReceivedNoteItemAsync(It.IsAny <GoodsReceivedNoteItem>()));

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

            //Act
            var result = await repository.UpdateGoodsReceivedNoteItemAsync(id, _fixture.EditGoodsReceivedNoteItemDto);

            //Assert
            result.Should().BeOfType(typeof(GetGoodsReceivedNoteItemDto));
            result.Id.Should().Be(id);
            result.ItemTypeName.Should().Be("Grocery");
            result.ItemName.Should().Be("Rice");
            result.ItemUnitPrice.Should().Be(650);
            result.Quantity.Should().Be(7);
        }