Ejemplo n.º 1
0
        public void WriteInvalidMember()
        {
            var access = TypeAccessor.Create(typeof(PropsOnClass));
            var obj    = new PropsOnClass();

            access[obj, "doesnotexist"] = "abc";
        }
Ejemplo n.º 2
0
 public void ReadInvalidMember()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var access   = TypeAccessor.Create(typeof(PropsOnClass));
         var obj      = new PropsOnClass();
         object value = access[obj, "doesnotexist"];
     });
 }
Ejemplo n.º 3
0
        public void BasicReadTest_PropsOnClass_ViaWrapper()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass() { A = 123, B = "abc", C = now, D = null };

            var wrapper = ObjectAccessor.Create(obj);

            Assert.AreEqual(123, wrapper["A"]);
            Assert.AreEqual("abc", wrapper["B"]);
            Assert.AreEqual(now, wrapper["C"]);
            Assert.AreEqual(null, wrapper["D"]);
        }
Ejemplo n.º 4
0
        public void BasicReadTest_PropsOnClass()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass() { A = 123, B = "abc", C = now, D = null };

            var access = TypeAccessor.Create(typeof(PropsOnClass));

            Assert.AreEqual(123, access[obj, "A"]);
            Assert.AreEqual("abc", access[obj, "B"]);
            Assert.AreEqual(now, access[obj, "C"]);
            Assert.AreEqual(null, access[obj, "D"]);
        }
Ejemplo n.º 5
0
        public void BasicReadTest_PropsOnClass_ViaWrapper()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass {
                A = 123, B = "abc", C = now, D = null
            };

            var wrapper = ObjectAccessor.Create(obj);

            Assert.AreEqual(123, wrapper["A"]);
            Assert.AreEqual("abc", wrapper["B"]);
            Assert.AreEqual(now, wrapper["C"]);
            Assert.AreEqual(null, wrapper["D"]);
        }
Ejemplo n.º 6
0
        public void BasicReadTest_PropsOnClass()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass {
                A = 123, B = "abc", C = now, D = null
            };

            var access = TypeAccessor.Create(typeof(PropsOnClass));

            Assert.AreEqual(123, access[obj, "A"]);
            Assert.AreEqual("abc", access[obj, "B"]);
            Assert.AreEqual(now, access[obj, "C"]);
            Assert.AreEqual(null, access[obj, "D"]);
        }
Ejemplo n.º 7
0
        public void BasicWriteTest_PropsOnClass_ViaWrapper()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass();

            var wrapper = ObjectAccessor.Create(obj);

            wrapper["A"] = 123;
            wrapper["B"] = "abc";
            wrapper["C"] = now;
            wrapper["D"] = null;

            Assert.Equal(123, obj.A);
            Assert.Equal("abc", obj.B);
            Assert.Equal(now, obj.C);
            Assert.Equal(null, obj.D);
        }
Ejemplo n.º 8
0
        public void BasicWriteTest_PropsOnClass()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass();

            var access = TypeAccessor.Create(typeof(PropsOnClass));

            access[obj, "A"] = 123;
            access[obj, "B"] = "abc";
            access[obj, "C"] = now;
            access[obj, "D"] = null;

            Assert.Equal(123, obj.A);
            Assert.Equal("abc", obj.B);
            Assert.Equal(now, obj.C);
            Assert.Equal(null, obj.D);
        }
Ejemplo n.º 9
0
        public void BasicWriteTest_PropsOnClass_ViaWrapper()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass();

            var wrapper = ObjectAccessor.Create(obj);

            wrapper["A"] = 123;
            wrapper["B"] = "abc";
            wrapper["C"] = now;
            wrapper["D"] = null;

            Assert.AreEqual(123, obj.A);
            Assert.AreEqual("abc", obj.B);
            Assert.AreEqual(now, obj.C);
            Assert.AreEqual(null, obj.D);
        }
Ejemplo n.º 10
0
        public void BasicWriteTest_PropsOnClass()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass();

            var access = TypeAccessor.Create(typeof(PropsOnClass));

            access[obj, "A"] = 123;
            access[obj, "B"] = "abc";
            access[obj, "C"] = now;
            access[obj, "D"] = null;

            Assert.AreEqual(123, obj.A);
            Assert.AreEqual("abc", obj.B);
            Assert.AreEqual(now, obj.C);
            Assert.AreEqual(null, obj.D);
        }
Ejemplo n.º 11
0
 public void ReadInvalidMember()
 {
     var    access = TypeAccessor.Create(typeof(PropsOnClass));
     var    obj    = new PropsOnClass();
     object value  = access[obj, "doesnotexist"];
 }
Ejemplo n.º 12
0
 public void ReadInvalidMember()
 {
     var access = TypeAccessor.Create(typeof(PropsOnClass));
     var obj = new PropsOnClass();
     object value = access[obj, "doesnotexist"];
 }
Ejemplo n.º 13
0
 public void WriteInvalidMember()
 {
     var access = TypeAccessor.Create(typeof(PropsOnClass));
     var obj = new PropsOnClass();
     access[obj, "doesnotexist"] = "abc";
 }
Ejemplo n.º 14
0
 public void WriteInvalidMember()
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         var access = TypeAccessor.Create(typeof(PropsOnClass));
         var obj = new PropsOnClass();
         access[obj, "doesnotexist"] = "abc";
     });
 }