Exemplo n.º 1
0
        public void DefaultContructor_Properties_AreEmpty()
        {
            PatternElement patternEle = new PatternElement();

            Assert.AreEqual("", patternEle.Name);
            Assert.AreEqual(0, patternEle.Pattern._pattern.Length);
            Assert.IsNull(patternEle.Cached);
        }
Exemplo n.º 2
0
        public void Cached_Get_ReadsCachedElement()
        {
            XElement cached = CreateCachedXElement("blub", "value");
            XElement element = CreatePatternXElement("some name", "AA BB CC", cached);
            PatternElement patternEle = new PatternElement(element);

            var cachedEle = patternEle.Cached;

            Assert.AreEqual(cached, cachedEle.Element);
        }
Exemplo n.º 3
0
        public void Cached_SetNull_RemovesCachedElement()
        {
            XElement cached = CreateCachedXElement("some", "value");
            XElement element = CreatePatternXElement("some name", "AA BB CC", cached);
            PatternElement patternEle = new PatternElement(element);

            patternEle.Cached = null;

            Assert.IsFalse(element.Elements("Cached").Any());
        }
Exemplo n.º 4
0
        public void Cached_Set_SetsCachedElement()
        {
            string expectedBuild = "1.1.1";
            int expectedValue = 12;
            XElement element = CreatePatternXElement("some name", "AA BB CC");
            PatternElement patternEle = new PatternElement
            {
                Cached = new CachedElement { Build = expectedBuild, Value = expectedValue }
            };

            var cachedEle = patternEle.Cached;

            Assert.AreEqual(expectedBuild, cachedEle.Build);
            Assert.AreEqual(expectedValue, cachedEle.Value);
        }
Exemplo n.º 5
0
        public void Cached_Set_ReplacesCachedElement()
        {
            string expectedBuild = "1.1.1";
            int expectedValue = 12;
            XElement cached = CreateCachedXElement("1.1.0", "45");
            XElement element = CreatePatternXElement("some name", "AA BB CC", cached);
            PatternElement patternEle = new PatternElement(element);
            patternEle.Cached = new CachedElement { Build = expectedBuild, Value = expectedValue };

            var cachedEle = patternEle.Cached;

            Assert.AreEqual(expectedBuild, cachedEle.Build);
            Assert.AreEqual(expectedValue, cachedEle.Value);
            Assert.IsNull(cached.Parent);
        }
Exemplo n.º 6
0
 public void SetPatternElement(PatternElement patternElement)
 {
     _patternElement = patternElement;
 }
Exemplo n.º 7
0
        public void Pattern_Set_SetsPatternElement()
        {
            string expected = "AA ? BB";
            XElement element = CreatePatternXElement("some name");
            PatternElement patternEle = new PatternElement(element);
            patternEle.Pattern = Pattern.FromCombinedString(expected);

            string actual = element.Element(element.GetDefaultNamespace() + "Pattern").Value;
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void Pattern_Get_ReplacesLineBreaksWithWhitespaces()
        {
            XElement element = CreatePatternXElement("some name", "AA\nBB CC");
            PatternElement patternEle = new PatternElement(element);

            CollectionAssert.AreEqual(new byte[] { 0xAA, 0xBB, 0xCC }, patternEle.Pattern._pattern);
        }
Exemplo n.º 9
0
        public void Pattern_Get_ReadsPatternElement()
        {
            XElement element = CreatePatternXElement("some name", "AA BB CC");
            PatternElement patternEle = new PatternElement(element);

            CollectionAssert.AreEqual(new byte[] { 0xAA, 0xBB, 0xCC }, patternEle.Pattern._pattern);
        }
Exemplo n.º 10
0
        public void Name_Set_SetsNameElement()
        {
            string expected = "Hi!";
            XElement element = CreatePatternXElement("some other name");
            PatternElement patternEle = new PatternElement(element);
            patternEle.Name = expected;

            string actual = element.Element(element.GetDefaultNamespace() + "Name").Value;
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void Name_Get_ReadsNameElement()
        {
            string expected = "Hi!";
            XElement element = CreatePatternXElement(expected);
            PatternElement patternEle = new PatternElement(element);

            Assert.AreEqual(expected, patternEle.Name);
        }