Skip to content

Commit

Permalink
Added basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe committed Jun 17, 2024
1 parent da57ca9 commit 38a9800
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions Tests/Realm.Tests/Database/DynamicAccessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,6 @@ public void GetEmbeddedObjectProperty_WhenCastToRealmObject_Throws()
});
}

[Test]
public void GetProperty_WhenPropertyIsMissing_Throws()
{
RunTestInAllModes((realm, _) =>
{
var allTypesObject = realm.Write(() => realm.DynamicApi.CreateObject(nameof(AllTypesObject)));

Assert.Throws<MissingMemberException>(() => allTypesObject.DynamicApi.Get<string>("idontexist"));
});
}

[Test]
public void GetProperty_WhenPropertyIsBacklinks_Throws()
{
Expand Down Expand Up @@ -563,20 +552,6 @@ public void SetProperty_WhenUsingConvertibleType_Succeeds()
});
}

[Test]
public void SetProperty_WhenPropertyIsMissing_Throws()
{
RunTestInAllModes((realm, _) =>
{
realm.Write(() =>
{
var ato = realm.DynamicApi.CreateObject(nameof(AllTypesObject));

Assert.Throws<MissingMemberException>(() => ato.DynamicApi.Set("idontexist", "foo"));
});
});
}

[Test]
public void SetProperty_WhenPropertyIsBacklinks_Throws()
{
Expand Down Expand Up @@ -1003,6 +978,29 @@ public void GetDictionary_WhenCastToWrongValue_Throws()

#endregion

#region Flexible schema

[Test]
public void FlexibleSchema_BaseTest()
{
var person = _realm.Write(() =>
{
return _realm.Add(new Person());
});

_realm.Write(() =>
{
person.DynamicApi.Set("prop1", "testval");
person.DynamicApi.Set("prop2", 10);

});

Assert.That(person.DynamicApi.Get<string>("prop1"), Is.EqualTo("testval"));
Assert.That(person.DynamicApi.Get<int>("prop2"), Is.EqualTo(10));
}

#endregion

[Test]
public void GetPrimaryKey_WhenPrivate_Works()
{
Expand Down

0 comments on commit 38a9800

Please sign in to comment.