public void RealmObjectProperties_WhenNotSet_ShouldHaveDefaultValues() { var obj = new AllTypesObject { RequiredStringProperty = string.Empty }; _realm.Write(() => _realm.Add(obj)); Assert.That(obj.ByteArrayProperty, Is.EqualTo(default(byte[]))); Assert.That(obj.StringProperty, Is.EqualTo(default(string))); Assert.That(obj.BooleanProperty, Is.EqualTo(default(bool))); Assert.That(obj.ByteProperty, Is.EqualTo(default(byte))); Assert.That(obj.CharProperty, Is.EqualTo(default(char))); Assert.That(obj.DateTimeOffsetProperty, Is.EqualTo(default(DateTimeOffset))); Assert.That(obj.SingleProperty, Is.EqualTo(default(float))); Assert.That(obj.DoubleProperty, Is.EqualTo(default(double))); Assert.That(obj.Int16Property, Is.EqualTo(default(short))); Assert.That(obj.Int32Property, Is.EqualTo(default(int))); Assert.That(obj.Int64Property, Is.EqualTo(default(long))); Assert.That(obj.NullableBooleanProperty, Is.EqualTo(default(bool?))); Assert.That(obj.NullableByteProperty, Is.EqualTo(default(byte?))); Assert.That(obj.NullableCharProperty, Is.EqualTo(default(char?))); Assert.That(obj.NullableDateTimeOffsetProperty, Is.EqualTo(default(DateTimeOffset?))); Assert.That(obj.NullableSingleProperty, Is.EqualTo(default(float?))); Assert.That(obj.NullableDoubleProperty, Is.EqualTo(default(double?))); Assert.That(obj.NullableInt16Property, Is.EqualTo(default(short?))); Assert.That(obj.NullableInt32Property, Is.EqualTo(default(int?))); Assert.That(obj.NullableInt64Property, Is.EqualTo(default(long?))); }
public void GetPrimaryKey_WhenNotManagedAndDoesNotHavePK_ShouldReturnFalse() { var obj = new AllTypesObject { BooleanProperty = true }; var success = GetHelper(obj.GetType()).TryGetPrimaryKeyValue(obj, out var pk); Assert.That(success, Is.False); Assert.That(pk, Is.Null); }
public void SetAndGetValue(string propertyName, object propertyValue) { AllTypesObject ato = null; _realm.Write(() => { ato = _realm.Add(new AllTypesObject { RequiredStringProperty = string.Empty }); TestHelpers.SetPropertyValue(ato, propertyName, propertyValue); }); Assert.That(TestHelpers.GetPropertyValue(ato, propertyName), Is.EqualTo(propertyValue)); }
public void GetPrimaryKey_WhenManagedAndDoesNotHavePK_ShouldReturnFalse() { var obj = new AllTypesObject { BooleanProperty = true, RequiredStringProperty = string.Empty }; _realm.Write(() => { _realm.Add(obj); }); var success = GetHelper(obj).TryGetPrimaryKeyValue(obj, out var pk); Assert.That(success, Is.False); Assert.That(pk, Is.Null); }