public void Should_replace_document()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db.Document
.Replace(documents[0].ID(), document);
Assert.AreEqual(202, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.ID(), documents[0].ID());
Assert.AreEqual(replaceResult.Value.Key(), documents[0].Key());
Assert.AreNotEqual(replaceResult.Value.Rev(), documents[0].Rev());
var getResult = db.Document
.Get(replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.ID(), replaceResult.Value.ID());
Assert.AreEqual(getResult.Value.Key(), replaceResult.Value.Key());
Assert.AreEqual(getResult.Value.Rev(), replaceResult.Value.Rev());
Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), document.String("foo"));
Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz"));
Assert.IsFalse(getResult.Value.Has("bar"));
}