Esempio 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));
 }
Esempio 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));
 }
Esempio n. 3
0
 private Venture(Name name, Amount outlay)
 {
     this.name = name;
     Outlay = outlay;
     MinInvestment = new Amount(0);
     Subscription = new Subscription();
     holding = new Holding();
 }
Esempio n. 4
0
 //public static readonly string[] STATES = new string[] { PROPOSED_STATE, STARTED_STATE, CANCELLED_STATE, CLOSED_STATE };
 public Venture(Name name, Amount outlay, Amount minInvestment)
 {
     if (minInvestment <= new Amount(0))
         throw new Exception("Minimum investment must be greater than 0");
     if (outlay < minInvestment)
         throw new Exception("Outlay must be greater than minimum investment");
     Name = name;
     Outlay = outlay;
     MinInvestment = minInvestment;
     Subscription = new Subscription();
     State = PROPOSED_STATE;
     holding = new Holding();
 }
Esempio n. 5
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));
 }
Esempio n. 6
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));
        }