예제 #1
0
        public virtual void ResolveTargetCountersTest()
        {
            CssCounterManager manager = new CssCounterManager();

            manager.ResetCounter("counter");
            manager.IncrementCounter("counter", 5);
            NUnit.Framework.Assert.IsNull(manager.ResolveTargetCounters("id", "counter", ".", CounterDigitsGlyphStyle.
                                                                        DEFAULT));
            NUnit.Framework.Assert.IsNull(manager.ResolveTargetCounters("id", "counter", ".", CounterDigitsGlyphStyle.
                                                                        DEFAULT));
            IElementNode node = new _CssPseudoElementNode_127(null, "name");

            manager.AddTargetCountersIfRequired(node);
            NUnit.Framework.Assert.AreEqual("5", manager.ResolveTargetCounters("id", "counter", ".", CounterDigitsGlyphStyle
                                                                               .DEFAULT));
            NUnit.Framework.Assert.IsNull(manager.ResolveTargetCounters("id", "counter2", ".", CounterDigitsGlyphStyle
                                                                        .DEFAULT));
            manager.IncrementCounter("counter2", 10);
            manager.AddTargetCountersIfRequired(node);
            NUnit.Framework.Assert.AreEqual("10", manager.ResolveTargetCounters("id", "counter2", ".", CounterDigitsGlyphStyle
                                                                                .DEFAULT));
            manager.PushEveryCounterToCounters(node);
            manager.ResetCounter("counter2", 7);
            manager.AddTargetCountersIfRequired(node);
            NUnit.Framework.Assert.AreEqual("5", manager.ResolveTargetCounters("id", "counter", ".", CounterDigitsGlyphStyle
                                                                               .DEFAULT));
            NUnit.Framework.Assert.AreEqual("10.7", manager.ResolveTargetCounters("id", "counter2", ".", CounterDigitsGlyphStyle
                                                                                  .DEFAULT));
        }
예제 #2
0
        public virtual void IncrementCounterTest()
        {
            CssCounterManager manager = new CssCounterManager();

            manager.ResetCounter("counter");
            manager.IncrementCounter("counter");
            NUnit.Framework.Assert.AreEqual("1", manager.ResolveCounter("counter", CounterDigitsGlyphStyle.DEFAULT));
            manager.IncrementCounter("counter", 101);
            NUnit.Framework.Assert.AreEqual("102", manager.ResolveCounter("counter", CounterDigitsGlyphStyle.DEFAULT));
            manager.IncrementCounter("counter", -3);
            NUnit.Framework.Assert.AreEqual("99", manager.ResolveCounter("counter", CounterDigitsGlyphStyle.DEFAULT));
            manager.IncrementCounter("counter", -101);
            NUnit.Framework.Assert.AreEqual("-2", manager.ResolveCounter("counter", CounterDigitsGlyphStyle.DEFAULT));
        }
예제 #3
0
        public virtual void ResolveCountersTest()
        {
            CssCounterManager manager = new CssCounterManager();

            manager.ResetCounter("counter1", 1);
            NUnit.Framework.Assert.AreEqual("1", manager.ResolveCounters("counter1", ";", CounterDigitsGlyphStyle.DEFAULT
                                                                         ));
            NUnit.Framework.Assert.AreEqual("0", manager.ResolveCounters("counter2", "::", CounterDigitsGlyphStyle.DEFAULT
                                                                         ));
            IElementNode node1 = new CssPseudoElementNode(null, "name");

            manager.PushEveryCounterToCounters(node1);
            manager.ResetCounter("counter2", 1);
            manager.IncrementCounter("counter1", 2);
            NUnit.Framework.Assert.AreEqual("3", manager.ResolveCounters("counter1", ";", CounterDigitsGlyphStyle.DEFAULT
                                                                         ));
            NUnit.Framework.Assert.AreEqual("1", manager.ResolveCounters("counter2", "::", CounterDigitsGlyphStyle.DEFAULT
                                                                         ));
            IElementNode node2 = new CssPseudoElementNode(null, "name");

            manager.PushEveryCounterToCounters(node2);
            manager.ResetCounter("counter1", 2);
            manager.ResetCounter("counter1", 30);
            manager.ResetCounter("counter2", 10);
            NUnit.Framework.Assert.AreEqual("3;30", manager.ResolveCounters("counter1", ";", CounterDigitsGlyphStyle.DEFAULT
                                                                            ));
            NUnit.Framework.Assert.AreEqual("1::10", manager.ResolveCounters("counter2", "::", CounterDigitsGlyphStyle
                                                                             .DEFAULT));
        }
예제 #4
0
        public virtual void AddTargetCounterIfRequiredTest()
        {
            CssCounterManager manager = new CssCounterManager();

            NUnit.Framework.Assert.IsNull(manager.ResolveTargetCounter("id1", "counter", CounterDigitsGlyphStyle.DEFAULT
                                                                       ));
            IElementNode node1 = new _CssPseudoElementNode_161(null, "name");
            IElementNode node2 = new _CssPseudoElementNode_170(null, "name");
            IElementNode node3 = new CssPseudoElementNode(null, "name");

            manager.AddTargetCounterIfRequired(node1);
            manager.AddTargetCounterIfRequired(node2);
            manager.AddTargetCounterIfRequired(node3);
            NUnit.Framework.Assert.AreEqual("0", manager.ResolveTargetCounter("id1", "counter", CounterDigitsGlyphStyle
                                                                              .DEFAULT));
            NUnit.Framework.Assert.IsNull(manager.ResolveTargetCounter("id2", "counter", CounterDigitsGlyphStyle.DEFAULT
                                                                       ));
            manager.ResetCounter("counter");
            manager.IncrementCounter("counter");
            manager.AddTargetCounterIfRequired(node1);
            NUnit.Framework.Assert.AreEqual("1", manager.ResolveTargetCounter("id1", "counter", CounterDigitsGlyphStyle
                                                                              .DEFAULT));
        }