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()); }
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); }
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()); }
public virtual IEnumerable<Venture> Split(TermsOfSplit termsOfSplit) { if(!IsStarted()){ throw new Exception("Cannot split a venture that is not started."); } // Splitting of OutLay var aVentures = new List<Venture>(); var aFirstVenture = new Venture(termsOfSplit.FirstVentureName,termsOfSplit.Ratio.Apply(Outlay)); var aSecondVenture = new Venture(termsOfSplit.SecondVentureName, termsOfSplit.Ratio.ApplyRemaining(Outlay)); // Splitting of Holding's Investments var holdings = Holding.Split(termsOfSplit.Ratio); aFirstVenture.holding = holdings[0]; aSecondVenture.holding = holdings[1]; AddEventToVentureHistory(VentureEvent.SPLIT); CloseTheVenture(); aFirstVenture.AddEventToVentureHistory(VentureEvent.SPLIT); aSecondVenture.AddEventToVentureHistory(VentureEvent.SPLIT); aFirstVenture.ChangeStateToStarted(); aSecondVenture.ChangeStateToStarted(); aVentures.Add(aFirstVenture); aVentures.Add(aSecondVenture); return aVentures; }
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)); }
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)); }
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())); }
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); }
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()); }