public void RealmValue_WhenCastingIsWrong_ThrowsException() { RealmValue rv = 10; Assert.That(() => rv.AsString(), Throws.Exception.TypeOf <InvalidCastException>()); Assert.That(() => rv.AsFloat(), Throws.Exception.TypeOf <InvalidCastException>()); rv = Guid.NewGuid().ToString(); Assert.That(() => rv.AsInt16(), Throws.Exception.TypeOf <InvalidCastException>()); Assert.That(() => rv.AsGuid(), Throws.Exception.TypeOf <InvalidCastException>()); rv = true; Assert.That(() => rv.AsInt16(), Throws.Exception.TypeOf <InvalidCastException>()); }
public void StringTests(string value, bool isManaged) { RealmValue rv = value; if (isManaged) { var retrievedObject = PersistAndFind(rv); rv = retrievedObject.RealmValueProperty; } Assert.That(rv == value); Assert.That(rv.Type, Is.EqualTo(RealmValueType.String)); Assert.That((string)rv == value); Assert.That(rv.As <string>() == value); Assert.That(rv.AsString() == value); Assert.That(rv != RealmValue.Null); }