Ejemplo n.º 1
0
        public ActionResult History(int id)
        {
            var transactions = _transactionDao.GetTransactionsByBatchId(id);

            var supplyChain = SupplyChainFactory.Make(transactions);

            var model = new HistoryView
            {
                BatchId     = id,
                SupplyChain = supplyChain
            };

            return(View("History", model));
        }
Ejemplo n.º 2
0
        public void ShouldOrderTheTransactionsByDate()
        {
            var transactions = new List <Transaction>
            {
                new Transaction {
                    OrderTime = new DateTime(2002, 1, 1), FromOwner = "test2", ToOwner = "test3"
                },
                new Transaction {
                    OrderTime = new DateTime(2001, 1, 1), FromOwner = "test2", ToOwner = "test3"
                },
                new Transaction {
                    OrderTime = new DateTime(2000, 1, 1), FromOwner = "test1", ToOwner = "test2"
                }
            };


            var chain = SupplyChainFactory.Make(transactions);

            Assert.AreEqual(2001, chain.Children[0].Transaction.OrderTime.Year);
        }
Ejemplo n.º 3
0
        public void ShouldHaveTheCorrectChildren()
        {
            var transactions = new List <Transaction>
            {
                new Transaction {
                    OrderTime = new DateTime(2000, 1, 1), FromOwner = "test1", ToOwner = "test2"
                },
                new Transaction {
                    OrderTime = new DateTime(2001, 1, 1), FromOwner = "test2", ToOwner = "test3"
                },
                new Transaction {
                    OrderTime = new DateTime(2002, 1, 1), FromOwner = "test3", ToOwner = "test4"
                }
            };


            var chain = SupplyChainFactory.Make(transactions);

            Assert.AreEqual("test1", chain.Transaction.FromOwner);
            Assert.AreEqual("test2", chain.Children[0].Transaction.FromOwner);
            Assert.AreEqual("test3", chain.Children[0].Children[0].Transaction.FromOwner);
        }