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 FloatTests(float 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.Float)); Assert.That((float)rv == value); Assert.That(rv.As <float>() == value); Assert.That((float?)rv == value); Assert.That(rv.As <float?>() == value); Assert.That(rv.AsFloat() == value); Assert.That(rv.AsNullableFloat() == value); Assert.That(rv != RealmValue.Null); }