Example #1
0
        public void MultiplePurchasesDifferentPurchaser()
        {
            var purchase1 = new Purchase()
            {
                Name      = "Birras",
                Id        = 1,
                Cost      = 100,
                Currency  = Currency.Usd,
                Group     = _group,
                Purchaser = _danny
            };

            purchase1.Participants = new List <Participant>()
            {
                new Participant(_jon, purchase1),
                new Participant(_ghost, purchase1),
                new Participant(_tyrion, purchase1)
            };
            _group.Purchases.Add(purchase1);

            var purchase2 = new Purchase()
            {
                Name      = "Birras",
                Id        = 2,
                Cost      = 100,
                Currency  = Currency.Usd,
                Group     = _group,
                Purchaser = _danny
            };

            purchase2.Participants = new List <Participant>()
            {
                new Participant(_jon, purchase2),
                new Participant(_ghost, purchase2),
                new Participant(_tyrion, purchase2)
            };
            _group.Purchases.Add(purchase2);


            var purchase3 = new Purchase()
            {
                Name      = "OtrasBirras",
                Id        = 3,
                Cost      = 100,
                Currency  = Currency.Usd,
                Group     = _group,
                Purchaser = _jon
            };

            purchase3.Participants = new List <Participant>()
            {
                new Participant(_danny, purchase3),
                new Participant(_ghost, purchase3),
                new Participant(_tyrion, purchase3)
            };
            _group.Purchases.Add(purchase3);

            SplitCostReport report = _group.GenerateSplitCostReport(Currency.Usd);

            Assert.Equal(25d, report[(_jon, _danny)]);
Example #2
0
        public void MultiplePurchasesSamePurchaser()
        {
            var purchase1 = new Purchase()
            {
                Name      = "Birras",
                Id        = 1,
                Cost      = 100,
                Currency  = Currency.Usd,
                Group     = _group,
                Purchaser = _danny
            };

            purchase1.Participants = new List <Participant>()
            {
                new Participant(_jon, purchase1),
                new Participant(_ghost, purchase1),
                new Participant(_tyrion, purchase1)
            };
            _group.Purchases.Add(purchase1);
            var purchase2 = new Purchase()
            {
                Name      = "Birras",
                Id        = 1,
                Cost      = 100,
                Currency  = Currency.Usd,
                Group     = _group,
                Purchaser = _danny
            };

            purchase2.Participants = new List <Participant>()
            {
                new Participant(_jon, purchase2),
                new Participant(_ghost, purchase2),
                new Participant(_tyrion, purchase2)
            };
            _group.Purchases.Add(purchase2);

            SplitCostReport report = _group.GenerateSplitCostReport(Currency.Usd);

            Assert.True(report.Dictionary.All(pair => pair.Key.Item2.Equals(_danny) && Math.Abs(pair.Value - 50) < 0.01d));
        }