Ejemplo n.º 1
0
 static Lifo <State> Bind(Lifo <State> l1, Func <State, Lifo <State> > selector)
 {
     return(l1.IsEmpty          ? l1:
            l1.Value.IsComplete ? MPlus(selector(l1.Value), Bind(l1.Next, selector)):
            new Lifo <State>(new State {
         incomplete = () => Bind(l1.Value.incomplete(), selector)
     }));
 }
Ejemplo n.º 2
0
 static Lifo <State> MPlus(Lifo <State> l1, Lifo <State> l2)
 {
     return(l1.IsEmpty          ? l2:
            l1.Value.IsComplete ? MPlus(l1.Next, l2) & l1.Value:
            new Lifo <State>(new State {
         incomplete = () => MPlus(l2, l1.Value.incomplete())
     }));
 }
        public void LifoTest120SharesSoldSpecifyingDateInMiddleOfTransactions()
        {
            var transaction = new Transaction {
                SharesSold = 120, PricePerShare = 10.5m, Selldate = new DateTime(2005, 2, 3)
            };
            var lifo      = new Lifo();
            var assets    = Assets;
            var costPrice = lifo.CostPriceOfSharesSoldAndSharesRemaining(transaction, assets);

            Assert.AreEqual(1280 / 120.0m, costPrice.CostPriceSold);
        }