Skip to content

Commit

Permalink
More testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rorbech committed Mar 15, 2024
1 parent 9b20f97 commit a7aef39
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 230 deletions.
139 changes: 138 additions & 1 deletion Tests/Realm.Tests/Database/RealmValueWithCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Code should not contain multiple blank lines in a row [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.MacCatalyst

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.iOS

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Maui.Android

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 336 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

[Test]
public void List_WhenManaged_CanBeModified()
{
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Operator '(RealmValue)' should not be followed by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1003.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Commas should not be preceded by whitespace. [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Closing parenthesis should not be followed by a space [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Commas should not be preceded by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Commas should not be preceded by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Commas should not be preceded by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Operator '(RealmValue)' should not be followed by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1003.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 739 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]
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

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Commas should not be preceded by whitespace. [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.tvOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.macOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Operator '(RealmValue)' should not be followed by whitespace. [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.iOS

Closing parenthesis should not be followed by a space [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Operator '(RealmValue)' should not be followed by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1003.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Commas should not be preceded by whitespace. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 753 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Closing parenthesis should not be followed by a space (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]
_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

View workflow job for this annotation

GitHub Actions / Test / net7.0, linux-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Package / Unity

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / .NET Framework

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net461]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Woven classes

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, win81

Code should not contain multiple blank lines in a row [C:\run\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-x64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / net7.0, osx-arm64

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/Users/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / UWP

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Code Coverage

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [/home/runner/work/realm-dotnet/realm-dotnet/Tests/Realm.Tests/Realm.Tests.csproj::TargetFramework=net7.0]

Check warning on line 816 in Tests/Realm.Tests/Database/RealmValueWithCollections.cs

View workflow job for this annotation

GitHub Actions / Test / Xamarin.Android

Code should not contain multiple blank lines in a row (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) [D:\a\realm-dotnet\realm-dotnet\Tests\Realm.Tests\Realm.Tests.csproj::TargetFramework=netstandard2.0]

[Test]
public void Dictionary_WhenManaged_CanBeModified()
{
Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit a7aef39

Please sign in to comment.