public void Should_replace_edge_with_ifMatch()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db
.Document
.CreateEdge(Database.TestEdgeCollectionName, _documents[0].ID(), _documents[1].ID(), document);
document.Merge(createResult.Value);
var newDocument = new Dictionary<string, object>()
.From(_documents[0].ID())
.To(_documents[1].ID())
.String("foo", "some other new string")
.Int("baz", 54321);
var replaceResult = db
.Document
.IfMatch(document.Rev())
.Replace(createResult.Value.ID(), newDocument);
Assert.AreEqual(202, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.AreEqual(replaceResult.Value.ID(), document.ID());
Assert.AreEqual(replaceResult.Value.Key(), document.Key());
Assert.AreNotEqual(replaceResult.Value.Rev(), document.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"), document.String("foo"));
Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo"));
Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz"));
Assert.IsFalse(getResult.Value.Has("bar"));
}