public async Task given_theater_not_found_then_FindTheater_returns_NotFoundResult(
            Guid theaterId,
            InMemoryTheaterRepository readerStub,
            [NoAutoProperties] QueriesController sut)
        {
            var           facade = new TheaterReadModelFacade(readerStub);
            IActionResult actual = await sut.FindTheater(theaterId, facade);

            actual.Should().BeOfType <NotFoundResult>();
        }
Exemplo n.º 2
0
        public async Task GetAllTheaters_sort_transfer_objects_by_CreatedAt(
            ImmutableArray <Theater> entities,
            InMemoryTheaterRepository readerStub)
        {
            entities.ForEach(x => readerStub.Data[x.Id] = x);
            var sut = new TheaterReadModelFacade(readerStub);

            ImmutableArray <TheaterDto> actual = await sut.GetAllTheaters();

            actual.Should().BeInDescendingOrder(x => x.CreatedAt);
        }
        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 given_theater_found_then_FindTheater_returns_OkObjectResult(
            Theater theater,
            InMemoryTheaterRepository readerStub,
            [NoAutoProperties] QueriesController sut)
        {
            readerStub.Data[theater.Id] = theater;
            var facade = new TheaterReadModelFacade(readerStub);

            IActionResult actual = await sut.FindTheater(theater.Id, facade);

            actual.Should().BeOfType <OkObjectResult>();
        }
        public async Task GetAllTheaters_returns_transfer_objects_as_content(
            Theater[] theaters,
            InMemoryTheaterRepository readerStub,
            [NoAutoProperties] QueriesController sut)
        {
            theaters.ForEach(t => readerStub.Data[t.Id] = t);
            var facade = new TheaterReadModelFacade(readerStub);

            var actual = (OkObjectResult)await sut.GetAllTheaters(facade);

            actual.Value.Should().BeEquivalentTo(await facade.GetAllTheaters());
        }
        public async Task GetAllTheaters_returns_OkObjectResult(
            Theater[] theaters,
            InMemoryTheaterRepository readerStub,
            [NoAutoProperties] QueriesController sut)
        {
            theaters.ForEach(t => readerStub.Data[t.Id] = t);
            var facade = new TheaterReadModelFacade(readerStub);

            IActionResult actual = await sut.GetAllTheaters(facade);

            actual.Should().BeOfType <OkObjectResult>();
        }
Exemplo n.º 7
0
        public async Task GetAllTheaters_assembles_all_transfer_objects_correctly(
            ImmutableArray <Theater> entities,
            InMemoryTheaterRepository readerStub)
        {
            entities.ForEach(x => readerStub.Data[x.Id] = x);
            var sut = new TheaterReadModelFacade(readerStub);

            ImmutableArray <TheaterDto> actual = await sut.GetAllTheaters();

            actual.Should().BeEquivalentTo(
                expectation: entities,
                opts => opts.ExcludingMissingMembers());
        }
Exemplo n.º 8
0
        public async Task FindTheater_assembles_transfer_object_correctly(
            Theater entity, InMemoryTheaterRepository readerStub)
        {
            readerStub.Data[entity.Id] = entity;
            var sut = new TheaterReadModelFacade(readerStub);

            TheaterDto actual = await sut.FindTheater(theaterId : entity.Id);

            actual.Should().BeEquivalentTo(new
            {
                entity.Id,
                entity.Name,
                entity.SeatRowCount,
                entity.SeatColumnCount,
                entity.CreatedAt,
            });
        }
        public async Task given_theater_found_then_FindTheater_returns_transfer_object_as_content(
            Theater theater,
            InMemoryTheaterRepository readerStub,
            [NoAutoProperties] QueriesController sut)
        {
            readerStub.Data[theater.Id] = theater;
            var facade = new TheaterReadModelFacade(readerStub);

            IActionResult result = await sut.FindTheater(theater.Id, facade);

            object actual = result.As <OkObjectResult>().Value;

            actual.Should().BeOfType <TheaterDto>();
            actual.Should().BeEquivalentTo(new
            {
                theater.Id,
                theater.Name,
                theater.SeatRowCount,
                theater.SeatColumnCount,
            });
        }
        public async Task TheaterCreated_event_handler_creates_read_model_entity_correctly(
            TheaterCreated domainEvent,
            InMemoryTheaterRepository repositorySpy)
        {
            // Arrange
            var sut = new TheaterReadModelGenerator(repositorySpy);

            // Act
            await sut.Handle(new Envelope(domainEvent));

            // Assert
            IDictionary <Guid, Theater> data = repositorySpy.Data;

            data.Should().ContainKey(domainEvent.TheaterId);
            data[domainEvent.TheaterId].Should().BeEquivalentTo(new
            {
                domainEvent.Name,
                domainEvent.SeatRowCount,
                domainEvent.SeatColumnCount,
                CreatedAt = domainEvent.RaisedAt,
                ETag      = default(string),
            });
        }