Ejemplo n.º 1
0
        public async Task SetPublishedSchema()
        {
            // 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 initial = new PublishedSchema(
                Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());

            // act
            await repository.SetPublishedSchemaAsync(initial);

            // assert
            PublishedSchema retrieved = await publishedSchemas.AsQueryable().SingleOrDefaultAsync();

            Assert.NotNull(retrieved);
            Assert.Equal(initial.Id, retrieved.Id);
            Assert.Equal(initial.EnvironmentId, retrieved.EnvironmentId);
            Assert.Equal(initial.SchemaId, retrieved.SchemaId);
            Assert.Equal(initial.SchemaVersionId, retrieved.SchemaVersionId);
        }