public async Task CreateGoodsReceivedNoteItem_Returns_CreatedAtRouteResult() { //Arrange _fixture.MockGoodsReceivedNoteItemRepository.Setup(x => x.CreateGoodsReceivedNoteItemAsync(It.IsAny <CreateGoodsReceivedNoteItemDto>())) .ReturnsAsync(_fixture.CreateGoodsReceivedNoteItemDtoResult); var controller = new GoodsReceivedNoteItemController(_fixture.MockGoodsReceivedNoteItemRepository.Object); //Act var result = await controller.CreateGoodsReceivedNoteItem(_fixture.ValidCreateGoodsReceivedNoteItemDto, _fixture.ApiVersion); //Assert var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject; objectResult.StatusCode.Should().Be(201); objectResult.RouteValues !["id"].Should().Be(5);
public async Task GetGoodsReceivedNoteItems_Returns_OkObjectResult() { //Arrange _fixture.MockGoodsReceivedNoteItemRepository.Setup(x => x.GetGoodsReceivedNoteItemsAsync(It.IsAny <long>())) .ReturnsAsync(_fixture.GoodsReceivedNoteItems.Where(d => d.GoodsReceivedNoteId == 101)); var controller = new GoodsReceivedNoteItemController(_fixture.MockGoodsReceivedNoteItemRepository.Object); //Act var result = await controller.GetGoodsReceivedNoteItems(101); //Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var items = okResult.Value.Should().BeAssignableTo <IEnumerable <GetGoodsReceivedNoteItemDto> >().Subject; okResult.StatusCode.Should().Be(200); items.Should().HaveCount(2); }
public async Task GetGoodsReceivedNoteItem_Returns_OkObjectResult() { //Arrange var id = 2; _fixture.MockGoodsReceivedNoteItemRepository.Setup(x => x.GetGoodsReceivedNoteItemAsync(It.IsAny <long>())) .ReturnsAsync(_fixture.GoodsReceivedNoteItems.Single(d => d.Id == id)); var controller = new GoodsReceivedNoteItemController(_fixture.MockGoodsReceivedNoteItemRepository.Object); //Act var result = await controller.GetGoodsReceivedNoteItem(id); //Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var item = okResult.Value.Should().BeAssignableTo <GetGoodsReceivedNoteItemDto>().Subject; okResult.StatusCode.Should().Be(200); item.Id.Should().Be(id); item.ItemTypeName.Should().Be("Grocery"); item.ItemName.Should().Be("Chilli Powder"); item.ItemUnit.Should().Be(250); }