Beispiel #1
0
        public async Task GetMultipleSchemaVersions()
        {
            // arrange
            IMongoCollection <Schema> schemas =
                _mongoResource.CreateCollection <Schema>();
            IMongoCollection <SchemaVersion> versions =
                _mongoResource.CreateCollection <SchemaVersion>();
            IMongoCollection <SchemaPublishReport> publishReports =
                _mongoResource.CreateCollection <SchemaPublishReport>();
            IMongoCollection <PublishedSchema> publishedSchemas =
                _mongoResource.CreateCollection <PublishedSchema>();

            var repository = new SchemaRepository(
                schemas, versions, publishReports, publishedSchemas);

            var schema = new Schema("foo", "bar");
            await repository.AddSchemaAsync(schema);

            var a = new SchemaVersion(
                schema.Id,
                "bar",
                new DocumentHash("baz", "baz", HashFormat.Hex),
                new[]
            {
                new Tag("a", "b", DateTime.UtcNow)
            },
                DateTime.UtcNow);
            await repository.AddSchemaVersionAsync(a);

            var b = new SchemaVersion(
                schema.Id,
                "baz",
                new DocumentHash("baz", "baz", HashFormat.Hex),
                new[]
            {
                new Tag("a", "b", DateTime.UtcNow)
            },
                DateTime.UtcNow);
            await repository.AddSchemaVersionAsync(b);

            // act
            IReadOnlyDictionary <Guid, SchemaVersion> retrieved =
                await repository.GetSchemaVersionsAsync(new[] { a.Id, b.Id });

            // assert
            Assert.True(retrieved.ContainsKey(a.Id));
            Assert.True(retrieved.ContainsKey(b.Id));
        }