public void ShouldVerifySaveAndLoadOfBalanceEvents() { BalanceEvent balanceEvent = new BalanceEvent(BalanceEvent.OFFER_ACCEPTED, new Amount(600)); String id = (String)session.Save(balanceEvent); session.Evict(balanceEvent); IQuery query = session.CreateQuery("from BalanceEvent"); IList<BalanceEvent> events = query.List<BalanceEvent>(); Assert.AreEqual(1,events.Count); Assert.AreEqual(balanceEvent, events[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)); }
public void ShouldCreateABalanceEventWhenVentureBankruptcyIsNotified() { var investor = new Investor(new Name("Inverstor1"), new Amount(1100)); var venture = new Venture(new Name("Hacker's Venture"), new Amount(500), new Amount(500)); Offer offer = venture.AddOffer(investor, new Amount(500)); Investment investment = offer.ToInvestment(); venture.Start(); investor.NotifyVentureBankruptcy(investment); BalanceHistory history = investor.GetBalanceHistory(); String offerEvent = String.Format(BalanceEvent.VENTURE_BANKRUPT, "Hacker's Venture"); BalanceEvent expectedBalanceEvent = new BalanceEvent(offerEvent, new Amount(600)); Assert.Contains(expectedBalanceEvent, history.GetEvents()); }
public void AddEvent(BalanceEvent balanceEvent) { events.Add(balanceEvent); }
public Task Handle(BalanceEvent notification, CancellationToken cancellationToken) { return(Task.Run(() => _logger.LogWarning( $"WEALTH ALERT: Customer: {notification.CustomerID}, Account: {notification.AccountNumber}, Balance: {notification.Balance}"), cancellationToken)); }
public void ShouldCreateAOfferAcceptedBalanceEventWhenInvestorMakesAnOffer() { var investor = new Investor(new Name("Inverstor1"), new Amount(1000)); var venture = new Venture(new Name("ventura!"), new Amount(1000), new Amount(500)); Offer offer = venture.AddOffer(investor, new Amount(600)); Assert.AreEqual(new Amount(400), investor.Balance); BalanceHistory history = investor.GetBalanceHistory(); string offerEvent = string.Format(BalanceEvent.OFFER_ACCEPTED, offer.VentureName); BalanceEvent balanceEvent = new BalanceEvent(offerEvent, new Amount(400)); Assert.Contains(balanceEvent, history.GetEvents()); }
public void ShouldCreateAInvestorCreatedBalanceEventWhenInvestorIsCreated() { Amount amount = new Amount(100); var investor = new Investor(new Name("Investor"), amount); BalanceHistory history = investor.GetBalanceHistory(); BalanceEvent balanceEvent = new BalanceEvent(BalanceEvent.INVESTOR_CREATED, amount); Assert.Contains(balanceEvent, history.GetEvents()); }
public void ShouldCreateDividendReceivedEventWhenDividendIsDeclared() { var initialBalance = new Amount(1000); var investor1 = new Investor(new Name("Inverstor 1"), initialBalance); var outlay = new Amount(400); var venture = new Venture(new Name("Ventura Inc."), outlay, new Amount(1)); venture.AddOffer(investor1, outlay); venture.Start(); var dividend = new Amount(1000); venture.HandOutDividends(dividend); BalanceHistory history = investor1.GetBalanceHistory(); string dividendEvent = string.Format(BalanceEvent.DIVIDEND_RECEIVED, venture.Name); BalanceEvent balanceEvent = new BalanceEvent(dividendEvent, initialBalance - outlay + dividend); Assert.Contains(balanceEvent, history.GetEvents()); }
public void ShouldCreateAOfferRejectedEventWhenVentureRejectsAnOffer() { var initialBalance = new Amount(1000); var investor1 = new Investor(new Name("Inverstor 1"), initialBalance); var investor2 = new Investor(new Name("Inverstor 2"), initialBalance); var outlay = new Amount(500); var venture = new Venture(new Name("Ventura Inc."), outlay, new Amount(1)); venture.AddOffer(investor1, outlay); var offerAmount2 = new Amount(600); venture.AddOffer(investor2, offerAmount2); venture.Start(); BalanceHistory history = investor2.GetBalanceHistory(); string offerEvent = string.Format(BalanceEvent.OFFER_REJECTED, venture.Name); BalanceEvent balanceEvent = new BalanceEvent(offerEvent, initialBalance); Assert.Contains(balanceEvent, history.GetEvents()); }
public void ShouldCreateAOfferPartiallyAcceptedEventWhenOffersAreConfirmed() { var initialBalance = new Amount(1000); var investor1 = new Investor(new Name("Inverstor 1"), initialBalance); var outlay = new Amount(400); var venture = new Venture(new Name("Ventura Inc."), outlay, new Amount(1)); var excess = new Amount(100); venture.AddOffer(investor1, outlay + excess); Assert.AreEqual(initialBalance - (outlay + excess), investor1.Balance); venture.Start(); BalanceHistory history = investor1.GetBalanceHistory(); string offerEvent = string.Format(BalanceEvent.OFFER_PARTIALLY_ACCEPTED, venture.Name); BalanceEvent balanceEvent = new BalanceEvent(offerEvent, initialBalance - outlay); Assert.Contains(balanceEvent, history.GetEvents()); }