public void ShouldSetNullableValueInInstance() { Nullable nullable = new Nullable(); PropertyInfo info = typeof(Nullable).GetProperty("Value"); ReflectorProperty <Nullable, long?> property = new ReflectorProperty <Nullable, long?>(info); property.SetValue(nullable, 123); Assert.That(nullable.Value, Is.EqualTo(123)); }
public void ShouldSetValueInInstance() { Regular regular = new Regular(); PropertyInfo info = typeof(Regular).GetProperty("Value"); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); property.SetValue(regular, "cde"); Assert.That(regular.Value, Is.EqualTo("cde")); }
public void ShouldHandleCastedSetConversionInInstance() { Regular regular = new Regular(); PropertyInfo info = typeof(Regular).GetProperty("Value"); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); ReflectorProperty <Regular, string> casted = property.Cast(x => x.ToLower(), x => x.ToUpper()); casted.SetValue(regular, "cDe"); Assert.That(regular.Value, Is.EqualTo("CDE")); }
public void ShouldSetNullableValueToNullInInstance() { Nullable nullable = new Nullable { Value = 10 }; PropertyInfo info = typeof(Nullable).GetProperty("Value"); ReflectorProperty <Nullable, long?> property = new ReflectorProperty <Nullable, long?>(info); property.SetValue(nullable, null); Assert.That(nullable.Value, Is.Null); }
public void ShouldSetNullableValueToNullInSubstitute() { Addressable source = new MemoryMock(); Serializer <Nullable> serializer = new Serializer <Nullable>(); Substitute <Nullable> nullable = new Substitute <Nullable>(serializer, source); PropertyInfo info = typeof(Nullable).GetProperty("Value"); ReflectorProperty <Nullable, long?> property = new ReflectorProperty <Nullable, long?>(info); property.SetValue(nullable, () => null); Assert.That(nullable.AsDynamic().Value, Is.Null); }
public void ShouldSetValueInSubstitute() { Addressable source = new MemoryMock(); Serializer <Regular> serializer = new Serializer <Regular>(); Substitute <Regular> regular = new Substitute <Regular>(serializer, source); PropertyInfo info = typeof(Regular).GetProperty("Value"); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); property.SetValue(regular, () => "cde"); Assert.That(regular.AsDynamic().Value, Is.EqualTo("cde")); }
public void ShouldHandleCastedSetConversionInSubstitute() { Addressable source = new MemoryMock(); Serializer <Regular> serializer = new Serializer <Regular>(); PropertyInfo info = typeof(Regular).GetProperty("Value"); Substitute <Regular> regular = new Substitute <Regular>(serializer, source); ReflectorProperty <Regular, string> property = new ReflectorProperty <Regular, string>(info); ReflectorProperty <Regular, string> casted = property.Cast(x => x.ToLower(), x => x.ToUpper()); casted.SetValue(regular, () => "cDe"); Assert.That(regular.AsDynamic().Value, Is.EqualTo("CDE")); }