Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe committed Sep 25, 2023
1 parent 2fdefc7 commit cdeaa4c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion Tests/Realm.Tests/Database/RealmValueWithCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void List_WhenManaged_CanBeModified()
}

[Test]
public void List_AddSetInsertList_WorksAsIntended()
public void List_AddSetInsertMoveRemoveList_WorksAsIntended()
{
var listVal = new List<RealmValue> { 1, "string", true };

Expand All @@ -222,6 +222,7 @@ public void List_AddSetInsertList_WorksAsIntended()

var innerList1 = new List<RealmValue> { "inner", 23, false };

// Indexer
_realm.Write(() =>
{
rvo.RealmValueProperty.AsList()[1] = innerList1;
Expand All @@ -230,6 +231,7 @@ public void List_AddSetInsertList_WorksAsIntended()

Assert.That(rvo.RealmValueProperty.AsList(), Is.EqualTo(listVal));

// Insert
var innerList2 = new List<RealmValue> { "inner2", 23, false };

_realm.Write(() =>
Expand All @@ -240,6 +242,7 @@ public void List_AddSetInsertList_WorksAsIntended()

Assert.That(rvo.RealmValueProperty.AsList(), Is.EqualTo(listVal));

// Add
var innerList3 = new List<RealmValue> { "inner3", 23, false };

_realm.Write(() =>
Expand All @@ -249,6 +252,40 @@ public void List_AddSetInsertList_WorksAsIntended()
});

Assert.That(rvo.RealmValueProperty.AsList(), Is.EqualTo(listVal));

// Move
_realm.Write(() =>
{
rvo.RealmValueProperty.AsList().Move(0, 1);
listVal.Move(0, 1);
});

Assert.That(rvo.RealmValueProperty.AsList(), Is.EqualTo(listVal));

// Remove
_realm.Write(() =>
{
rvo.RealmValueProperty.AsList().RemoveAt(2);
listVal.RemoveAt(2);
});

Assert.That(rvo.RealmValueProperty.AsList(), Is.EqualTo(listVal));
}

public void List_RemoveWithListArgument_ReturnsFalse()
{
var innerListVal = new List<RealmValue> { 1, "string", true };
var listVal = new List<RealmValue> { innerListVal, 23 };

var rvo = _realm.Write(() =>
{
return _realm.Add(new RealmValueObject { RealmValueProperty = listVal });
});

_realm.Write(() =>
{
Assert.That(rvo.RealmValueProperty.AsList().Remove(innerListVal), Is.False);
});
}

[Test]
Expand Down

0 comments on commit cdeaa4c

Please sign in to comment.