From 6eb749867a1808909f7c8463183a0cc4aeec6dc7 Mon Sep 17 00:00:00 2001 From: LJ <81748770+elle-j@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:57:22 +0200 Subject: [PATCH] Update tests to use 'As<>()' instead of setting backing storage. --- .../Database/FlexibleSchemaPocTests.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Tests/Realm.Tests/Database/FlexibleSchemaPocTests.cs b/Tests/Realm.Tests/Database/FlexibleSchemaPocTests.cs index a7def00cdd..dd7eccde65 100644 --- a/Tests/Realm.Tests/Database/FlexibleSchemaPocTests.cs +++ b/Tests/Realm.Tests/Database/FlexibleSchemaPocTests.cs @@ -76,18 +76,15 @@ public void RealmValue_AsMappedType_WhenTypeIsIncorrect_Throws() public void AccessMappedTypeProperties_ReadsValuesFromBackingStorage() { AddData(); - var dogContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Dog)); - var dog = new Dog(); - dog.SetBackingStorage(dogContainer.MixedDict); + var dogContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Dog)); + var dog = dogContainer.MixedProperty.As(); Assert.That(dog.Name, Is.EqualTo("Fido")); Assert.That(dog.BarkCount, Is.EqualTo(5)); var birdContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Bird)); - - var bird = new Bird(); - bird.SetBackingStorage(birdContainer.MixedDict); + var bird = birdContainer.MixedProperty.As(); Assert.That(bird.Name, Is.EqualTo("Tweety")); Assert.That(bird.CanFly, Is.True); @@ -113,10 +110,9 @@ public void AccessMappedTypeProperties_WhenNonExistent_Throws() public void UpdateMappedTypeProperties_WritesValuesToBackingStorage() { AddData(); - var dogContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Dog)); - var dog = new Dog(); - dog.SetBackingStorage(dogContainer.MixedDict); + var dogContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Dog)); + var dog = dogContainer.MixedProperty.As(); _realm.Write(() => { @@ -127,9 +123,7 @@ public void UpdateMappedTypeProperties_WritesValuesToBackingStorage() Assert.That(dog.BarkCount, Is.EqualTo(6)); var birdContainer = _realm.All().First(c => c.ContainedObjectType == nameof(Bird)); - - var bird = new Bird(); - bird.SetBackingStorage(birdContainer.MixedDict); + var bird = birdContainer.MixedProperty.As(); _realm.Write(() => {