public void When_parsing_a_restMS_domain()
        {
            _couldParse = XmlResultParser.TryParse(BODY, out _domain);

            //_should_be_able_to_parse_the_result
            _couldParse.Should().BeTrue();
            //_should_have_a_domain_object
            _domain.Should().NotBeNull();
        }
예제 #2
0
        public void When_parsing_a_restMS_domain()
        {
            _couldParse = XmlResultParser.TryParse(BODY, out _domain);

            //_should_be_able_to_parse_the_result
            Assert.True(_couldParse);
            //_should_have_a_domain_object
            Assert.NotNull(_domain);
        }
        /// <summary>
        /// Parses the response.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="response">The response.</param>
        /// <returns>T.</returns>
        /// <exception cref="ResultParserException"></exception>
        public T ParseResponse <T>(HttpResponseMessage response) where T : class, new()
        {
            var entityBody = response.Content.ReadAsStringAsync().Result;
            T   domainObject;

            if (!XmlResultParser.TryParse(entityBody, out domainObject))
            {
                var errorString = string.Format("Could not parse entity body as a domain => {0}", entityBody);
                _logger.Value.ErrorFormat(errorString);
                throw new ResultParserException(errorString);
            }
            return(domainObject);
        }