protected void WaitForDocument(IDatabaseCommands commands, string expectedId, Etag afterEtag = null, CancellationToken?token = null) { if (afterEtag != null) { throw new NotImplementedException(); } for (int i = 0; i < RetriesCount; i++) { if (token.HasValue) { token.Value.ThrowIfCancellationRequested(); } if (commands.Head(expectedId) != null) { break; } Thread.Sleep(100); } var jsonDocumentMetadata = commands.Head(expectedId); Assert.NotNull(jsonDocumentMetadata); }
private static void WaitForDocument(IDatabaseCommands commands, string expectedId) { for (int i = 0; i < RetriesCount; i++) { if (commands.Head(expectedId) != null) break; Thread.Sleep(100); } if(commands.Head(expectedId) == null) throw new Exception("Document not replicated"); }
protected override void WaitForDocument(IDatabaseCommands commands, string expectedId) { for (int i = 0; i < RetriesCount; i++) { if (commands.Head(expectedId) != null) { break; } Thread.Sleep(100); } var jsonDocumentMetadata = commands.Head(expectedId); Assert.NotNull(jsonDocumentMetadata); }
private static void WaitForDocument(IDatabaseCommands commands, string expectedId) { for (int i = 0; i < RetriesCount; i++) { if (commands.Head(expectedId) != null) { break; } Thread.Sleep(100); } if (commands.Head(expectedId) == null) { throw new Exception("Document not replicated"); } }
protected bool WaitForDocument(IDatabaseCommands commands, string expectedId, int timeoutInMs) { var cts = new CancellationTokenSource(); var waitingTask = Task.Run(() => WaitForDocument(commands, expectedId, null, cts.Token), cts.Token); Task.WaitAny(waitingTask, Task.Delay(timeoutInMs, cts.Token)); cts.Cancel(); return(AsyncHelpers.RunSync(() => waitingTask.ContinueWith(t => commands.Head(expectedId) != null))); }
public Task <JsonDocumentMetadata> HeadAsync(string key) { return(new CompletedTask <JsonDocumentMetadata>(databaseCommands.Head(key))); }
public static bool DocumentExists(this IDatabaseCommands databaseCommands, string key) { var metadata = databaseCommands.Head(key); return(metadata != null); }