示例#1
0
        public void Should_ReturnASuccessResponse_When_InputParametersAreValid()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.AddItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", itemDto);



            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeTrue(),
                () => result.ErrorMessage.Should().BeNull()
                );
        }
示例#2
0
        public void Should_ReturnAnErrorResponse_When_ItemRepositoryThrowsAnException()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges())
            .Throws(new Exception());


            //Act
            var result = ItemsDataService.AddItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", itemDto);


            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("An error occurred while creating item")
                );
        }
示例#3
0
        public void Should_AddItem_When_InputParametersAreValid()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.AddItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", itemDto);


            //Assert
            AssertHelper.AssertAll(
                () => saveObject.Id.Should().Be(0),
                () => saveObject.Name.Should().Be("Bread"),
                () => saveObject.NextReplenishmentDate.Should().BeSameDateAs(new DateTime(2020, 10, 06)),
                () => saveObject.ReplenishmentPeriod.Should().Be(1)
                );
        }
示例#4
0
        public void Should_CheckForUserIdEmptyBeforeOtherMethodCalls_When_UserIdIsEmptyString()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.AddItem(string.Empty, itemDto);


            //Assert
            AssertHelper.AssertAll(
                () => MapperMock.Verify(x => x.Map <ItemDto, Item>(It.IsAny <ItemDto>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.Add(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#5
0
        public void Should_ReturnErrorResponse_When_NoItemsExist()
        {
            //Arrange
            var allItems = new List <Item>().AsQueryable();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var filteredItems    = new List <Item>();
            var filteredItemDtos = new List <ItemDto>();

            MapperMock
            .Setup(c => c.ProjectTo(
                       It.Is <IQueryable <Item> >(x => ItemsTestHelper.HaveTheSameElements(filteredItems, x)),
                       null,
                       It.Is <Expression <Func <ItemDto, object> >[]>(x => x.Length == 0)))
            .Returns(filteredItemDtos.AsQueryable());


            //Act
            var result = ItemsDataService.GetItem(2, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => result.Data.Should().BeNull(),
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("Current user does not have item with id 2")
                );
        }
示例#6
0
        public void Should_CheckForItemDtoNullBeforeAllOtherMethodCalls_When_ItemDtoIsNull()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());

            var updatedItemDto = new ItemDto()
            {
                Id   = 1,
                Name = "Bread updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };

            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", null);


            //Assert
            AssertHelper.AssertAll(
                () => ItemsRepositoryMock.Verify(x => x.All(), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.Update(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#7
0
        public void Should_ReturnErrorResponse_When_CurrentUserDoesNotHaveItemWithThisId()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var deleteObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()))
            .Callback <Item>((obj) => deleteObject = obj);

            ItemsRepositoryMock.Setup(x => x.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(5, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => response.IsSuccess.Should().BeFalse(),
                () => response.ErrorMessage.Should().Be("Current user does not have item with id 5")
                );
        }
示例#8
0
        public void Should_CallDeletemethodWithCorrectItem_When_InputParametersAreValid()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var deleteObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()))
            .Callback <Item>((obj) => deleteObject = obj);

            ItemsRepositoryMock.Setup(x => x.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(1, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => deleteObject.Id.Should().Be(1),
                () => deleteObject.Name.Should().Be("Bread"),
                () => deleteObject.NextReplenishmentDate.Should().BeSameDateAs(new DateTime(2020, 10, 06)),
                () => deleteObject.ReplenishmentPeriod.Should().Be(1),
                () => deleteObject.UserId.Should().Be("ab70793b-cec8-4eba-99f3-cbad0b1649d0")
                );
        }
示例#9
0
        public void Should_NotUpdateAnyItemInTheDb_When_AnotherUserHasThisItem()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());

            var updatedItemDto = new ItemDto()
            {
                Id   = 5,
                Name = "Cake updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };


            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto);


            //Assert
            AssertHelper.AssertAll(
                () => ItemsRepositoryMock.Verify(x => x.All(), Times.Once()),
                () => ItemsRepositoryMock.Verify(x => x.Update(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#10
0
        public void Should_ReturnErrorResponse_When_UserIdIsNull()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var deleteObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()))
            .Callback <Item>((obj) => deleteObject = obj);

            ItemsRepositoryMock.Setup(x => x.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(1, null);


            //Assert
            AssertHelper.AssertAll(
                () => response.IsSuccess.Should().BeFalse(),
                () => response.ErrorMessage.Should().Be("An error occurred while deleting item")
                );
        }
示例#11
0
        public void Should_NotDeleteAnyItem_When_UserIdIsNull()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var deleteObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()))
            .Callback <Item>((obj) => deleteObject = obj);

            ItemsRepositoryMock.Setup(x => x.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(1, null);


            //Assert
            AssertHelper.AssertAll(
                () => ItemsRepositoryMock.Verify(x => x.Delete(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#12
0
        public void Should_NotDeleteAnyItem_When_CurrentUserDoesNotHaveItemWithThisId()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var deleteObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()))
            .Callback <Item>((obj) => deleteObject = obj);

            ItemsRepositoryMock.Setup(x => x.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(5, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => ItemsRepositoryMock.Verify(x => x.Delete(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#13
0
        public void Should_ReturnErrorResponse_When_RepositorySaveChangesThrowsAnException()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges()).Throws(new Exception());

            var updatedItemDto = new ItemDto()
            {
                Id   = 1,
                Name = "Bread updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };


            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto);


            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("An error occurred while updating item")
                );
        }
示例#14
0
        public void Should_CallRepositorySaveChangesAfterUpdateMethod_When_InputParametersAreValid()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var updatedItemDto = new ItemDto()
            {
                Id   = 1,
                Name = "Bread updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };


            var sequence = new MockSequence();

            ItemsRepositoryMock
            .InSequence(sequence)
            .Setup(c => c.Update(It.Is <Item>(x =>
                                              x.HasTheSameProperties("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto))));

            ItemsRepositoryMock.InSequence(sequence).Setup(x => x.SaveChanges());

            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto);

            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeTrue(),
                () => result.ErrorMessage.Should().BeNull()
                );
        }
示例#15
0
        public void Should_ReturnErrorResponse_When_AnotherUserHasThisItem()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());

            var updatedItemDto = new ItemDto()
            {
                Id   = 5,
                Name = "Cake updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };


            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto);


            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("Current user does not have item with id 5")
                );
        }
示例#16
0
        public void Should_ReturnAnErrorResponse_When_UserIdIsEmptyString()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.AddItem(string.Empty, itemDto);


            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("An error occurred while creating item")
                );
        }
示例#17
0
        public void Should_ReturnErrorResponse_When_CurrentUserDoesNotHaveItemWithThisId()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var filteredItems    = new List <Item>();
            var filteredItemDtos = new List <ItemDto>();

            MapperMock
            .Setup(c => c.ProjectTo(
                       It.Is <IQueryable <Item> >(x => ItemsTestHelper.HaveTheSameElements(filteredItems, x)),
                       null,
                       It.Is <Expression <Func <ItemDto, object> >[]>(x => x.Length == 0)))
            .Returns(filteredItemDtos.AsQueryable());


            //Act
            var result = ItemsDataService.GetItem(2, "925912b0-c59c-4e1b-971a-06e8abab7848");


            //Assert
            AssertHelper.AssertAll(
                () => result.Data.Should().BeNull(),
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("Current user does not have item with id 2")
                );
        }
示例#18
0
        public void Should_CheckForUserIdEmptyBeforeAllOtherMethodCalls_When_UserIdIsEmpty()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());

            var updatedItemDto = new ItemDto()
            {
                Id   = 1,
                Name = "Bread updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };

            //Act
            var result = ItemsDataService.UpdateItem(string.Empty, updatedItemDto);


            //Assert
            AssertHelper.AssertAll(
                () => ItemsRepositoryMock.Verify(x => x.All(), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.Update(It.IsAny <Item>()), Times.Never()),
                () => ItemsRepositoryMock.Verify(x => x.SaveChanges(), Times.Never())
                );
        }
示例#19
0
        public void Should_UpdateItem_When_InputParametersAreValid()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());

            var updatedItemDto = new ItemDto()
            {
                Id   = 1,
                Name = "Bread updated",
                NextReplenishmentDate = new DateTime(2020, 10, 10),
                ReplenishmentPeriod   = 4
            };


            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", updatedItemDto);


            //Assert
            AssertHelper.AssertAll(
                () => saveObject.Id.Should().Be(1),
                () => saveObject.Name.Should().Be("Bread updated"),
                () => saveObject.NextReplenishmentDate.Should().BeSameDateAs(new DateTime(2020, 10, 10)),
                () => saveObject.ReplenishmentPeriod.Should().Be(4)
                );
        }
        protected void InitializeMocksWithEmptyCollection()
        {
            var allItems = new List <Item>().AsQueryable();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var filteredItems        = new List <Item>();
            var filteredItemNameDtos = new List <ItemNameDto>();

            MapperMock
            .Setup(c => c.ProjectTo(
                       It.Is <IQueryable <Item> >(x => ItemsTestHelper.HaveTheSameElements(filteredItems, x)),
                       null,
                       It.Is <Expression <Func <ItemNameDto, object> >[]>(x => x.Length == 0)))
            .Returns(filteredItemNameDtos.AsQueryable());
        }
示例#21
0
        public void Should_ReturnSuccessResponse_When_InputParametersAreValid()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Delete(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var response = ItemsDataService.DeleteItem(1, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => response.IsSuccess.Should().BeTrue(),
                () => response.ErrorMessage.Should().BeNull()
                );
        }
示例#22
0
        public void Should_ReturnErrorResponse_When_ItemDtoIsNull()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            ItemsRepositoryMock.Setup(c => c.Update(It.IsAny <Item>()));
            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.UpdateItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", null);


            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeFalse(),
                () => result.ErrorMessage.Should().Be("An error occurred while updating item")
                );
        }
示例#23
0
        public void Should_ReturnResponseWithCorrectItem_When_CurrentUserHasItemWithThisId()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var filteredItem  = BuildSecondItem();
            var filteredItems = new List <Item>()
            {
                filteredItem
            };

            var filteredItemDto  = BuildSecondItemDto();
            var filteredItemDtos = new List <ItemDto>()
            {
                filteredItemDto
            };

            MapperMock
            .Setup(c => c.ProjectTo(
                       It.Is <IQueryable <Item> >(x => ItemsTestHelper.HaveTheSameElements(filteredItems, x)),
                       null,
                       It.Is <Expression <Func <ItemDto, object> >[]>(x => x.Length == 0)))
            .Returns(filteredItemDtos.AsQueryable());


            //Act
            var result = ItemsDataService.GetItem(2, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => result.Data.Id.Should().Be(2),
                () => result.Data.Name.Should().Be("Cheese"),
                () => result.Data.NextReplenishmentDate.Should().BeSameDateAs(new DateTime(2020, 10, 08)),
                () => result.Data.ReplenishmentPeriod.Should().Be(2)
                );
        }
示例#24
0
        public void Should_ReturnSuccessResponseWithItem_When_CurrentUserHasItemWithThisId()
        {
            //Arrange
            var allItems = BuildItemsCollection();

            ItemsRepositoryMock.Setup(x => x.All()).Returns(allItems);

            var filteredItem  = BuildSecondItem();
            var filteredItems = new List <Item>()
            {
                filteredItem
            };

            var filteredItemDto  = BuildSecondItemDto();
            var filteredItemDtos = new List <ItemDto>()
            {
                filteredItemDto
            };

            MapperMock
            .Setup(c => c.ProjectTo(
                       It.Is <IQueryable <Item> >(x => ItemsTestHelper.HaveTheSameElements(filteredItems, x)),
                       null,
                       It.Is <Expression <Func <ItemDto, object> >[]>(x => x.Length == 0)))
            .Returns(filteredItemDtos.AsQueryable());


            //Act
            var result = ItemsDataService.GetItem(2, "ab70793b-cec8-4eba-99f3-cbad0b1649d0");


            //Assert
            AssertHelper.AssertAll(
                () => result.Data.Should().NotBeNull(),
                () => result.IsSuccess.Should().BeTrue(),
                () => result.ErrorMessage.Should().BeNull()
                );
        }
示例#25
0
        public void Should_FirstAddItemThenCallSaveChanges_When_InputParametersAreValid()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);


            var sequence = new MockSequence();

            ItemsRepositoryMock.InSequence(sequence).Setup(x => x.Add(item));
            ItemsRepositoryMock.InSequence(sequence).Setup(x => x.SaveChanges());

            //Act
            var result = ItemsDataService.AddItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", itemDto);

            //Assert
            AssertHelper.AssertAll(
                () => result.IsSuccess.Should().BeTrue(),
                () => result.ErrorMessage.Should().BeNull()
                );
        }
示例#26
0
        public void Should_AddItemOnce_When_InputParametersAreValid()
        {
            //Arrange
            var itemDto = BuildFirstItemDtoWithoutId();
            var item    = BuildFirstItemWithoutId();

            MapperMock.Setup(c => c.Map <ItemDto, Item>(itemDto))
            .Returns(item);

            var saveObject = new Item();

            ItemsRepositoryMock.Setup(c => c.Add(It.IsAny <Item>()))
            .Callback <Item>((obj) => saveObject = obj);

            ItemsRepositoryMock.Setup(c => c.SaveChanges());


            //Act
            var result = ItemsDataService.AddItem("ab70793b-cec8-4eba-99f3-cbad0b1649d0", itemDto);


            //Assert
            ItemsRepositoryMock.Verify(c => c.Add(item), Times.Once());
        }