Exemple #1
0
        public void GetAttributeProxy_IsCached()
        {
            var provider = new StableBindingProxyProvider(
                new TypeLevelTypeFilter(new[] { typeof(ProxiedChild) }), CreateModuleScope("GetTypeMemberProxy"));

            var proxied0 = new ProxiedChildChildChild("ABCccccccccccccccccc");
            var proxied1 = new ProxiedChildChildChild("xyzzzzzzzzz");

            const string attributeName       = "PrependName";
            var          typeMemberProxy0    = provider.GetAttributeProxy(proxied0, attributeName);
            var          customMemberTester0 = new GetCustomMemberTester(typeMemberProxy0);
            var          result0             = ScriptingHelper.ExecuteScriptExpression <string> ("p0.XYZ('simsalbum',2)", customMemberTester0);

            Assert.That(result0, Is.EqualTo("ProxiedChild ProxiedChild: ABCccccccccccccccccc simsalbum, THE NUMBER=2"));


            var typeMemberProxy1 = provider.GetAttributeProxy(proxied1, attributeName);

            Assert.That(typeMemberProxy0, Is.SameAs(typeMemberProxy1));

            var customMemberTester1 = new GetCustomMemberTester(typeMemberProxy1);
            var result1             = ScriptingHelper.ExecuteScriptExpression <string> ("p0.ABCDEFG('Schlaf')", customMemberTester1);

            Assert.That(result1, Is.EqualTo("xyzzzzzzzzz Schlaf"));
        }
Exemple #2
0
        public void GetTypeMemberProxy()
        {
            var provider = new StableBindingProxyProvider(
                new TypeLevelTypeFilter(new[] { typeof(ProxiedChild) }), CreateModuleScope("GetTypeMemberProxy"));

            var          proxied       = new ProxiedChildChildChild("abrakadava");
            const string attributeName = "PrependName";

            var typeMemberProxy = provider.GetAttributeProxy(proxied, attributeName);

            var customMemberTester = new GetCustomMemberTester(typeMemberProxy);

            var result = ScriptingHelper.ExecuteScriptExpression <string> ("p0.XYZ('simsalbum',2)", customMemberTester);

            Assert.That(result, Is.EqualTo("ProxiedChild ProxiedChild: abrakadava simsalbum, THE NUMBER=2"));
        }