Exemplo n.º 1
0
        public void EmbeddedStyleGroupRegisterTest()
        {
            var styleGroup = new EmbeddedStyleGroup();
            var source     = "#style { color:blue; }";
            var style1     = new EmbeddedStyle(source);
            var style2     = new EmbeddedStyle(source);

            styleGroup.Register(style1);
            styleGroup.Register(style2);
            Assert.AreEqual(1, styleGroup.Count);
        }
Exemplo n.º 2
0
        public void EmbeddedStyleGroupRegisterTest3()
        {
            var styleGroup = new EmbeddedStyleGroup();
            var style1     = "#world { color:blue; }";
            var style2     = "#world { color:blue; }";
            var style3     = "#earth { color:green; }";

            styleGroup.Register(style1, style2, style3);

            Assert.AreEqual(2, styleGroup.Count);
            Assert.AreEqual(style1, styleGroup.First().Source);
            Assert.AreEqual(style3, styleGroup.Skip(1).First().Source);
        }
Exemplo n.º 3
0
        public void EmbeddedStyleGroupRegisterTest2()
        {
            var styleGroup = new EmbeddedStyleGroup();
            var source     = "#style { color:blue; }";
            var style1     = new EmbeddedStyle(source);
            var style2     = new EmbeddedStyle(source);

            Assert.IsFalse(styleGroup.HasRegistered(style1));
            Assert.IsFalse(styleGroup.HasRegistered(style2));
            styleGroup.Register(style1);
            Assert.IsTrue(styleGroup.HasRegistered(style1));
            Assert.IsTrue(styleGroup.HasRegistered(style2));
        }
Exemplo n.º 4
0
        public void EmbeddedStyleGroupRenderTest()
        {
            var style1     = new EmbeddedStyle("#world { color:blue; }");
            var style2     = new EmbeddedStyle("#earth { color:green; }");
            var styleGroup = new EmbeddedStyleGroup();

            styleGroup.Add(style1);
            styleGroup.Add(style2);

            var rendered = styleGroup.Render();
            var expected = "<style type=\"text/css\">";

            expected += Environment.NewLine + "#world { color:blue; }";
            expected += Environment.NewLine + "#earth { color:green; }";
            expected += Environment.NewLine + "</style>";

            Assert.AreEqual(expected, rendered);
        }
Exemplo n.º 5
0
        public void EmbeddedStyleGroupAddTest()
        {
            var styleGroup = new EmbeddedStyleGroup();
            var source     = "#style { color:red; }";
            var style1     = new EmbeddedStyle(source);
            var style2     = new EmbeddedStyle(source);

            styleGroup.Add(style1);
            try
            {
                styleGroup.Add(style2);
            }
            catch (ResourceAlreadyAddedException)
            {
                return;
            }
            catch (Exception)
            {
                Assert.Fail("Incorrect exception thrown.");
            }
            Assert.Fail("No exception thrown.");
        }