Example #1
0
        public async Task CreateGoodsReceivedNoteFreeItem_Returns_CreatedAtRouteResult()
        {
            //Arrange
            _fixture.MockGoodsReceivedNoteFreeItemRepository.Setup(x => x.CreateGoodsReceivedNoteFreeItemAsync(It.IsAny <CreateGoodsReceivedNoteFreeItemDto>()))
            .ReturnsAsync(_fixture.CreateGoodsReceivedNoteFreeItemDtoResult);

            var controller = new GoodsReceivedNoteFreeItemController(_fixture.MockGoodsReceivedNoteFreeItemRepository.Object);

            //Act
            var result = await controller.CreateGoodsReceivedNoteFreeItem(_fixture.ValidCreateGoodsReceivedNoteFreeItemDto, _fixture.ApiVersion);

            //Assert
            var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject;

            objectResult.StatusCode.Should().Be(201);
            objectResult.RouteValues !["id"].Should().Be(3);
Example #2
0
        public async Task GetGoodsReceivedNoteFreeItems_Returns_OkObjectResult()
        {
            //Arrange
            _fixture.MockGoodsReceivedNoteFreeItemRepository.Setup(x => x.GetGoodsReceivedNoteFreeItemsAsync(It.IsAny <long>()))
            .ReturnsAsync(_fixture.GoodsReceivedNoteFreeItems.Where(d => d.GoodsReceivedNoteId == 202));

            var controller = new GoodsReceivedNoteFreeItemController(_fixture.MockGoodsReceivedNoteFreeItemRepository.Object);

            //Act
            var result = await controller.GetGoodsReceivedNoteFreeItems(202);

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var items    = okResult.Value.Should().BeAssignableTo <IEnumerable <GetGoodsReceivedNoteFreeItemDto> >().Subject;

            okResult.StatusCode.Should().Be(200);
            items.Should().HaveCount(1);
        }
Example #3
0
        public async Task GetGoodsReceivedNoteFreeItem_Returns_OkObjectResult()
        {
            //Arrange
            var id = 2;

            _fixture.MockGoodsReceivedNoteFreeItemRepository.Setup(x => x.GetGoodsReceivedNoteFreeItemAsync(It.IsAny <long>()))
            .ReturnsAsync(_fixture.GoodsReceivedNoteFreeItems.Single(d => d.Id == id));

            var controller = new GoodsReceivedNoteFreeItemController(_fixture.MockGoodsReceivedNoteFreeItemRepository.Object);

            //Act
            var result = await controller.GetGoodsReceivedNoteFreeItem(id);

            //Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var item     = okResult.Value.Should().BeAssignableTo <GetGoodsReceivedNoteFreeItemDto>().Subject;

            okResult.StatusCode.Should().Be(200);
            item.Id.Should().Be(id);
            item.ItemTypeName.Should().Be("Grocery");
            item.ItemName.Should().Be("Salt");
            item.ItemUnit.Should().Be(5);
        }