Esempio n. 1
0
        public void PartBoxGetTest()
        {
            PartContainer.Noop();
            var test = new MyClass {
                Name = "blqw"
            };
            var p    = test.GetType().GetProperty("Name");
            var part = PartBox.Default.Get(p, x => new
            {
                Get = PartContainer.Invoke <Func <object, object> >("GetValue", x),
                Set = PartContainer.Invoke <Action <object, object> >("SetValue", x),
            }, p);

            Assert.NotNull(part);
            Assert.NotNull(part.Get);
            Assert.NotNull(part.Set);

            var part2 = PartBox.Default.Get(p, x => new
            {
                Get = PartContainer.Invoke <Func <object, object> >("GetValue", x),
                Set = PartContainer.Invoke <Action <object, object> >("SetValue", x),
            }, p);

            Assert.NotNull(part2);
            Assert.NotNull(part2.Get);
            Assert.NotNull(part2.Set);

            Assert.Equal(part.Get, part2.Get);
            Assert.Equal(part.Set, part2.Set);
        }
Esempio n. 2
0
        public void TestInvoke()
        {
            PartContainer.Noop();
            var test = new MyClass {
                Name = "blqw"
            };
            var p      = test.GetType().GetProperty("Name");
            var getter = PartContainer.Invoke <Func <object, object> >("GetValue", p);
            var setter = PartContainer.Invoke <Action <object, object> >("SetValue", p);

            Assert.NotNull(getter);
            Assert.NotNull(setter);

            Assert.Equal(getter(test), test.Name);
            test.Name = "xxxx";
            Assert.Equal(getter(test), test.Name);
            setter(test, "yyyy");
            Assert.Equal(getter(test), test.Name);
            Assert.Equal(test.Name, "yyyy");
        }