Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void Should_Be_Able_To_Save_And_Load_A_Venture()
        {
            Name nameOfVenture = new Name("Ventura");
            Amount outlay = new Amount(100);
            Amount minInvestment = new Amount(1);
            Venture venture = new Venture(nameOfVenture, outlay, minInvestment);
            VentureRepository ventureRepository = new VentureRepository(session);

            ventureRepository.Save(venture);
            IList<Venture> ventures = ventureRepository.FetchAll();

            Assert.AreEqual(venture, ventures.First());
        }
Ejemplo n.º 3
0
        public void ShouldBeAbleToSaveAndLoadAVenture()
        {
            Name nameOfVenture = new Name("Ventura");
            Amount outlay = new Amount(100);
            Amount minInvestment = new Amount(1);
            Venture venture = new Venture(nameOfVenture, outlay, minInvestment);
            VentureRepository ventureRepository = new VentureRepository(session);

            ventureRepository.Save(venture);
            session.Flush();
            session.Evict(venture);

            IList<Venture> ventures = ventureRepository.FetchAll();

            Assert.Contains(venture, ventures as ICollection);
        }
        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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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());
        }