Пример #1
0
        public void GetTransactionByType_BoughtType_ReturnsBoughtType()
        {
            TransactionLibrary library      = new TransactionLibrary();
            List <Transaction> transactions = new List <Transaction>();

            transactions.Add(new Transaction()
            {
                Id             = 1,
                ProductHistory = new List <ProductHistory>()
                {
                    new ProductHistory()
                    {
                        Price = 1
                    },
                    new ProductHistory()
                    {
                        Price = 2
                    }
                },
                TransactionType = TransactionType.Sold
            });
            transactions.Add(new Transaction()
            {
                Id             = 2,
                ProductHistory = new List <ProductHistory>()
                {
                    new ProductHistory()
                    {
                        Price = 2.50
                    }
                },

                TransactionType = TransactionType.Bought
            });

            var result = library.GetTransactionsByType(new EnumerableQuery <Transaction>(transactions), TransactionType.Bought);

            Assert.IsTrue(result.All(t => t.ProductHistory.Count == 1));
            Assert.IsTrue(result.All(t => t.Id == 2));
        }