public async Task UpdateSchemaVersion() { // arrange IMongoCollection <Schema> schemas = _mongoResource.CreateCollection <Schema>(); IMongoCollection <SchemaVersion> versions = _mongoResource.CreateCollection <SchemaVersion>(); IMongoCollection <SchemaPublishReport> publishReports = _mongoResource.CreateCollection <SchemaPublishReport>(); var repository = new SchemaRepository(schemas, versions, publishReports); var schema = new Schema("foo", "bar"); await repository.AddSchemaAsync(schema); var schemaVersion = new SchemaVersion( schema.Id, "bar", "baz", new[] { new Tag("a", "b", DateTime.UtcNow) }, DateTime.UtcNow); await repository.AddSchemaVersionAsync(schemaVersion); var updatedSchemaVersion = new SchemaVersion( schemaVersion.Id, schema.Id, "baz", "qux", new[] { new Tag("a", "b", DateTime.UtcNow) }, DateTime.UtcNow); // act await repository.UpdateSchemaVersionAsync(updatedSchemaVersion); // assert SchemaVersion retrieved = await versions.AsQueryable() .Where(t => t.Id == schemaVersion.Id) .FirstOrDefaultAsync(); Assert.NotNull(retrieved); Assert.Equal(schemaVersion.Id, retrieved.Id); Assert.Equal(schemaVersion.Published, retrieved.Published, TimeSpan.FromSeconds(1)); Assert.Equal(schemaVersion.SchemaId, retrieved.SchemaId); Assert.Equal(updatedSchemaVersion.SourceText, retrieved.SourceText); Assert.Equal(updatedSchemaVersion.Hash, retrieved.Hash); Assert.Equal(updatedSchemaVersion.Tags.Count, retrieved.Tags.Count); }