Add() public method

public Add ( Offer investment ) : void
investment Offer
return void
Ejemplo n.º 1
0
 public void ShouldBeAbleToTellIfInvestorAlreadyInvested()
 {
     var investor = new Investor(new Name("investor"), new Amount(50000));
     var subscription = new Subscription();
     subscription.Add(new Offer(investor, new Amount(500), null));
     Assert.IsTrue(subscription.AlreadyInvested(investor));
 }
Ejemplo n.º 2
0
 public void Should_Be_Able_To_Tell_If_Investor_Already_Invested()
 {
     Investor investor = new Investor(new Name("investor"), new GringottsDate(DateTime.Now), new Amount(50000));
     Venture venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1));
     Subscription subscription = new Subscription();
     subscription.Add(new Offer(investor, new Amount(500), null));
     Assert.IsTrue(subscription.AlreadyInvested(investor));
 }
Ejemplo n.º 3
0
 public void Should_Be_Able_To_Confirm_Subscription()
 {
     Subscription subscription = new Subscription();
     Investor investor0 = new Investor(new Name("Investor0"), new GringottsDate(DateTime.Now), new Amount(100));
     Investor investor1 = new Investor(new Name("Investor1"), new GringottsDate(DateTime.Now), new Amount(100));
     Investor investor2 = new Investor(new Name("Investor2"), new GringottsDate(DateTime.Now), new Amount(100));
     Investor investor3 = new Investor(new Name("Investor3"), new GringottsDate(DateTime.Now), new Amount(100));
     subscription.Add(new Offer(investor0, new Amount(100), null));
     subscription.Add(new Offer(investor1, new Amount(200), null));
     subscription.Add(new Offer(investor2, new Amount(300), null));
     Offer excess = new Offer(investor3, new Amount(400), null);
     subscription.Add(excess);
     Amount outlay = new Amount(600);
     List<Investment> confirmations = subscription.Confirm(outlay);
     Assert.IsFalse(confirmations.Contains(excess.ToInvestment()));
     Assert.AreEqual(outlay, confirmations.Aggregate(new Amount(0), (sum, inv) => sum + inv.Value));
 }
Ejemplo n.º 4
0
        public void SubscriptionConfirmationAcceptsJustTheMinimumSetOfOffers()
        {
            // venture used here just to create the offer. not for adding offers
            var dummyVenture = new Venture(new Name("Ventura"), new Amount(1), new Amount(1));

            var subscription = new Subscription();

            var investor0 = new Investor(new Name("Investor0"),  new Amount(100));
            var investor1 = new Investor(new Name("Investor1"),  new Amount(100));
            var investor2 = new Investor(new Name("Investor2"),  new Amount(100));
            var investor3 = new Investor(new Name("Investor3"),  new Amount(100));

            subscription.Add(new Offer(investor0, new Amount(100), dummyVenture));
            subscription.Add(new Offer(investor1, new Amount(200), dummyVenture));
            subscription.Add(new Offer(investor2, new Amount(300), dummyVenture));
            var excess = new Offer(investor3, new Amount(400), dummyVenture);
            subscription.Add(excess);

            var outlay = new Amount(600);
            List<Investment> confirmations = subscription.Confirm(outlay);
            Assert.IsFalse(confirmations.Contains(excess.ToInvestment()));
            Assert.AreEqual(outlay, confirmations.Aggregate(new Amount(0), (sum, inv) => sum + inv.Value));
        }