Пример #1
0
        public void AssertText(XmlNodeSimplified expectedNode)
        {
            if (expectedNode.NodeType != XmlNodeType.Text)
            {
                return;
            }

            var expectedText = expectedNode.InnerText;

            if (_assertContext.XmlNode.NodeType != XmlNodeType.Text)
            {
                var exceptionMsg = string.Format("Expected text, but found [{0}]",
                                                 _assertContext.XmlNode.NodeType);
                _assertContext.ThrowErrorMessage(exceptionMsg);
            }
            var actualText = _assertContext.XmlNode.InnerText;
            var eq         = _assertContext.StringComparer.Equals(actualText, expectedText);

            if (!eq)
            {
                var exceptionMsg = string.Format("Expected text [{0}], but found [{1}]",
                                                 expectedText, actualText);
                _assertContext.ThrowErrorMessage(exceptionMsg);
            }
        }
Пример #2
0
        public void AssertAttributeExists(string attributeName)
        {
            var attribute      = GetAttributeByName(attributeName);
            var attributeFound = attribute != null;

            if (!attributeFound)
            {
                var exceptionMessage = string.Format("Expected attribute [{0}] was not found", attributeName);
                _assertContext.ThrowErrorMessage(exceptionMessage);
            }
        }
Пример #3
0
        public void AssertName(string expectedName)
        {
            var actualName   = _assertContext.XmlNode.Name;
            var everythingOk = _assertContext.StringComparer.Equals(actualName, expectedName);

            if (everythingOk)
            {
                return;
            }
            var exceptionMessage = string.Format("Expected xml node with name [{0}], but found [{1}]",
                                                 expectedName, actualName);

            _assertContext.ThrowErrorMessage(exceptionMessage);
        }
        public void AssertChildrenNumber(XmlNodeSimplified expected)
        {
            var childrenActual      = _assertContext.XmlNode.Children.ToList();
            var childrenExpected    = expected.Children.ToList();
            var equalChildrenNumber = childrenActual.Count == childrenExpected.Count;

            if (!equalChildrenNumber)
            {
                _assertContext.ThrowErrorMessage(string.Format("Number of children is " +
                                                               "incorrent, expected [{0}], but was [{1}]",
                                                               childrenExpected.Count,
                                                               childrenActual.Count));
            }
        }