public async Task RetriesIfCannotFind() { string itemId = "1"; object partitionKey = "1"; List <KeyValuePair <string, DocumentServiceLease> > state = new List <KeyValuePair <string, DocumentServiceLease> >(); DocumentServiceLeaseCore leaseToUpdate = new DocumentServiceLeaseCore(); ConcurrentDictionary <string, DocumentServiceLease> container = new ConcurrentDictionary <string, DocumentServiceLease>(state); DocumentServiceLeaseUpdaterInMemory updater = new DocumentServiceLeaseUpdaterInMemory(container); DocumentServiceLease updatedLease = await updater.UpdateLeaseAsync(leaseToUpdate, itemId, partitionKey, serverLease => { serverLease.Owner = "newHost"; return(serverLease); }); }
public async Task UpdatesLease() { string itemId = "1"; string partitionKey = "1"; List <KeyValuePair <string, DocumentServiceLease> > state = new List <KeyValuePair <string, DocumentServiceLease> >() { new KeyValuePair <string, DocumentServiceLease>(itemId, new DocumentServiceLeaseCore()) }; DocumentServiceLeaseCore leaseToUpdate = new DocumentServiceLeaseCore(); ConcurrentDictionary <string, DocumentServiceLease> container = new ConcurrentDictionary <string, DocumentServiceLease>(state); DocumentServiceLeaseUpdaterInMemory updater = new DocumentServiceLeaseUpdaterInMemory(container); DocumentServiceLease updatedLease = await updater.UpdateLeaseAsync(leaseToUpdate, itemId, new Cosmos.PartitionKey(partitionKey), serverLease => { serverLease.Owner = "newHost"; return(serverLease); }); Assert.AreEqual("newHost", updatedLease.Owner); }