예제 #1
0
        public async Task GetAllTheaters_restores_all_read_model_entities_correctly(
            Theater[] theaters, SomeDocument[] residuals)
        {
            // Arrange
            string collectionId = "GetAllTheaters";

            await InitializeCollection(collectionId);

            var sut = new CosmosDbTheaterRepository(
                DocumentClient,
                new CollectionReference(DatabaseId, collectionId));

            await Task.WhenAll(theaters.Select(sut.CreateTheater));

            foreach (SomeDocument document in residuals)
            {
                await CreateDocument(collectionId, document);
            }

            // Act
            ImmutableArray <Theater> actual = await sut.GetAllTheaters();

            // Assert
            actual.Should().BeEquivalentTo(
                expectation: theaters,
                config: c => c.Excluding(x => x.ETag));
        }
예제 #2
0
        public async Task FindTheater_restores_read_model_entity_correctly(
            Theater theater)
        {
            // Arrange
            theater.ETag = default;
            IDocumentClient client = DocumentClient;
            var             sut    = new CosmosDbTheaterRepository(client, Collection);
            await sut.CreateTheater(theater);

            // Act
            Theater actual = await sut.FindTheater(theater.Id);

            // Assert
            IQueryable <TheaterDocument> query =
                from d in client.CreateDocumentQuery <TheaterDocument>()
                where
                d.Discriminator == nameof(TheaterDocument) &&
                d.Id == theater.Id
                select d;

            TheaterDocument document = await query.SingleOrDefault();

            actual.Should().BeEquivalentTo(new
            {
                document.Id,
                document.ETag,
                document.Name,
                document.SeatRowCount,
                document.SeatColumnCount,
                document.CreatedAt,
            });
        }
예제 #3
0
        public async Task given_document_not_found_then_FindTheater_returns_null(
            Guid theaterId)
        {
            var     sut    = new CosmosDbTheaterRepository(DocumentClient, Collection);
            Theater actual = await sut.FindTheater(theaterId);

            actual.Should().BeNull();
        }