-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,61 @@ public void List_AfterCreation_CanBeReassigned([Values(true, false)] bool isMana | |
Assert.AreEqual(updatedList.AsList().Count, actual.Count); | ||
} | ||
|
||
[Test] | ||
public void List_AfterCreation_EmbeddedListCanBeReassigned([Values(true, false)] bool isManaged) | ||
{ | ||
var embeddedList = new List<RealmValue>{ new List<RealmValue>{1, 2, 3}}; | ||
var rvo = new RealmValueObject { RealmValueProperty = new List<RealmValue>{ embeddedList} }; | ||
|
||
if (isManaged) | ||
{ | ||
_realm.Write(() => | ||
{ | ||
_realm.Add(rvo); | ||
}); | ||
} | ||
|
||
var actualEmbedded = rvo.RealmValueProperty.AsList()[0].AsList(); | ||
Assert.AreEqual(embeddedList.Count, actualEmbedded.Count); | ||
|
||
var updatedList = (RealmValue)new List<RealmValue>{4, 5, 6}; | ||
_realm.Write(() => | ||
{ | ||
rvo.RealmValueProperty.AsList()[0] = updatedList; | ||
}); | ||
|
||
actualEmbedded = rvo.RealmValueProperty.AsList()[0].AsList(); | ||
Assert.AreEqual(updatedList.AsList().Count, actualEmbedded.Count); | ||
} | ||
|
||
[Test] | ||
public void List_AfterCreation_EmbeddedDictionaryCanBeReassigned([Values(true, false)] bool isManaged) | ||
{ | ||
var embeddedDictionary = new Dictionary<string, RealmValue>{{ "key1", 1}}; | ||
var rvo = new RealmValueObject { RealmValueProperty = new List<RealmValue>{ embeddedDictionary} }; | ||
|
||
if (isManaged) | ||
{ | ||
_realm.Write(() => | ||
{ | ||
_realm.Add(rvo); | ||
}); | ||
} | ||
|
||
var actualEmbedded = rvo.RealmValueProperty.AsList()[0].AsDictionary(); | ||
Assert.AreEqual(embeddedDictionary.Count, actualEmbedded.Count); | ||
|
||
var updatedDictionary = new Dictionary<string, RealmValue>{{ "key2", 2}}; | ||
_realm.Write(() => | ||
{ | ||
rvo.RealmValueProperty.AsList()[0] = updatedDictionary; | ||
}); | ||
|
||
actualEmbedded = rvo.RealmValueProperty.AsList()[0].AsDictionary(); | ||
Assert.AreEqual(updatedDictionary.Count, actualEmbedded.Count); | ||
} | ||
|
||
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, linux-x64
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / .NET Framework
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win-x64
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Woven classes
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win81
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-x64
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-arm64
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Maui.MacCatalyst
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / UWP
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Maui.iOS
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Maui.Android
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Code Coverage
Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
|
||
|
||
[Test] | ||
public void List_WhenManaged_CanBeModified() | ||
{ | ||
|
@@ -678,6 +733,88 @@ public void Dictionary_AfterCreation_CanBeAssigned([Values(true, false)] bool is | |
Assert.That(rvo.RealmValueProperty == newStringVal); | ||
} | ||
|
||
[Test] | ||
public void Dictionary_AfterCreation_CanBeReassigned([Values(true, false)] bool isManaged) | ||
{ | ||
var initialDictionary = (RealmValue) new Dictionary<string, RealmValue> { {"key1" , 1 } }; | ||
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, linux-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, linux-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / .NET Framework
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / .NET Framework
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Woven classes
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Woven classes
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win81
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win81
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-x64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.tvOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.tvOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.tvOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-arm64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-arm64
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.macOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.macOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.macOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.iOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.iOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.iOS
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / UWP
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / UWP
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Code Coverage
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Code Coverage
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
|
||
var rvo = new RealmValueObject { RealmValueProperty = initialDictionary }; | ||
|
||
if (isManaged) | ||
{ | ||
_realm.Write(() => | ||
{ | ||
_realm.Add(rvo); | ||
}); | ||
} | ||
|
||
var actual = rvo.RealmValueProperty.AsDictionary(); | ||
Assert.AreEqual(initialDictionary.AsDictionary().Count, actual.Count); | ||
|
||
var updatedDictionary = (RealmValue) new Dictionary<string, RealmValue> { {"key2" , 2 } }; | ||
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, linux-x64
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / .NET Framework
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win-x64
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Woven classes
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win81
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-x64
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.tvOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.tvOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-arm64
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.macOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.macOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.iOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.iOS
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / UWP
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Code Coverage
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
|
||
_realm.Write(() => | ||
{ | ||
rvo.RealmValueProperty = updatedDictionary; | ||
}); | ||
|
||
actual = rvo.RealmValueProperty.AsDictionary(); | ||
Assert.AreEqual(updatedDictionary.AsDictionary().Count, actual.Count); | ||
} | ||
|
||
[Test] | ||
public void Dictionary_AfterCreation_EmbeddedListCanBeReassigned([Values(true, false)] bool isManaged) | ||
{ | ||
var embeddedList = new List<RealmValue>{ new List<RealmValue>{1, 2, 3}}; | ||
var rvo = new RealmValueObject { RealmValueProperty = new Dictionary<string, RealmValue>{ { "key", embeddedList}} }; | ||
|
||
if (isManaged) | ||
{ | ||
_realm.Write(() => | ||
{ | ||
_realm.Add(rvo); | ||
}); | ||
} | ||
|
||
var actualEmbedded = rvo.RealmValueProperty.AsDictionary()["key"].AsList(); | ||
Assert.AreEqual(embeddedList.Count, actualEmbedded.Count); | ||
|
||
var updatedList = (RealmValue)new List<RealmValue>{4, 5, 6}; | ||
_realm.Write(() => | ||
{ | ||
rvo.RealmValueProperty.AsDictionary()["key"] = updatedList; | ||
}); | ||
|
||
actualEmbedded = rvo.RealmValueProperty.AsDictionary()["key"].AsList(); | ||
Assert.AreEqual(updatedList.AsList().Count, actualEmbedded.Count); | ||
} | ||
|
||
[Test] | ||
public void Dict_AfterCreation_EmbeddedDictionaryCanBeReassigned([Values(true, false)] bool isManaged) | ||
{ | ||
var embeddedDictionary = new Dictionary<string, RealmValue>{{ "key1", 1}}; | ||
var rvo = new RealmValueObject { RealmValueProperty = new Dictionary<string, RealmValue>{ { "key", embeddedDictionary} } }; | ||
|
||
if (isManaged) | ||
{ | ||
_realm.Write(() => | ||
{ | ||
_realm.Add(rvo); | ||
}); | ||
} | ||
|
||
var actualEmbedded = rvo.RealmValueProperty.AsDictionary()["key"].AsDictionary(); | ||
Assert.AreEqual(embeddedDictionary.Count, actualEmbedded.Count); | ||
|
||
var updatedDictionary = new Dictionary<string, RealmValue>{{ "key2", 2}}; | ||
_realm.Write(() => | ||
{ | ||
rvo.RealmValueProperty.AsDictionary()["key"] = updatedDictionary; | ||
}); | ||
|
||
actualEmbedded = rvo.RealmValueProperty.AsDictionary()["key"].AsDictionary(); | ||
Assert.AreEqual(updatedDictionary.Count, actualEmbedded.Count); | ||
} | ||
|
||
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, linux-x64
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Package / Unity
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / .NET Framework
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win-x64
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Woven classes
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, win81
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-x64
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / net7.0, osx-arm64
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / UWP
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Code Coverage
Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs GitHub Actions / Test / Xamarin.Android
|
||
|
||
[Test] | ||
public void Dictionary_WhenManaged_CanBeModified() | ||
{ | ||
|
@@ -985,7 +1122,7 @@ public void IndexedRealmValue_WithCollection_BasicTest() | |
|
||
#endregion | ||
|
||
private class RealmValueComparer : IEqualityComparer<RealmValue> | ||
internal class RealmValueComparer : IEqualityComparer<RealmValue> | ||
{ | ||
public bool Equals(RealmValue x, RealmValue y) | ||
{ | ||
|