public void Concert_Applying_ConcertTicketsBoughtDomainEvent() { ConcertTicketsBoughtDomainEvent ticketsBought = new ConcertTicketsBoughtDomainEvent(10, 5, Guid.NewGuid()); Concert concert = new Concert("SPENS", 50, DateTime.Now, "Koncert godine", Guid.NewGuid()); concert.Apply(ticketsBought); Assert.True(concert.BoughtTickets.Quantity == 10); }
public void Concert_Applying_ConcertCreatedDomainEvent() { ConcertCreatedDomainEvent concertCreated = new ConcertCreatedDomainEvent(3, "SPENS", DateTime.Now, "Koncert godine", Guid.NewGuid()); Concert concert = new Concert(); concert.Apply(concertCreated); Assert.True(concert.BoughtTickets.Quantity == 0); Assert.True(concert.Date == concertCreated.Date); Assert.True(concert.Id == concertCreated.ConcertId); Assert.True(concert.MaximumNumberOfTickets.Quantity == concertCreated.NumberOfTickets); }
public bool TryFindBy(Guid concertId, out Concert concert) { var bucketId = GetBucketId(concertId); var fromEventNumber = 0; var toEventNumber = int.MaxValue; concert = _concertFactory.Create(); using (var stream = _eventStore.OpenStream(bucketId, concertId.ToString(), fromEventNumber, toEventNumber)) { foreach (var @event in stream.CommittedEvents) { concert.Apply((dynamic)@event.Body); } } return(concert.Id != Guid.Empty); }