public void AddOrUpdate_WhenExists_ShouldUpdate() { var first = new PrimaryKeyObject { Id = 1, StringValue = "first" }; _realm.Write(() => { _realm.Add(first, update: true); }); var second = new PrimaryKeyObject { Id = 1, StringValue = "second" }; _realm.Write(() => { _realm.Add(second, update: true); }); var queried = _realm.Find <PrimaryKeyObject>(1); Assert.That(queried.StringValue, Is.EqualTo("second")); Assert.That(first.StringValue, Is.EqualTo("second")); Assert.That(second.StringValue, Is.EqualTo("second")); }
public void AddOrUpdate_WhenExists_ShouldUpdate() { var first = new PrimaryKeyObject { Id = 1, StringValue = "first" }; _realm.Write(() => { _realm.Add(first, update: true); }); var second = new PrimaryKeyObject { Id = 1, StringValue = "second" }; _realm.Write(() => { _realm.Add(second, update: true); }); var queried = _realm.Find<PrimaryKeyObject>(1); Assert.That(queried.StringValue, Is.EqualTo("second")); Assert.That(first.StringValue, Is.EqualTo("second")); Assert.That(second.StringValue, Is.EqualTo("second")); }
public void AddOrUpdate_ShouldReturnManaged() { PrimaryKeyObject item = null; _realm.Write(() => { item = _realm.Add(new PrimaryKeyObject { Id = 1, StringValue = "1" }, update: true); }); Assert.That(item.IsManaged); Assert.That(item.StringValue == "1"); }
public void AddOrUpdate_WhenDoesntExist_ShouldAdd() { var standalone = new PrimaryKeyObject { Id = 1, StringValue = "bla" }; _realm.Write(() => { _realm.Add(standalone, update: true); }); Assert.That(standalone.IsManaged, Is.True); var queried = _realm.Find<PrimaryKeyObject>(1); Assert.That(queried, Is.EqualTo(standalone)); }
public void AddOrUpdate_WhenDoesntExist_ShouldAdd() { var standalone = new PrimaryKeyObject { Id = 1, StringValue = "bla" }; _realm.Write(() => { _realm.Add(standalone, update: true); }); Assert.That(standalone.IsManaged, Is.True); var queried = _realm.Find <PrimaryKeyObject>(1); Assert.That(queried, Is.EqualTo(standalone)); }
public void AddOrUpdate_ShouldReturnPassedInObject() { var first = new PrimaryKeyObject { Id = 1, StringValue = "1" }; PrimaryKeyObject firstAdded = null; _realm.Write(() => { firstAdded = _realm.Add(first, update: true); }); Assert.That(firstAdded, Is.SameAs(first)); var second = new PrimaryKeyObject { Id = 1, StringValue = "2" }; PrimaryKeyObject secondAdded = null; _realm.Write(() => { secondAdded = _realm.Add(second, update: true); }); Assert.That(secondAdded, Is.SameAs(second)); Assert.That(first.StringValue, Is.EqualTo("2")); Assert.That(firstAdded.StringValue, Is.EqualTo("2")); Assert.That(second.StringValue, Is.EqualTo("2")); Assert.That(secondAdded.StringValue, Is.EqualTo("2")); }