Beispiel #1
0
        public void DynamicDataElementParametersRender()
        {
            string name   = "Yohan";
            Person viewer = ControlTestHelper.CreatePerson(909, name, null);

            string content           = "My Name is {0}";
            string param             = "thisPerson";
            string mainPersonDataKey = "vwr";
            //string instVariable = "${" + param
            string paramGet = param + ".displayName";
            string tag      = "x:Foo";

            string template = "<script type='text/os-template' tag='{0}'>\n{1}</script>";

            template = String.Format(template, tag, string.Format(content, "${My." + paramGet + "}"));

            string elemInstMarkup = "<{0}><{1}>{2}</{1}></{0}>";


            string tagInstanceMarkup = string.Format(elemInstMarkup, new string[] { tag, param, "${" + mainPersonDataKey + "}" });
            string expected          = string.Format(content, name);

            factory.RegisterCustomTag(tag, template);

            DataContext     dc        = factory.MyRootMaster.MyDataContext;
            OsViewerRequest viewerReq = new OsViewerRequest();

            viewerReq.Key = mainPersonDataKey;

            dc.RegisterDataItem(viewerReq);
            ResolveDataControlValues(dc, viewer, viewer, null);

            CustomTag inst = factory.CreateTagInstance(tag, tagInstanceMarkup);

//			Assert.AreEqual(name, inst.Parameters[param], "Registered instance value incorrect");

            string result = ControlTestHelper.GetRenderedContents(inst);

            result = ControlTestHelper.NormalizeRenderResult(result);
            Assert.AreEqual(expected, result, "Rendered results incorrect");
        }
Beispiel #2
0
        public void TagTopVariableParametersRender()
        {
            string name   = "Yohan";
            Person viewer = ControlTestHelper.CreatePerson(909, name, null);

            string content  = "My Name is {1} and my favorite color is {0}";
            string param    = "color";
            string tag      = "x:Foo";
            string val      = "blue";
            string paramTop = "vwr.displayName";
            //${Top.vwr.DisplayName}
            string template = "<script type='text/os-template' tag='{0}'>\n{1}</script>";

            template = String.Format(template, tag, string.Format(content, "${My." + param + "}", "${Top." + paramTop + "}"));

            string elemInstMarkup = "<{0}><{1}>{2}</{1}></{0}>";


            string tagInstanceMarkup = string.Format(elemInstMarkup, new string[] { tag, param, val });
            string expected          = string.Format(content, val, name);

            factory.RegisterCustomTag(tag, template);
            DataContext dc = factory.MyRootMaster.MyDataContext;

            ResolveDataControlValues(dc, viewer, viewer, null);
            OsViewerRequest viewerReq = new OsViewerRequest();

            viewerReq.Key = "vwr";

            dc.RegisterDataItem(viewerReq);
            ResolveDataControlValues(dc, viewer, viewer, null);

            CustomTag inst = factory.CreateTagInstance(tag, tagInstanceMarkup);

            Assert.AreEqual(val, inst.Parameters[param], "Registered instance value incorrect");

            string result = ControlTestHelper.GetRenderedContents(inst);

            result = ControlTestHelper.NormalizeRenderResult(result);
            Assert.AreEqual(expected, result, "Rendered results incorrect");
        }