public async Task PayingItemContainsProducts_CategoryContainsNoFreeProducts()
        {
            var payingItem = new PayingItem()
            {
                Category = new Category()
                {
                    Products = new List <Product>()
                },
                PayingItemProducts = new List <PayingItemProduct>()
                {
                    new PayingItemProduct()
                    {
                        Product = new Product()
                        {
                            ProductName = "P1"
                        }
                    },
                    new PayingItemProduct()
                    {
                        Product = new Product()
                        {
                            ProductName = "P2"
                        }
                    }
                }
            };

            _payingItemServiceMock.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(payingItem);
            var target = new PayingItemEditViewModelCreator(_payingItemServiceMock.Object);

            var result = await target.CreateViewModel(1);

            Assert.AreEqual(2, result.ProductsInItem.Count);
            Assert.AreEqual(0, result.ProductsNotInItem.Count);
        }
        public async Task PayingItemIsNull_ReturnsNullViewModel()
        {
            PayingItem payingItem = null;

            _payingItemServiceMock.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(payingItem);
            var target = new PayingItemEditViewModelCreator(_payingItemServiceMock.Object);

            var result = await target.CreateViewModel(It.IsAny <int>());

            Assert.AreEqual(null, result);
        }
        public async Task ThrowsWebUiExceptionWithInneException()
        {
            _payingItemServiceMock.Setup(x => x.GetItemAsync(It.IsAny <int>())).Throws <ServiceException>();
            var target = new PayingItemEditViewModelCreator(_payingItemServiceMock.Object);

            try
            {
                var result = await target.CreateViewModel(It.IsAny <int>());
            }
            catch (WebUiException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(Exception));
            }
        }
        public async Task PayingItemContainsAllProductsFromCategory()
        {
            var payingItem = new PayingItem()
            {
                Category = new Category()
                {
                    Products = _products
                },
                PayingItemProducts = new List <PayingItemProduct>()
                {
                    new PayingItemProduct()
                    {
                        Product = _products[0]
                    },
                    new PayingItemProduct()
                    {
                        Product = _products[1]
                    },
                    new PayingItemProduct()
                    {
                        Product = _products[2]
                    },
                    new PayingItemProduct()
                    {
                        Product = _products[3]
                    }
                }
            };

            _payingItemServiceMock.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(payingItem);
            var target = new PayingItemEditViewModelCreator(_payingItemServiceMock.Object);

            var result = await target.CreateViewModel(1);

            Assert.AreEqual(4, result.ProductsInItem.Count);
            Assert.AreEqual(0, result.ProductsNotInItem.Count);
        }