Exemplo n.º 1
0
 private Venture(Name name, Amount outlay)
 {
     this.name = name;
     Outlay = outlay;
     MinInvestment = new Amount(0);
     Subscription = new Subscription();
     holding = new Holding();
 }
Exemplo n.º 2
0
 public void ShouldCreateTwoVenturesOnSplit()
 {
     var venture = new Venture(new Name("venture-name"), new Amount(100), new Amount(10));
     var firstVentureName = new Name("new-venture-1");
     var secondVentureName = new Name("new-venture-2");
     var terms = new TermsOfSplit(new Percentage(0.8f), firstVentureName, secondVentureName);
     venture.AddOffer(new Investor(new Name("testName"), new Amount(1000)), new Amount(100));
     venture.Start();
     var ventures = venture.Split(terms);
     Assert.AreEqual(2, ventures.Count());
 }
Exemplo n.º 3
0
 public void ShouldBeAbleToCreateAVenture()
 {
     var nameOfVenture = new Name("Ventura");
     var outlay = new Amount(100);
     var minInvestment = new Amount(1);
     var venture = new Venture(nameOfVenture, outlay, minInvestment);
     Assert.AreEqual(nameOfVenture.GetValue(), venture.Name);
     Assert.AreEqual(outlay, venture.Outlay);
     Assert.AreEqual(minInvestment, venture.MinInvestment);
     Assert.True(venture.IsProposed());
 }
Exemplo n.º 4
0
 public Venture(Name name, Amount outlay, Amount minInvestment)
     : this(name, outlay)
 {
     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");
     MinInvestment = minInvestment;
     State = PROPOSED_STATE;
     AddEventToVentureHistory(VentureEvent.PROPOSED);
 }
Exemplo n.º 5
0
 public void ShouldCreateVenturesWithPassedNames()
 {
     var venture = new Venture(new Name("venture-name"), new Amount(100), new Amount(10));
     var firstVentureName = new Name("new-venture-1");
     var secondVentureName = new Name("new-venture-2");
     var terms = new TermsOfSplit(new Percentage(0.8f), firstVentureName, secondVentureName);
     venture.AddOffer(new Investor(new Name("testName"), new Amount(1000)), new Amount(100));
     venture.Start();
     var ventures = venture.Split(terms);
     Assert.AreEqual(firstVentureName.GetValue(), ventures.First().Name);
     Assert.AreEqual(secondVentureName.GetValue(), ventures.Last().Name);
 }
Exemplo n.º 6
0
        public void Should_Be_Able_To_Save_And_Load_A_Venture()
        {
            Name nameOfVenture = new Name("Ventura");
            Amount outlay = new Amount(100);
            Amount minInvestment = new Amount(1);
            Venture venture = new Venture(nameOfVenture, outlay, minInvestment);
            VentureRepository ventureRepository = new VentureRepository(session);

            ventureRepository.Save(venture);
            IList<Venture> ventures = ventureRepository.FetchAll();

            Assert.AreEqual(venture, ventures.First());
        }
Exemplo n.º 7
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();
 }
Exemplo n.º 8
0
        public void ShouldNotBeAbleToSplitANonStartedVenture()
        {
            var outlay = new Amount(40);
            var venture = new Venture(new Name("Ventura"), outlay, new Amount(1));
            var investor0 = new Investor(new Name("Investor0"), new Amount(100));
            venture.AddOffer(investor0, new Amount(50));

            var firstVentureName = new Name("new-venture-1");
            var secondVentureName = new Name("new-venture-2");
            var percentage = new Percentage(0.2f);
            var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);

            Assert.Throws<Exception>(()=>venture.Split(terms));
        }
Exemplo n.º 9
0
        public void ShouldCloseTheVentureWhenAVentureSplits()
        {
            var outlay = new Amount(40);
            var venture = new Venture(new Name("Ventura"), outlay, new Amount(1));
            var investor0 = new Investor(new Name("Investor0"), new Amount(100));
            venture.AddOffer(investor0, new Amount(50));
            venture.Start();
            var firstVentureName = new Name("new-venture-1");
            var secondVentureName = new Name("new-venture-2");
            var percentage = new Percentage(0.2f);

            var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);
            venture.Split(terms);

            Assert.IsTrue(venture.IsClosed());
        }
Exemplo n.º 10
0
        public void ShouldBeAbleToSaveAndLoadAVenture()
        {
            Name nameOfVenture = new Name("Ventura");
            Amount outlay = new Amount(100);
            Amount minInvestment = new Amount(1);
            Venture venture = new Venture(nameOfVenture, outlay, minInvestment);
            VentureRepository ventureRepository = new VentureRepository(session);

            ventureRepository.Save(venture);
            session.Flush();
            session.Evict(venture);

            IList<Venture> ventures = ventureRepository.FetchAll();

            Assert.Contains(venture, ventures as ICollection);
        }
Exemplo n.º 11
0
        public void ShouldSplitHoldingInvestmentsAccordingToRatio()
        {
            var outlay = new Amount(40);
            var venture = new Venture(new Name("Ventura"), outlay, new Amount(1));
            var investor0 = new Investor(new Name("Investor0"), new Amount(100));
            venture.AddOffer(investor0, new Amount(50));
            venture.Start();
            var firstVentureName = new Name("new-venture-1");
            var secondVentureName = new Name("new-venture-2");
            var percentage = new Percentage(0.2f);

            var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);
            var ventures = venture.Split(terms);
            Assert.AreEqual(venture.HoldingValue.Denomination, ventures.Sum(n => n.HoldingValue.Denomination));
        }
Exemplo n.º 12
0
 public void Should_Be_Able_To_Create_A_Venture()
 {
     Name nameOfVenture = new Name("Ventura");
     Amount outlay = new Amount(100);
     Amount minInvestment = new Amount(1);
     Venture venture = new Venture(nameOfVenture, outlay, minInvestment);
     Assert.AreEqual(nameOfVenture, venture.Name);
     Assert.AreEqual(outlay, venture.Outlay);
     Assert.AreEqual(minInvestment, venture.MinInvestment);
     Assert.True(venture.IsProposed());
 }
Exemplo n.º 13
0
 public void ShouldSplitOutlayMoneyAccordingToRatio()
 {
     var venture = new Venture(new Name("venture-name"), new Amount(100), new Amount(10));
     var firstVentureName = new Name("new-venture-1");
     var secondVentureName = new Name("new-venture-2");
     var percentage = new Percentage(0.2f);
     var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);
     venture.AddOffer(new Investor(new Name("testName"), new Amount(1000)), new Amount(100));
     venture.Start();
     var ventures = venture.Split(terms);
     Assert.AreEqual(percentage.Apply(venture.Outlay), ventures.First().Outlay);
     Assert.AreEqual(percentage.ApplyRemaining(venture.Outlay), ventures.Last().Outlay);
 }
Exemplo n.º 14
0
 public Investor(Name name, GringottsDate date, Amount amount)
 {
     this.name = name;
     this.date = date;
     Corpus = amount;
 }
Exemplo n.º 15
0
        public void ShouldCreateVentureEventWhenVentureSplits()
        {
            var outlay = new Amount(40);
            var venture = new Venture(new Name("Ventura"), outlay, new Amount(1));
            var investor0 = new Investor(new Name("Investor0"), new Amount(100));
            venture.AddOffer(investor0, new Amount(50));
            venture.Start();
            var firstVentureName = new Name("new-venture-1");
            var secondVentureName = new Name("new-venture-2");
            var percentage = new Percentage(0.2f);

            var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);
            var newVentures = venture.Split(terms);

            Assert.IsTrue(newVentures.First().IsStarted());
            Assert.IsTrue(newVentures.Last().IsStarted());

            VentureEvent ventureEventSplit1 = new VentureEvent(VentureEvent.SPLIT,new Amount(8));
            VentureEvent ventureEventStarted1 = new VentureEvent(VentureEvent.STARTED,new Amount(8));
            VentureEvent ventureEventSplit2 = new VentureEvent(VentureEvent.SPLIT,new Amount(32));
            VentureEvent ventureEventStarted2 = new VentureEvent(VentureEvent.STARTED,new Amount(32));

            VentureHistory ventureHistory1 = newVentures.First().GetVentureHistory();
            VentureHistory ventureHistory2 = newVentures.Last().GetVentureHistory();

            Assert.Contains(ventureEventSplit1, ventureHistory1.GetEvents());
            Assert.Contains(ventureEventStarted1, ventureHistory1.GetEvents());

            Assert.Contains(ventureEventSplit2, ventureHistory2.GetEvents());
            Assert.Contains(ventureEventStarted2, ventureHistory2.GetEvents());
        }
Exemplo n.º 16
0
        public void ShouldUpdateThePortfolioOfTheInvestorWhenVentureCloses()
        {
            var outlay = new Amount(50);
            var venture = new Venture(new Name("Ventura"), outlay, new Amount(1));
            var investor0 = new Investor(new Name("Investor0"), new Amount(100));
            venture.AddOffer(investor0, new Amount(50));
            venture.Start();
            var firstVentureName = new Name("new-venture-1");
            var secondVentureName = new Name("new-venture-2");
            var percentage = new Percentage(0.2f);

            var terms = new TermsOfSplit(percentage, firstVentureName, secondVentureName);
            var ventures = venture.Split(terms);

               Assert.IsFalse(investor0.HasInvestmentIn(venture));
               Assert.IsTrue(investor0.HasInvestmentIn(ventures.First()));
               Assert.IsTrue(investor0.HasInvestmentIn(ventures.Last()));
        }
Exemplo n.º 17
0
 public TermsOfSplit(Percentage ratio, Name firstVentureName, Name secondVentureName)
 {
     Ratio = ratio;
     FirstVentureName = firstVentureName;
     SecondVentureName = secondVentureName;
 }