Esempio n. 1
0
        public void TestControlLoadTemplate()
        {
            OsTemplate   template = new OsTemplate();
            GadgetMaster master   = new GadgetMaster();
            DataContext  dc       = master.MyDataContext;

            template.MyRootMaster = master;
            dc.RegisterDataItem("Viewer", Viewer);

            for (int i = 0; i < GadgetTestData.Templates.SimpleControls.Length; i++)
            {
                template.AddControl(GadgetTestData.Templates.SimpleControls[i]);
            }


            Assert.IsTrue(AssertRenderResultsEqual(template, GadgetTestData.Templates.ExpectedSimpleMarkup), "Render results do not match");
        }
Esempio n. 2
0
        /// <summary>
        /// Helper method to test that the tag doesn't render blank results
        /// </summary>
        /// <param name="gadget"></param>
        void TestOsRepeaterTagFoundNotEmpty(DataGadgetTestData gadget)
        {
            GadgetMaster master = null;
            MemoryStream stream = null;
            StreamWriter writer = null;

            stream = new MemoryStream();
            writer = new StreamWriter(stream);

            master = GadgetMaster.CreateGadget(TEST_FACTORY_KEY, gadget.Source);
            ResolveDataControlValues(master.MyDataContext, gadget.ExpectedViewer, gadget.ExpectedViewer, gadget.ExpectedFriends);

            master.RenderContent(writer);

            Assert.AreEqual(1, master.ContentBlocks.Count);
            ContentBlock block = master.ContentBlocks[0];

            Assert.IsNotNull(block);

            bool         found    = false;
            OsmlRepeater repeater = null;

            foreach (BaseGadgetControl control in block.Templates)
            {
                OsTemplate template = control as OsTemplate;
                if (template != null)
                {
                    foreach (BaseGadgetControl innerControl in template.Controls)
                    {
                        if (innerControl is OsmlRepeater)
                        {
                            found    = true;
                            repeater = (OsmlRepeater)innerControl;
                            break;
                        }
                    }
                }
            }

            Assert.IsTrue(found, "Repeater not found in gadget results");
            Assert.IsNotNull(repeater, "Repeater control is null - i.e. wasn't created");
            Assert.Greater(repeater.Controls.Count, 0, "Repeater control tree not built");
        }
Esempio n. 3
0
        public void TestParsedOffsets()
        {
            MemoryStream stream = new MemoryStream(1024);
            StreamWriter w      = new StreamWriter(stream);

            ControlFactory factory  = ControlFactory.GetControlFactory(TEST_FACTORY_KEY);
            OsTemplate     template = new OsTemplate();

            template.MyControlFactory = factory;
            template.MyRootMaster     = new RootElementMaster();
            template.MyRootMaster.MyControlFactory = factory;


            template.Name = "test";
            template.LoadTag(GadgetTestData.Templates.RawSimpleMarkup);

            template.Render(w);
            string builtOffsets = template.MyOffset.ToString();

            Assert.AreEqual(GadgetTestData.Templates.ExpectedSimpleOffsets, builtOffsets, "Offsets not matching");
        }