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 ShouldBeAbleToChangeStateOfANewVentureToStarted() { var venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1)); venture.ChangeStateToStarted(); Assert.AreEqual(Venture.STARTED_STATE, venture.State); }
public void Should_Be_Able_To_Change_State_Of_A_New_Venture_To_Started() { Venture venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1)); venture.ChangeStateToStarted(); Assert.AreEqual(Venture.STARTED_STATE, venture.State); }
public void ShouldNotBeAbleToDivideDividendsUnlessInAStartedState() { var dividend = new Amount(1000); var venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1)); Assert.Throws<Exception>(delegate { venture.HandOutDividends(dividend); }); venture.ChangeStateToCancelled(); Assert.Throws<Exception>(delegate { venture.HandOutDividends(dividend); }); venture.ChangeStateToStarted(); Assert.DoesNotThrow(delegate { venture.HandOutDividends(dividend); }); }
public void Should_Not_Be_Able_To_Divide_Dividends_Unless_In_A_Started_State() { Amount dividend = new Amount(1000); Venture venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1)); Assert.Throws<Exception>(delegate { venture.HandOutDividends(dividend); }); venture.ChangeStateToCancelled(); Assert.Throws<Exception>(delegate { venture.HandOutDividends(dividend); }); venture.ChangeStateToStarted(); Assert.DoesNotThrow(delegate { venture.HandOutDividends(dividend); }); }