public void GivenAResourceWrapper_WhenConvertingToAHistoryObject_ThenTheCorrectPropertiesAreUpdated() { var wrapper = Samples.GetJsonSample <CosmosResourceWrapper>("ResourceWrapperNoVersion"); var id = wrapper.Id; var lastModified = new DateTimeOffset(2017, 1, 1, 1, 1, 1, TimeSpan.Zero); var historyRecord = new CosmosResourceWrapper( id, "version1", wrapper.ResourceTypeName, wrapper.RawResource, wrapper.Request, lastModified, wrapper.IsDeleted, true, null, null, null); Assert.Equal($"{id}_{historyRecord.Version}", historyRecord.Id); Assert.Equal(lastModified, historyRecord.LastModified); Assert.True(historyRecord.IsHistory); Assert.Equal("version1", historyRecord.Version); }
public async Task <UpsertWithHistoryModel> Execute(IDocumentClient client, Uri collection, CosmosResourceWrapper resource, string matchVersionId, bool allowCreate, bool keepHistory) { EnsureArg.IsNotNull(client, nameof(client)); EnsureArg.IsNotNull(collection, nameof(collection)); EnsureArg.IsNotNull(resource, nameof(resource)); StoredProcedureResponse <UpsertWithHistoryModel> results = await ExecuteStoredProc <UpsertWithHistoryModel>(client, collection, resource.PartitionKey, resource, matchVersionId, allowCreate, keepHistory); return(results.Response); }