Save() public method

public Save ( Investor newInvestor ) : string
newInvestor Gringotts.Domain.Investor
return string
コード例 #1
0
        public void ShouldFetchMultipleOffersForInvestor()
        {
            Investor investor = CreateInvestor("Jagan1", 5000);
            InvestorRepository investorRepository = new InvestorRepository(session);
            investorRepository.Save(investor);

            Venture venture1 = CreateVenture(3000, 500, "Ram1");
            Venture venture2 = CreateVenture(6000, 1000, "Ram2");
            VentureRepository ventureRepository = new VentureRepository(session);
            ventureRepository.Save(venture1);
            ventureRepository.Save(venture2);

            Amount amount1 = new Amount(700);
            Amount amount2 = new Amount(800);

            Offer offer1 = new Offer(investor, amount1, venture1);
            Offer offer2 = new Offer(investor, amount2, venture2);
            OfferRepository offerRepository = new OfferRepository(session);
            offerRepository.Save(offer1);
            offerRepository.Save(offer2);

            session.Flush();
            session.Clear();

            Investor fetchedInvestor = investorRepository.GetInvestorById(investor.Id);
            Assert.AreEqual(new Amount(1500), fetchedInvestor.OfferValue);
        }
コード例 #2
0
        public void ShouldBeAbleToSaveInvestor()
        {
            string name = "Investor 1";
            DateTime date = DateTime.Today;
            int amount = 100;

            Investor investor = new Investor(new Name(name),  new Amount(amount));

            InvestorRepository investorRepository = new InvestorRepository(session);
            string newId = investorRepository.Save(investor);

            Investor newInvestor = investorRepository.GetInvestorById(newId);
            Assert.AreEqual(new Name(name), newInvestor.Name);
        }
コード例 #3
0
        public void Should_Be_Able_To_Save_Investor()
        {
            string name = "Investor 1";
            DateTime date = DateTime.Today;
            int amount = 100;

            Investor investor = new Investor(new Name(name), new GringottsDate(date), new Amount(amount));

            InvestorRepository investorRepository = new InvestorRepository();
            investorRepository.Session = session;
            int newId = investorRepository.Save(investor);

            Investor newInvestor = investorRepository.GetInvestorById(newId);
            Assert.AreEqual(new Name(name), newInvestor.Name);
        }
コード例 #4
0
        public void Should_Persist()
        {
            Investor investor = new Investor(new Name("Investor 1"), new GringottsDate(DateTime.Today), new Amount(100));
            InvestorRepository investorRepository = new InvestorRepository();
            investorRepository.Session = session;
            investorRepository.Save(investor);

            Venture venture = new Venture(new Name("Ventura"), new Amount(100), new Amount(1));
            VentureRepository ventureRepository = new VentureRepository(session);
            ventureRepository.Save(venture);

            Investment investment = new Investment(investor, venture, new Amount(10));
            InvestmentRepository investmentRepository = new InvestmentRepository(session);
            investmentRepository.Save(investment);

            IList<Investment> investments = investmentRepository.FetchAll();
            Assert.Greater(investments.Count, 0);
        }
コード例 #5
0
        public void VerifyCascadeSaveOfBalanceEventViaInvestor()
        {
            Investor investor = new Investor(new Name("dude"), new Amount(1000));
            BalanceHistory balanceHistory = investor.GetBalanceHistory();

            var venture = new Venture(new Name("Hacker's Venture"), new Amount(500), new Amount(500));
            var offerAmount = new Amount(500);
            venture.AddOffer(investor, offerAmount);
            var testBalanceEvent = new BalanceEvent(string.Format(BalanceEvent.OFFER_ACCEPTED,venture.Name), offerAmount);

            InvestorRepository investorRepository = new InvestorRepository(session);
            investorRepository.Save(investor);
            session.Evict(investor);

            IQuery query = session.CreateQuery("from BalanceEvent");
            IList<BalanceEvent> savedBalanceEvents = query.List<BalanceEvent>();
            Assert.IsTrue(savedBalanceEvents.Contains(testBalanceEvent));
        }
コード例 #6
0
        public void ShouldFetchInvestorAndVentureForOffer()
        {
            Investor investor = CreateInvestor("Jagan", 4000);
            var investorRepository = new InvestorRepository(session);

            investorRepository.Save(investor);

            Venture venture = CreateVenture(2000, 400, "Ram Capitalists");
            var ventureRepository = new VentureRepository(session);
            ventureRepository.Save(venture);

            const int denomination = 500;
            var offer = new Offer(investor, new Amount(denomination), venture);
            var offerRepository = new OfferRepository(session);
            offerRepository.Save(offer);

            session.Flush();

            session.Evict(offer);
            session.Evict(investor);
            session.Evict(venture);

            IList<Offer> offers = offerRepository.FetchAll();
            Assert.AreEqual(1, offers.Count);
            Offer savedOffer = offers[0];

            //offer props
            Assert.AreEqual(denomination, savedOffer.Value.Denomination);

            //investor props
            Assert.AreEqual(investor.Name.GetValue(), savedOffer.Investor.Name.GetValue());

            //venture props
            Assert.AreEqual(venture.Name, savedOffer.Venture.Name);
            Assert.AreEqual(venture.Outlay, savedOffer.Venture.Outlay);
            Assert.AreEqual(venture.MinInvestment, savedOffer.Venture.MinInvestment);
        }
コード例 #7
0
        public void ShouldFetchMultipleSubscriptionsForVenture()
        {
            Investor investor1 = CreateInvestor("Joy", 9000);
            Investor investor2 = CreateInvestor("Roy", 6000);
            InvestorRepository investorRepository = new InvestorRepository(session);
            investorRepository.Save(investor1);
            investorRepository.Save(investor2);

            Venture venture = CreateVenture(8000, 1920, "Ace Ventura");
            VentureRepository ventureRepository = new VentureRepository(session);
            ventureRepository.Save(venture);

            Amount amount1 = new Amount(712);
            Amount amount2 = new Amount(423);

            Offer offer1 = new Offer(investor1, amount1, venture);
            Offer offer2 = new Offer(investor2, amount2, venture);
            OfferRepository offerRepository = new OfferRepository(session);
            offerRepository.Save(offer1);
            offerRepository.Save(offer2);

            session.Flush();
            session.Clear();

            Venture fetchedVenture = ventureRepository.GetVentureById(venture.Id);
            Assert.AreEqual(new Amount(1135), fetchedVenture.SubscribedAmount());
        }
コード例 #8
0
        public void ShouldFetchOffersForInvestorAndVenture()
        {
            Investor investor = CreateInvestor("Jagan", 4000);
            InvestorRepository investorRepository = new InvestorRepository(session);
            investorRepository.Save(investor);

            Venture venture = CreateVenture(2000, 400, "Ram Capitalists");
            VentureRepository ventureRepository = new VentureRepository(session);
            ventureRepository.Save(venture);

            Amount amount = new Amount(600);
            Offer offer = new Offer(investor, amount, venture);
            OfferRepository offerRepository = new OfferRepository(session);
            offerRepository.Save(offer);

            session.Flush();
            session.Evict(investor);
            session.Evict(venture);
            session.Evict(offer);

            Investor fetchedInvestor = investorRepository.GetInvestorById(investor.Id);
            Assert.AreEqual(amount, fetchedInvestor.OfferValue);

            Venture fetchedVenture = ventureRepository.GetVentureById(venture.Id);
            Assert.AreEqual(amount, fetchedVenture.SubscribedAmount());
        }