示例#1
0
        public void ParseReceivedDataReturnsSuccessResultIfRulesPass()
        {
            _ruleManagerMock.Setup(m => m.RunRules(It.IsAny <Node>())).Returns(new List <RuleResult>());

            ParseDataResponse response = _dataService.ParseReceivedData("data");

            Assert.AreEqual(true, response.ParseSuccessful);
        }
示例#2
0
        public void ParseReceivedDataReturnsReturnsFailureIfUnknownExceptionIsThrown()
        {
            _ruleManagerMock.Setup(m => m.RunRules(It.IsAny <Node>())).Throws <Exception>();

            ParseDataResponse response = _dataService.ParseReceivedData("data");

            Assert.AreEqual(false, response.ParseSuccessful);
            Assert.True(response.ErrorMessages.Contains(ErrorMessages.UnknownParseError));
        }
示例#3
0
        public void ParseReceivedDataReturnsReturnsFailureIfParseExceptionIsThrown()
        {
            var xmlParseException = new XmlParseException("the parse error");

            _xmlParserMock.Setup(m => m.BuildNodeStructure(It.IsAny <string>(), It.IsAny <string>()))
            .Throws(xmlParseException);

            ParseDataResponse response = _dataService.ParseReceivedData("data");

            Assert.AreEqual(false, response.ParseSuccessful);
            Assert.True(response.ErrorMessages.Contains(xmlParseException.Message));
        }
示例#4
0
        public void ParseReceivedDataReturnsFailureResultIfAnyRulesFail()
        {
            var errorMessage = "error message";

            _ruleManagerMock.Setup(m => m.RunRules(It.IsAny <Node>()))
            .Returns(new List <RuleResult> {
                new RuleResult(false, errorMessage), new RuleResult(true)
            });

            ParseDataResponse response = _dataService.ParseReceivedData("data");

            Assert.AreEqual(false, response.ParseSuccessful);
            Assert.True(response.ErrorMessages.Contains(errorMessage));
        }
示例#5
0
        public void ParseReceivedDataReturnsNodedDataStructureIfRulesPass()
        {
            Node node = new Node {
                Name = "test"
            };

            _xmlParserMock.Setup(m => m.BuildNodeStructure(It.IsAny <string>(), It.IsAny <string>())).Returns(node);
            _ruleManagerMock.Setup(m => m.RunRules(It.IsAny <Node>()))
            .Returns(new List <RuleResult> {
                new RuleResult(true)
            });

            ParseDataResponse response = _dataService.ParseReceivedData("data");

            Assert.AreEqual(true, response.ParseSuccessful);
            Assert.AreEqual(node, response.Data);
        }