Example #1
0
        public async Task GetGoodsReceivedNoteItemAsync_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)));

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

            //Act
            var exception = await Assert.ThrowsAsync <RestException>(() => repository.GetGoodsReceivedNoteItemAsync(id));

            //Assert
            exception.ErrorCode.Should().Be(HttpStatusCode.NotFound);
            exception.ErrorMessage.Should().Be("Goods received note item not found.");
            exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString());
        }
Example #2
0
        public async Task GetGoodsReceivedNoteItemAsync_Returns_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)));

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

            //Act
            var result = await repository.GetGoodsReceivedNoteItemAsync(id);

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