public void TestResolvedDataKeys() { GadgetMaster target; DataGadgetTestData gadget = new DataGadgetTestData(); MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); target = new GadgetMaster(testFactory, gadget.Source); ResolveDataControlValues(target.MyDataContext, gadget.ExpectedViewer, gadget.ExpectedViewer, gadget.ExpectedFriends); target.MyDataContext.ResolveDataValues(); target.RenderContent(writer); string written = ControlTestHelper.GetStreamContent(stream); object data; for (int i = 0; i < gadget.ExpectedDataKeys.Length; i++) { string key = gadget.ExpectedDataKeys[i]; Assert.IsTrue(target.MasterDataContext.HasVariable(key), "Key not registered: " + key); data = target.MasterDataContext.GetVariableValue(gadget.ExpectedDataKeys[i]); Assert.IsNotNull(data, "Data not resolved for: " + key); } }
public void RenderClientSide() { CustomTagFactory factory = BuildInitTagFactoryWithTemplate(); MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); factory.RenderClientTemplates(writer); writer.Flush(); string result = ControlTestHelper.GetStreamContent(stream); //string templateDefinedTestString = CustomTagFactory.CLIENT_TEMPLATE_TAG_ATTRIBUTE + "=\"" + CUSTOM_TAG + "\""; string templateDefinedTestString = "<Template"; // + CUSTOM_TAG + "\""; Assert.IsFalse(string.IsNullOrEmpty(result), "Client template is empty"); Assert.IsTrue(-1 != result.IndexOf(TEMPLATE_CONTENTS), "Expected template contents not found:\n\n" + result); Assert.IsTrue(-1 != result.IndexOf(templateDefinedTestString), "Client template identifier not found:\n\n" + result); }
public void TestContentRender() { GadgetMaster master = new GadgetMaster(testFactory); ContentBlock block = master.AddContentBlock(new ContentBlock()); block.LoadTag(sampleContent); //block.ParseContent(); MemoryStream s = new MemoryStream(1024); StreamWriter w = new StreamWriter(s); block.Render(w); w.Flush(); s.Seek(0, SeekOrigin.Begin); string tagRendered = ControlTestHelper.GetStreamContent(s); Assert.IsTrue(tagRendered.Length > 0, "Empty rendered tag from content"); }
public void SuppressRenderClientSide() { CustomTagFactory factory = BuildInitTagFactoryWithTemplate(); MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); CustomTagTemplate template = factory.CustomTags[CUSTOM_TAG]; template.ClientRegister = false; factory.RenderClientTemplates(writer); writer.Flush(); string result = ControlTestHelper.GetStreamContent(stream); string templateDefinedTestString = CustomTagFactory.CLIENT_TEMPLATE_TAG_ATTRIBUTE + "=\"" + CUSTOM_TAG + "\""; Assert.IsTrue(-1 == result.IndexOf(templateDefinedTestString), "Client template incorrectly rendered" + result); }