Gringotts.Domain.Venture.Split C# (CSharp) Method

Split() public method

public Split ( TermsOfSplit termsOfSplit ) : IEnumerable
termsOfSplit TermsOfSplit
return IEnumerable
        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;
        }

Usage Example

コード例 #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());
 }
All Usage Examples Of Gringotts.Domain.Venture::Split