public async Task ShouldSuccesfullyInitializeDatabaseAndCollection()
        {
            // ARRANGE
            var eventOffset    = 0L;
            var projectionId   = CombGuid.Generate();
            var projectionType = "IntegrationTestProjection";

            // Query Model Repository (DocumentDB)
            var queryModelRepository = new DocumentDbQueryModelRepository(_database, _collection, _offerThroughput, _noOfPartitions, _endpoint, _authKey);

            queryModelRepository.Initialize();

            // Projection Metadata Repository (MSSQL);
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(_sqlConnectionString);

            projectionMetadataRepository.InitializeProjection(projectionId, projectionType);

            // Dummy Query Model
            var queryModelId   = CombGuid.Generate();
            var testQueryModel = new TestQueryModel(queryModelId, "Hello Integration Test!");

            // Query Model Store
            var queryModelStore = new QueryModelStore(
                queryModelRepository,
                projectionMetadataRepository,
                eventOffset,
                projectionId);

            // ACT
            await queryModelStore.SaveQueryModel(testQueryModel);

            // ASSERT
        }
Пример #2
0
        private async Task Handle(UserRegistered @event, QueryModelStore queryModelStore)
        {
            // Get current instance of query model
            var queryModel = await queryModelStore.GetQueryModel <UserQueryModel>(@event.AggregateId, createIfMissing : true);

            // Set Query Model properties
            queryModel.FirstName   = @event.FirstName;
            queryModel.LastName    = @event.LastName;
            queryModel.DisplayName = @event.FirstName + " " + @event.LastName;

            // Create or Update Query model in Read Store (E.g. CosmosDB)
            await queryModelStore.SaveQueryModel(queryModel);
        }