Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
		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");
		}
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
            }
        }
Exemplo n.º 5
0
        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)));
        }
Exemplo n.º 6
0
 public Task <JsonDocumentMetadata> HeadAsync(string key)
 {
     return(new CompletedTask <JsonDocumentMetadata>(databaseCommands.Head(key)));
 }
Exemplo n.º 7
0
        public static bool DocumentExists(this IDatabaseCommands databaseCommands, string key)
        {
            var metadata = databaseCommands.Head(key);

            return(metadata != null);
        }