public void Should_Add_New_Items()
        {
            var itemGet = new Item {
                Id = 1, Description = "MyItem1"
            };

            var resuattItems = new[]
            {
                new ParseResultItem {
                    Description = "MyItem1", Price = 10, Code = "1"
                },
                new ParseResultItem {
                    Description = "MyItem2", Price = 10, Code = "2"
                },
                new ParseResultItem {
                    Description = "MyItem3", Price = 10, Code = "3"
                },
            };

            var parsingConfiguration = new ParsingConfiguration
            {
                Path        = "https://www.citrus.ua/bluetooth-garnitury/",
                Stategy     = ParseStategyEnum.CitrusParserStategy,
                AmountItems = 10
            };

            var parserMock = new Mock <Parser>();

            parserMock.Setup(u => u.GetAllItems(parsingConfiguration.Path, parsingConfiguration.AmountItems)).Returns(resuattItems);

            var repositoryMock      = new Mock <IRepository <Item> >(MockBehavior.Default);
            var repositorypriseMock = new Mock <IRepository <Price> >(MockBehavior.Default);

            var unitOfWorkMock = new Mock <IUnitOfWork>();

            unitOfWorkMock.Setup(u => u.Items).Returns(() => repositoryMock.Object);
            unitOfWorkMock.Setup(u => u.Prices).Returns(() => repositorypriseMock.Object);

            var mappingProfile = new MappingProfile();
            var config         = new MapperConfiguration(mappingProfile);
            var mapper         = new Mapper(config);

            var service = new ItemService(unitOfWorkMock.Object, parserMock.Object, mapper);

            service.AddItems(parsingConfiguration);

            repositoryMock.Verify(m => m.Create(It.Is <Item>(t => t.Code == resuattItems[0].Code)));
            repositoryMock.Verify(m => m.Create(It.Is <Item>(t => t.Code == resuattItems[1].Code)));
            repositoryMock.Verify(m => m.Create(It.Is <Item>(t => t.Code == resuattItems[2].Code)));

            unitOfWorkMock.Verify(m => m.Save());
        }
 public IHttpActionResult PostItems(ICollection <ItemDto> items)
 {
     try {
         if (items == null)
         {
             return(Content(HttpStatusCode.BadRequest, "Cannot post null"));
         }
         _itemService.AddItems(items);
         return(Ok());
     } catch (Exception e) {
         return(Content(HttpStatusCode.InternalServerError, e.Message));
     }
 }