public IEnumerable <BullOakEvent> CreateViewing(CinemaAggregateRootId cinemaId, string movieName, DateTime timeOfViewing, int numberOfSeats) { yield return(new ViewingCreatedEvent(new ViewingId(movieName, timeOfViewing, cinemaId), numberOfSeats)); for (int i = 0; i < numberOfSeats; i++) { yield return(seatInViewingEntity.Initialize(i)); } }
public void SaveRepoBasedAggregate() { var cinemaId = new CinemaAggregateRootId(Guid.NewGuid().ToString()); using (var session = fixture.CinemaFunctionalRepo.BeginSessionFor(cinemaId).Result) { var @event = new BullOak.Test.EndToEnd.Stub.RepositoryBased.CinemaAggregate.CinemaAggregateRoot() .Create(fixture.correlationId, capacity, Guid.NewGuid().ToString()); session.AddEvent(@event); session.SaveChanges().Wait(); } }
public AggregateFixture(string name, object[] appliers = null) { var configuration = Configuration.Begin() .WithDefaultCollection() .WithDefaultStateFactory() .AlwaysUseThreadSafe() .WithNoEventPublisher() .WithAnyAppliersFromInstances((IEnumerable <object>)appliers ?? new List <object>()) .WithAnyAppliersFrom(Assembly.GetAssembly(typeof(CinemaAggregateState))) .AndNoMoreAppliers() .WithNoUpconverters() .Build(); this.name = name; correlationId = Guid.NewGuid(); CinemaFunctionalRepo = new InMemoryEventSourcedRepository <CinemaAggregateRootId, CinemaAggregateState>(configuration); ViewingFunctionalRepo = new InMemoryEventSourcedRepository <ViewingId, IViewingState>(configuration); cinemaId = new CinemaAggregateRootId(name); dateOfViewing = DateTime.Now.AddDays(3); }
public CinemaCreated(Guid correlationId, CinemaAggregateRootId cinemaId, int capacity) : base(correlationId) { CinemaId = cinemaId; Capacity = capacity; }