예제 #1
0
        public async Task CheckCommentCorrectnessIfPayingItemCommentIsEmpty()
        {
            var payingItemModel = CreatePayingItemModel();
            var target          = new PayingItemCreator(_payingItemService.Object);

            await target.CreatePayingItemFromViewModel(payingItemModel);

            Assert.AreEqual("Product_1, Product_2, Product_3", payingItemModel.PayingItem.Comment);
        }
예제 #2
0
        public async Task CheckPayingItemSumCorrectnessIfProductsNotNull()
        {
            var payingItemModel = CreatePayingItemModel();
            var target          = new PayingItemCreator(_payingItemService.Object);

            await target.CreatePayingItemFromViewModel(payingItemModel);

            Assert.AreEqual(payingItemModel.Products.Sum(x => x.Price), payingItemModel.PayingItem.Summ);
        }
예제 #3
0
        public async Task ThrowsWebUiExceptionWithInnerServiceException()
        {
            _payingItemService.Setup(x => x.CreateAsync(It.IsAny <PayingItem>())).ThrowsAsync(new ServiceException());
            var target          = new PayingItemCreator(_payingItemService.Object);
            var payingItemModel = CreatePayingItemModel();

            try
            {
                await target.CreatePayingItemFromViewModel(payingItemModel);
            }
            catch (WebUiException ex)
            {
                Assert.IsInstanceOfType(ex.InnerException, typeof(ServiceException));
            }
        }
예제 #4
0
        public async Task CheckForCorrectPayingItemDate()
        {
            var payingItemModel = new PayingItemModel()
            {
                PayingItem = new PayingItem()
                {
                    Date = DateTime.Today.AddMonths(1)
                },
                Products = null
            };
            var target = new PayingItemCreator(_payingItemService.Object);

            await target.CreatePayingItemFromViewModel(payingItemModel);

            Assert.AreEqual(DateTime.Today.Date, payingItemModel.PayingItem.Date);
        }
예제 #5
0
        public async Task CheckIfPayingItemProductsAreAddedCorrectly()
        {
            var payingItemModel = new PayingItemModel()
            {
                PayingItem = new PayingItem()
                {
                    Date = DateTime.Today
                },
                Products = new List <Product>()
                {
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductName = "Product_1",
                        ProductID   = 1,
                        Price       = 100
                    },
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductID   = 2,
                        ProductName = "Product_2",
                        Price       = 100
                    },
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductID   = 0,
                        ProductName = "Product_3",
                        Price       = 100
                    }
                }
            };
            var target = new PayingItemCreator(_payingItemService.Object);

            await target.CreatePayingItemFromViewModel(payingItemModel);

            // PayingItem.PayingItemProducts  must include only those PayingTemModel.Products where ProductId != 0
            Assert.AreEqual(2, payingItemModel.PayingItem.PayingItemProducts.Count);
        }
예제 #6
0
        public async Task CheckCommentCorrectnessIfPayingItemCommentIsNotEmpty()
        {
            var payingItemModel = new PayingItemModel()
            {
                PayingItem = new PayingItem()
                {
                    Date    = DateTime.Today,
                    Comment = "PayingItemComment"
                },
                Products = new List <Product>()
                {
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductName = "Product_1",
                        ProductID   = 1,
                        Price       = 100
                    },
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductID   = 2,
                        ProductName = "Product_2",
                        Price       = 100
                    },
                    new Product()
                    {
                        CategoryID  = 1,
                        ProductID   = 3,
                        ProductName = "Product_3",
                        Price       = 100
                    }
                }
            };
            var target = new PayingItemCreator(_payingItemService.Object);

            await target.CreatePayingItemFromViewModel(payingItemModel);

            Assert.AreEqual("PayingItemComment", payingItemModel.PayingItem.Comment);
        }
예제 #7
0
 public async Task CreatePayingItem_Throws_ArgumentNullException()
 {
     var target = new PayingItemCreator(null);
     await target.CreatePayingItemFromViewModel(null);
 }