public void TestParse_Works() { var actual = new CodeMarkupParser().Parse("code", false, " some code ", null); Assert.AreEqual(" some code ", actual.InitializerString); Globals.AssertThrows(() => actual.ValueRetriever(), (TemplateErrorException ex) => true); }
public void TestTryProcess_ErrorIfImplementingInterfaceTwiceClientSide() { Expect.Call(template.ImplementsClientInterface("TestType")).Return(true); mocks.ReplayAll(); Globals.AssertThrows(() => new ImplementsOrInheritsNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?implements type=\"TestType\" side=\"client\"?>"), true, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_DefFragmentErrorIfInvalidUnqualifiedName() { mocks.ReplayAll(); Globals.AssertThrows(() => new FunctionDefinitionAndCallNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<def-fragment name=\"A.B\"><x/></def-fragment>"), false, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestTryProcess_ErrorIfModelMemberAlreadyExists() { Expect.Call(template.HasMember("Model")).Return(true); mocks.ReplayAll(); Globals.AssertThrows(() => new ViewDirectiveNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?view modelType=\"ServerType\" ?>"), true, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_ErrorIfInheritingFromMoreThanOneBaseClassServerSide() { Expect.Call(template.ServerInherits).Return("SomeType"); mocks.ReplayAll(); Globals.AssertThrows(() => new ImplementsOrInheritsNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?inherits type=\"TestType\" side=\"server\"?>"), true, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_CustomInstantiateAndOtherPropertiesIsError() { mocks.ReplayAll(); Globals.AssertThrows(() => new ControlInstantiationNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<control id=\"TestId\" type=\"Namespace.TestType\" customInstantiate=\"true\" Attr1=\"value1\" Attr2=\"value2\"/>"), false, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestTryProcess_InvalidPropertyValueIsError() { mocks.ReplayAll(); Globals.AssertThrows(() => new ControlInstantiationNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<control id=\"TestId\" type=\"Namespace.TestType\" Attr1=\"value1\" Attr2=\"bad\"/>"), false, template, renderFunction), (TemplateErrorException ex) => ex.Message == "bad"); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestTryProcess_EmptyStatementThrows() { mocks.ReplayAll(); Globals.AssertThrows(() => new EmbeddedCodeNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?c ?>"), true, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestParse_InvalidValuesThrow() { foreach (string value in new[] { "bad", "lt", "lt(1, 2, 3)", "lt(1, x)", "lt(x, 1)", "lt(1)" }) { Globals.AssertThrows(() => new PositionMarkupParser().Parse("pos", false, value, null), (TemplateErrorException ex) => ex.Message == ParserUtils.MakeTypedMarkupErrorMessage("pos", false, value)); } }
public void TestTryProcess_ErrorIfNotRoot() { mocks.ReplayAll(); Globals.AssertThrows(() => new DirectiveNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?enableClientCreate ?>"), false, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestTryProcess_MissingTypeIsError() { mocks.ReplayAll(); Globals.AssertThrows(() => new ControlInstantiationNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<control id=\"TestId\" />"), false, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestTryProcess_DefFragmentErrorIfDuplicateName() { Expect.Call(template.HasMember("FragName")).Return(true); mocks.ReplayAll(); Globals.AssertThrows(() => new FunctionDefinitionAndCallNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<def-fragment name=\"FragName\"><x/><y/></def-fragment>"), false, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestParse_ErrorIfBadPrefix() { mocks.ReplayAll(); string value = "bad:some value"; Globals.AssertThrows(() => parser.ParseMarkup(value, null), (TemplateErrorException ex) => ex.Message == ParserUtils.MakeTypedMarkupErrorMessage2(value)); mocks.VerifyAll(); }
public void TestGetStatement_IfThrowsIfNoExpression() { mocks.ReplayAll(); XmlNode n = Globals.GetXmlNode("<if/>"); Globals.AssertThrows(() => ControlFlowTagProcessor.GetStatement(n), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestGetStatement_ForThrowsIfNeitherStmtNorEach() { mocks.ReplayAll(); XmlNode n = Globals.GetXmlNode("<for/>"); Globals.AssertThrows(() => ControlFlowTagProcessor.GetStatement(n), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestGetStatement_ForThrowsIfBothStmtAndEach() { mocks.ReplayAll(); XmlNode n = Globals.GetXmlNode("<for each=\"int x in ints\" stmt=\"int i = 0; i < l.Length; i++\"/>"); Globals.AssertThrows(() => ControlFlowTagProcessor.GetStatement(n), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestProcessSwitchContents_ErrorIfProcessingInstructionContent() { mocks.ReplayAll(); XmlNode node = Globals.GetXmlNode("<switch expr=\"testexpr\"><?bad?><default>x</default></switch>"); Globals.AssertThrows(() => ControlFlowTagProcessor.ProcessSwitchContent(docProcessor, node, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_ErrorIfDuplicateMember() { Expect.Call(template.HasMember("testName")).Return(true); mocks.ReplayAll(); Globals.AssertThrows(() => new FieldNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?field name=\"testName\" type=\"TestType\"?>"), true, template, renderFunction), (TemplateErrorException ex) => true); Assert.AreEqual(0, fragments.Count); mocks.VerifyAll(); }
public void TestProcessSwitchContents_ErrorIfTwoDefaults() { Expect.Call(() => docProcessor.ProcessRecursive(null, null, null)).IgnoreArguments().Repeat.Any(); mocks.ReplayAll(); XmlNode node = Globals.GetXmlNode("<switch expr=\"testexpr\"><default>x</default><default>y</default></switch>"); Globals.AssertThrows(() => ControlFlowTagProcessor.ProcessSwitchContent(docProcessor, node, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestAddSingleAttributeFragments_ErrorIfDuplicateMember() { Expect.Call(template.HasMember("ExistingMember")).Return(true); mocks.ReplayAll(); var context = new GenericElementProcessorContext(); Globals.AssertThrows(() => GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "id", "ExistingMember", false, template, renderFunction, context), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_IfStatementErrorIfElseIfAfterElse() { Expect.Call(() => docProcessor.ProcessRecursive(null, null, null)).IgnoreArguments().Repeat.Any(); mocks.ReplayAll(); XmlNode node = Globals.GetXmlNode("<if test=\"testexpr\">x<else/>x<else-if test=\"test2\"/>x</if>"); Globals.AssertThrows(() => new ControlFlowTagProcessor().TryProcess(docProcessor, node, false, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestInstantiate_CustomInstantiateThrows() { var tpl = mocks.StrictMock <ITemplate>(); var ctl = mocks.StrictMock <IInstantiatedTemplateControl>(); var container = mocks.StrictMock <IContainer>(); mocks.ReplayAll(); Globals.AssertThrows(() => new InstantiatedControlMember("CtlName", "Namespace.Type", true, new Dictionary <string, TypedMarkupData>(), new IMember[0]).Instantiate(tpl, ctl, container), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestRender_Throws() { var tpl = mocks.StrictMock <ITemplate>(); var ctl = mocks.StrictMock <IInstantiatedTemplateControl>(); mocks.ReplayAll(); StringBuilder sb = new StringBuilder(); Globals.AssertThrows(() => new CodeFragment("[Some code]", 0).Render(tpl, ctl, sb), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTopologicalSort_ThrowsIfUnknownDependency() { var members = new Dictionary <string, IMember>(); AddMember(members, "m1", "x"); AddMember(members, "m2", "m3"); mocks.ReplayAll(); Globals.AssertThrows(() => Template.TopologicalSort(members), (ArgumentException ex) => true); mocks.VerifyAll(); }
public void TestTopologicalSort_DetectsCycles() { var members = new Dictionary <string, IMember>(); AddMember(members, "m1", "m2"); AddMember(members, "m2", "m3"); AddMember(members, "m3", "m1"); AddMember(members, "m4"); AddMember(members, "m5"); mocks.ReplayAll(); Globals.AssertThrows(() => Template.TopologicalSort(members), (ArgumentException ex) => true); mocks.VerifyAll(); }
public void TestParse_InvalidArrayValueThrows() { string value = "np | bad | fixed"; Globals.AssertThrows(() => new PositionMarkupParser().Parse("pos", true, value, null), (TemplateErrorException ex) => ex.Message == ParserUtils.MakeTypedMarkupErrorMessage("pos", true, value)); }
public void TestTryProcess_ErrorIfNameMissing() { Globals.AssertThrows(() => new FieldNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?field type=\"TestType\"?>"), true, template, renderFunction), (TemplateErrorException ex) => true); }
public void TestAddSingleAttributeFragments_IdForRootElementThrowsException() { var context = new GenericElementProcessorContext(); Globals.AssertThrows(() => GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "id", "testid", true, template, renderFunction, context), (TemplateErrorException ex) => true); }
public void TestTryProcess_ErrorIfNotRoot() { mocks.ReplayAll(); Globals.AssertThrows(() => new UsingDirectiveNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?using namespace=\"TestType\" side=\"both\"?>"), false, template, renderFunction), (TemplateErrorException ex) => true); mocks.VerifyAll(); }
public void TestTryProcess_ErrorIfBadSide() { Globals.AssertThrows(() => new UsingDirectiveNodeProcessor().TryProcess(docProcessor, Globals.GetXmlNode("<?using namespace=\"TestType\" side=\"x\"?>"), true, template, renderFunction), (TemplateErrorException ex) => true); }