Пример #1
0
        public void TryInvokeMember_PublicMethod_InvokesTheMethod()
        {
            dynamic o = new AccessPrivateWrapper(new PrivateAccessTester());

            int result = o.PublicMethod(555);

            Assert.IsTrue(o.PublicMethodCalled);
            Assert.AreEqual(result, 666);
        }
Пример #2
0
        public void TrySetMember_PublicProperty_ReturnsCorrectValue()
        {
            var     tester = new PrivateAccessTester();
            dynamic o      = new AccessPrivateWrapper(tester);

            o.PublicProperty = 111111;

            Assert.AreEqual(111111, tester.PublicProperty);
        }
Пример #3
0
        public void TryGetMember_PrivateProperty_ReturnsCorrectValue()
        {
            var     tester = new PrivateAccessTester();
            dynamic o      = new AccessPrivateWrapper(tester);

            tester.PrivateGetProperty = 888;

            Assert.AreEqual(888, o.PrivateGetProperty);
        }
Пример #4
0
        public void TrySetMember_PublicField_ReturnsCorrectValue()
        {
            var     tester = new PrivateAccessTester();
            dynamic o      = new AccessPrivateWrapper(tester);

            o.PublicField = 888;

            Assert.AreEqual(888, tester.PublicField);
        }
Пример #5
0
        public void TrySetMember_PrivateField_ReturnsCorrectValue()
        {
            var     tester = new PrivateAccessTester();
            dynamic o      = new AccessPrivateWrapper(tester);

            o.privateField = 777;

            Assert.AreEqual(777, tester.PrivateFieldAccessor);
        }
Пример #6
0
        public void TryInvokeMember_UnknownMethod_ThrowsException()
        {
            dynamic o = new AccessPrivateWrapper(new PrivateAccessTester());

            o.UnknownMethod(555);
        }
Пример #7
0
 public void FromType_UnknownType_ReturnsNull()
 {
     AccessPrivateWrapper.FromType(Assembly.GetExecutingAssembly(), "UnknownType");
 }
Пример #8
0
 public void FromType_UnknownCtor_ThrowsException()
 {
     AccessPrivateWrapper.FromType(Assembly.GetExecutingAssembly(), "PrivateAccessTester", "TheCtorDoesNotAcceptStrings");
 }
Пример #9
0
        public void FromType_PublicCtor_CreatesInstance()
        {
            dynamic o = AccessPrivateWrapper.FromType(Assembly.GetExecutingAssembly(), "PrivateAccessTester");

            Assert.IsTrue(o.Wrapped.PublicCtorCalled);
        }
Пример #10
0
        public void TrySetMember_UnknownField_ThrowsException()
        {
            dynamic o = new AccessPrivateWrapper(new PrivateAccessTester());

            o.UnknownField = 123;
        }
Пример #11
0
        public void TryGetMember_PublicField_ReturnsCorrectValue()
        {
            dynamic o = new AccessPrivateWrapper(new PrivateAccessTester());

            Assert.AreEqual(222, o.PublicField);
        }