public void RunNumericTests(RealmValue rv, long value, bool isManaged) { if (isManaged) { var retrievedObject = PersistAndFind(rv); rv = retrievedObject.RealmValueProperty; } Assert.That(rv == value); Assert.That(rv.Type, Is.EqualTo(RealmValueType.Int)); Assert.That(rv != RealmValue.Null); // 8 - byte var byteValue = (byte)value; Assert.That((byte)rv == byteValue); Assert.That(rv.As <byte>() == byteValue); Assert.That((byte?)rv == byteValue); Assert.That(rv.As <byte?>() == byteValue); Assert.That(rv.AsByte() == byteValue); Assert.That(rv.AsNullableByte() == byteValue); Assert.That(rv.AsByteRealmInteger() == byteValue); Assert.That(rv.AsNullableByteRealmInteger() == byteValue); // 16 - short var shortValue = (short)value; Assert.That((short)rv == shortValue); Assert.That(rv.As <short>() == shortValue); Assert.That((short?)rv == shortValue); Assert.That(rv.As <short?>() == shortValue); Assert.That(rv.AsInt16() == shortValue); Assert.That(rv.AsNullableInt16() == shortValue); Assert.That(rv.AsInt16RealmInteger() == shortValue); Assert.That(rv.AsNullableInt16RealmInteger() == shortValue); // 32 - int var intValue = (int)value; Assert.That((int)rv == intValue); Assert.That(rv.As <int>() == intValue); Assert.That((int?)rv == intValue); Assert.That(rv.As <int?>() == intValue); Assert.That(rv.AsInt32() == intValue); Assert.That(rv.AsNullableInt32() == intValue); Assert.That(rv.AsInt32RealmInteger() == intValue); Assert.That(rv.AsNullableInt32RealmInteger() == intValue); // 64 - long Assert.That((long)rv == value); Assert.That(rv.As <long>() == value); Assert.That((long?)rv == value); Assert.That(rv.As <long?>() == value); Assert.That(rv.AsInt64() == value); Assert.That(rv.AsNullableInt64() == value); Assert.That(rv.AsInt64RealmInteger() == value); Assert.That(rv.AsNullableInt64RealmInteger() == value); }
public void GuidTests(Guid 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.Guid)); Assert.That((Guid)rv == value); Assert.That(rv.As <Guid>() == value); Assert.That((Guid?)rv == value); Assert.That(rv.As <Guid?>() == value); Assert.That(rv.AsGuid() == value); Assert.That(rv.AsNullableGuid() == value); Assert.That(rv != RealmValue.Null); }
public void DateTests(DateTimeOffset 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.Date)); Assert.That((DateTimeOffset)rv == value); Assert.That(rv.As <DateTimeOffset>() == value); Assert.That((DateTimeOffset?)rv == value); Assert.That(rv.As <DateTimeOffset?>() == value); Assert.That(rv.AsDate() == value); Assert.That(rv.AsNullableDate() == value); Assert.That(rv != RealmValue.Null); }
public void BoolTests(bool 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.Bool)); Assert.That((bool)rv == value); Assert.That(rv.As <bool>() == value); Assert.That((bool?)rv == value); Assert.That(rv.As <bool?>() == value); Assert.That(rv.AsBool() == value); Assert.That(rv.AsNullableBool() == value); Assert.That(rv != RealmValue.Null); }
public void DecimalTests(decimal 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.Decimal128)); Assert.That((decimal)rv == value); Assert.That(rv.As <decimal>() == value); Assert.That((decimal?)rv == value); Assert.That(rv.As <decimal?>() == value); Assert.That(rv.AsDecimal() == value); Assert.That(rv.AsNullableDecimal() == value); Assert.That(rv != RealmValue.Null); }
public void DoubleTests(double 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.Double)); Assert.That((double)rv == value); Assert.That(rv.As <double>() == value); Assert.That((double?)rv == value); Assert.That(rv.As <double?>() == value); Assert.That(rv.AsDouble() == value); Assert.That(rv.AsNullableDouble() == value); Assert.That(rv != RealmValue.Null); }
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); }
public void ObjectTests(RealmObjectBase value, bool isManaged) { RealmValue rv = value; if (isManaged) { var retrievedObject = PersistAndFind(rv); rv = retrievedObject.RealmValueProperty; } Assert.That(rv.Type, Is.EqualTo(RealmValueType.Object)); Assert.That((RealmObjectBase)rv, Is.EqualTo(value)); Assert.That(rv.As <RealmObjectBase>(), Is.EqualTo(value)); Assert.That(rv.AsRealmObject(), Is.EqualTo(value)); Assert.That(rv != RealmValue.Null); }
public void DataTests(byte[] value, bool isManaged) { RealmValue rv = value; if (isManaged) { var retrievedObject = PersistAndFind(rv); rv = retrievedObject.RealmValueProperty; } Assert.That(rv.Type, Is.EqualTo(RealmValueType.Data)); Assert.That((byte[])rv, Is.EqualTo(value)); Assert.That(rv.As <byte[]>(), Is.EqualTo(value)); Assert.That(rv.AsData(), Is.EqualTo(value)); Assert.That(rv != RealmValue.Null); }
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); }