本文整理汇总了C#中System.Collections.Dictionary.SetRevID方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.SetRevID方法的具体用法?C# Dictionary.SetRevID怎么用?C# Dictionary.SetRevID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.SetRevID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPusherDeletedDoc
public void TestPusherDeletedDoc()
{
if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
{
Assert.Inconclusive("Replication tests disabled.");
return;
}
using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
var remote = remoteDb.RemoteUri;
var docIdTimestamp = Convert.ToString((ulong)DateTime.UtcNow.TimeSinceEpoch().TotalMilliseconds);
// Create some documentsConvert
var documentProperties = new Dictionary<string, object>();
var doc1Id = string.Format("doc1-{0}", docIdTimestamp);
documentProperties["_id"] = doc1Id;
documentProperties["foo"] = 1;
documentProperties["bar"] = false;
var body = new Body(documentProperties);
var rev1 = new RevisionInternal(body);
rev1 = database.PutRevision(rev1, null, false);
documentProperties.SetRevID(rev1.RevID);
documentProperties["UPDATED"] = true;
documentProperties["_deleted"] = true;
database.PutRevision(new RevisionInternal(documentProperties), rev1.RevID, false);
var repl = database.CreatePushReplication(remote);
if (!IsSyncGateway(remote)) {
((Pusher)repl).CreateTarget = true;
}
RunReplication(repl);
Assert.IsNull(repl.LastError);
// make sure doc1 is deleted
var replicationUrlTrailing = new Uri(string.Format("{0}/", remote));
var pathToDoc = new Uri(replicationUrlTrailing, doc1Id);
WriteDebug("Send http request to " + pathToDoc);
var httpRequestDoneSignal = new CountdownEvent(1);
using (var httpclient = new HttpClient()) {
try {
var getDocResponse = httpclient.GetAsync(pathToDoc.ToString()).Result;
var statusLine = getDocResponse.StatusCode;
WriteDebug("statusLine " + statusLine);
Assert.AreEqual(Couchbase.Lite.StatusCode.NotFound, statusLine.GetStatusCode());
}
catch (ProtocolViolationException e) {
Assert.IsNull(e, "Got ClientProtocolException: " + e.Message);
}
catch (IOException e) {
Assert.IsNull(e, "Got IOException: " + e.Message);
}
finally {
httpRequestDoneSignal.Signal();
}
WriteDebug("Waiting for http request to finish");
try {
httpRequestDoneSignal.Wait(TimeSpan.FromSeconds(10));
WriteDebug("http request finished");
}
catch (Exception e) {
Console.WriteLine("Exception during TestPusherDeletedDoc", e);
}
}
}
}
示例2: TestPusher
public void TestPusher()
{
if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
{
Assert.Inconclusive("Replication tests disabled.");
return;
}
using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
var remote = remoteDb.RemoteUri;
var docIdTimestamp = Convert.ToString((ulong)DateTime.UtcNow.TimeSinceEpoch().TotalMilliseconds);
// Create some documents:
var documentProperties = new Dictionary<string, object>();
var doc1Id = string.Format("doc1-{0}", docIdTimestamp);
documentProperties["_id"] = doc1Id;
documentProperties["foo"] = 1;
documentProperties["bar"] = false;
var body = new Body(documentProperties);
var rev1 = new RevisionInternal(body);
rev1 = database.PutRevision(rev1, null, false);
documentProperties.SetRevID(rev1.RevID);
documentProperties["UPDATED"] = true;
database.PutRevision(new RevisionInternal(documentProperties), rev1.RevID, false);
documentProperties = new Dictionary<string, object>();
var doc2Id = string.Format("doc2-{0}", docIdTimestamp);
documentProperties["_id"] = doc2Id;
documentProperties["baz"] = 666;
documentProperties["fnord"] = true;
database.PutRevision(new RevisionInternal(documentProperties), null, false);
var doc2 = database.GetDocument(doc2Id);
var doc2UnsavedRev = doc2.CreateRevision();
var attachmentStream = GetAsset("attachment.png");
doc2UnsavedRev.SetAttachment("attachment_testPusher.png", "image/png", attachmentStream);
var doc2Rev = doc2UnsavedRev.Save();
doc2UnsavedRev.Dispose();
attachmentStream.Dispose();
Assert.IsNotNull(doc2Rev);
const bool continuous = false;
var repl = database.CreatePushReplication(remote);
repl.Continuous = continuous;
if (!IsSyncGateway(remote)) {
repl.CreateTarget = true;
}
// Check the replication's properties:
Assert.AreEqual(database, repl.LocalDatabase);
Assert.AreEqual(remote, repl.RemoteUrl);
Assert.IsFalse(repl.IsPull);
Assert.IsFalse(repl.Continuous);
Assert.IsNull(repl.Filter);
Assert.IsNull(repl.FilterParams);
Assert.IsNull(repl.DocIds);
// TODO: CAssertNil(r1.headers); still not null!
// Check that the replication hasn't started running:
Assert.IsFalse(repl.IsRunning);
Assert.AreEqual(ReplicationStatus.Stopped, repl.Status);
Assert.AreEqual(0, repl.CompletedChangesCount);
Assert.AreEqual(0, repl.ChangesCount);
Assert.IsNull(repl.LastError);
RunReplication(repl);
// TODO: Verify the foloowing 2 asserts. ChangesCount and CompletedChangesCount
// should already be reset when the replicator stopped.
Assert.IsNull(repl.LastError);
Assert.IsTrue(repl.ChangesCount >= 2);
Assert.IsTrue(repl.CompletedChangesCount >= 2);
remoteDb.VerifyDocumentExists(doc1Id);
// Add doc3
documentProperties = new Dictionary<string, object>();
var doc3Id = string.Format("doc3-{0}", docIdTimestamp);
var doc3 = database.GetDocument(doc3Id);
documentProperties["bat"] = 677;
doc3.PutProperties(documentProperties);
// re-run push replication
var repl2 = database.CreatePushReplication(remote);
repl2.Continuous = continuous;
if (!IsSyncGateway(remote)) {
repl2.CreateTarget = true;
}
var repl2CheckedpointId = repl2.RemoteCheckpointDocID();
RunReplication(repl2);
Assert.IsNull(repl2.LastError);
Sleep(1000);
//.........这里部分代码省略.........