public async Task ScreeningAdded_event_handler_add_screening_entity_correctly( MovieCreated movieCreated, Theater theater, InMemoryMovieRepository movieRepositoryDouble, InMemoryTheaterRepository theaterReaderStub, IFixture builder) { // Arrange theaterReaderStub.Data[theater.Id] = theater; var sut = new MovieReadModelGenerator( movieRepositoryDouble, theaterReaderStub); await sut.Handle(new Envelope(movieCreated)); Guid movieId = movieCreated.MovieId; ScreeningAdded domainEvent = builder .Build <ScreeningAdded>() .With(x => x.SourceId, movieId) .With(x => x.TheaterId, theater.Id) .With(x => x.SeatRowCount, theater.SeatRowCount) .With(x => x.SeatColumnCount, theater.SeatColumnCount) .Create(); // Act await sut.Handle(new Envelope(domainEvent)); // Assert Movie actual = movieRepositoryDouble.Data[movieId]; actual.Screenings .Should().Contain(s => s.Id == domainEvent.ScreeningId).Which .Should().BeEquivalentTo(new { Id = domainEvent.ScreeningId, domainEvent.TheaterId, TheaterName = theater.Name, Seats = from r in Enumerable.Range(0, theater.SeatRowCount) from c in Enumerable.Range(0, theater.SeatColumnCount) select new Seat { Row = r, Column = c, IsReserved = false, }, domainEvent.ScreeningTime, domainEvent.DefaultFee, domainEvent.ChildrenFee, CreatedAt = domainEvent.RaisedAt, }); }
public async Task MovieCreated_event_handler_creates_read_model_entity_correctly( MovieCreated domainEvent, InMemoryMovieRepository repositorySpy) { var sut = new MovieReadModelGenerator( repositorySpy, Mock.Of <ITheaterReader>()); await sut.Handle(new Envelope(domainEvent)); IDictionary <Guid, Movie> data = repositorySpy.Data; data.Should().ContainKey(domainEvent.MovieId); data[domainEvent.MovieId].Should().BeEquivalentTo(new { domainEvent.Title, CreatedAt = domainEvent.RaisedAt, ETag = default(string), }); }