Split() public method

public Split ( TermsOfSplit termsOfSplit ) : IEnumerable
termsOfSplit TermsOfSplit
return IEnumerable
Ejemplo n.º 1
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());
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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()));
        }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
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());
        }