Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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"));
        }
Exemplo n.º 7
0
        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"));
        }