예제 #1
0
        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();
        }
예제 #2
0
        public void TestAddSingleAttributeFragments_StyleInNonRootIsNotModified()
        {
            Expect.Call(docProcessor.ParseUntypedMarkup("width: 0px")).Return(new LiteralFragment("width: 0px"));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "style", "width: 0px", false, template, renderFunction, context);
            Assert.AreEqual(" style=\"width: 0px\"", ConcatenatedFragments);
            mocks.VerifyAll();
        }
예제 #3
0
        public void TestAddSingleAttributeFragments_StyleInRootAppendsSemicolonIfNonLiteralFragmentIsReturned()
        {
            Expect.Call(docProcessor.ParseUntypedMarkup("code")).Return(new CodeExpressionFragment("code"));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "style", "code", true, template, renderFunction, context);
            Assert.AreEqual(" style=\"[EXPR:code];[Position]\"", ConcatenatedFragments);
            mocks.VerifyAll();
        }
예제 #4
0
        public void TestAddSingleAttributeFragments_StyleInRootAppendsSemicolonIfOneIsMissing()
        {
            Expect.Call(docProcessor.ParseUntypedMarkup("width: 0px")).Return(new LiteralFragment("width: 0px"));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "style", "width: 0px", true, template, renderFunction, context);
            Assert.AreEqual(" style=\"width: 0px;[Position]\"", ConcatenatedFragments);
            mocks.VerifyAll();
        }
예제 #5
0
        public void TestAddSingleAttributeFragments_SimpleNameValuePairWorks()
        {
            Expect.Call(docProcessor.ParseUntypedMarkup("test\"Value\"")).Return(new LiteralFragment("test"Value""));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "testName", "test\"Value\"", false, template, renderFunction, context);
            Assert.AreEqual(" testName=\"test"Value"\"", ConcatenatedFragments);
            mocks.VerifyAll();
        }
예제 #6
0
        public void TestAddSingleAttributeFragments_ActualNameWorks()
        {
            Expect.Call(docProcessor.ParseUntypedMarkup("SomeName")).Return(new LiteralFragment("SomeName"));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "actualName", "SomeName", false, template, renderFunction, context);
            Assert.AreEqual(" name=\"SomeName\"", ConcatenatedFragments);
            mocks.VerifyAll();
        }
예제 #7
0
        public void TestAddSingleAttributeFragments_IdForNonRootElementWorks()
        {
            Expect.Call(template.HasMember("testid")).Return(false);
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "id", "testid", false, template, renderFunction, context);
            Assert.AreEqual(" id=\"[ID]_testid\"", ConcatenatedFragments);
            Assert.AreEqual("testid", context.Id);
            mocks.VerifyAll();
        }
예제 #8
0
        public void TestAddSingleAttributeFragments_TypeAttributeWorks()
        {
            SetupRepo();
            Expect.Call(docProcessor.ParseUntypedMarkup("TestValue")).Return(new LiteralFragment("TestValue"));
            mocks.ReplayAll();
            var context = new GenericElementProcessorContext();

            GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "type", "TestValue", false, template, renderFunction, context);
            Assert.AreEqual(" type=\"TestValue\"", ConcatenatedFragments);
            Assert.AreEqual("TestValue", context.Type);
            mocks.VerifyAll();
        }
예제 #9
0
 public void TestAddSingleAttributeFragments_ForAndNameAttributesWorks()
 {
     foreach (var attrName in new[] { "for", "name" })
     {
         SetupRepo();
         mocks.ReplayAll();
         var context = new GenericElementProcessorContext();
         GenericElementProcessor.AddSingleAttributeFragments(docProcessor, attrName, "TestValue", false, template, renderFunction, context);
         Assert.AreEqual(" " + attrName + "=\"[ID]_TestValue\"", ConcatenatedFragments);
         mocks.VerifyAll();
     }
 }
예제 #10
0
        public void TestAddSingleAttributeFragments_IdForRootElementThrowsException()
        {
            var context = new GenericElementProcessorContext();

            Globals.AssertThrows(() => GenericElementProcessor.AddSingleAttributeFragments(docProcessor, "id", "testid", true, template, renderFunction, context), (TemplateErrorException ex) => true);
        }