Skip to content

Commit

Permalink
Update tests to use 'As<>()' instead of setting backing storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
elle-j committed Jul 11, 2024
1 parent 11da026 commit 6eb7498
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Tests/Realm.Tests/Database/FlexibleSchemaPocTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,15 @@ public void RealmValue_AsMappedType_WhenTypeIsIncorrect_Throws()
public void AccessMappedTypeProperties_ReadsValuesFromBackingStorage()
{
AddData();
var dogContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Dog));

var dog = new Dog();
dog.SetBackingStorage(dogContainer.MixedDict);
var dogContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Dog));
var dog = dogContainer.MixedProperty.As<Dog>();

Assert.That(dog.Name, Is.EqualTo("Fido"));
Assert.That(dog.BarkCount, Is.EqualTo(5));

var birdContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Bird));

var bird = new Bird();
bird.SetBackingStorage(birdContainer.MixedDict);
var bird = birdContainer.MixedProperty.As<Bird>();

Assert.That(bird.Name, Is.EqualTo("Tweety"));
Assert.That(bird.CanFly, Is.True);
Expand All @@ -113,10 +110,9 @@ public void AccessMappedTypeProperties_WhenNonExistent_Throws()
public void UpdateMappedTypeProperties_WritesValuesToBackingStorage()
{
AddData();
var dogContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Dog));

var dog = new Dog();
dog.SetBackingStorage(dogContainer.MixedDict);
var dogContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Dog));
var dog = dogContainer.MixedProperty.As<Dog>();

_realm.Write(() =>
{
Expand All @@ -127,9 +123,7 @@ public void UpdateMappedTypeProperties_WritesValuesToBackingStorage()
Assert.That(dog.BarkCount, Is.EqualTo(6));

var birdContainer = _realm.All<FlexibleSchemaPocContainer>().First(c => c.ContainedObjectType == nameof(Bird));

var bird = new Bird();
bird.SetBackingStorage(birdContainer.MixedDict);
var bird = birdContainer.MixedProperty.As<Bird>();

_realm.Write(() =>
{
Expand Down

0 comments on commit 6eb7498

Please # to comment.