public void MaterialCitationsParser_WithNullContentInInvoke_ShouldThrow() { var connectorMock = new Mock <INetConnectorFactory>(); var parser = new MaterialCitationsParser(connectorMock.Object, Encoding.UTF8); var result = parser.Invoke(null).Result; }
public void MaterialCitationsParser_WithValidRealTestContentWithCommentInIt_ShouldReturnValidResponse() { var connector = new NetConnectorFactory(); var parser = new MaterialCitationsParser(connector, Encoding.UTF8); var requestXml = new XmlDocument { PreserveWhitespace = false }; requestXml.Load(ConfigurationManager.AppSettings["RequestXmlWithTwoMaterialCitations"]); string result = parser.Invoke(requestXml.OuterXml).Result; var responseXml = new XmlDocument { PreserveWhitespace = false }; responseXml.LoadXml(result); Assert.AreEqual( requestXml.DocumentElement.LocalName, responseXml.DocumentElement.LocalName, "Local names of root elements should match."); Assert.AreEqual( this.matchWhitespace.Replace(requestXml.DocumentElement.InnerText, " ").Trim(), this.matchWhitespace.Replace(responseXml.DocumentElement.InnerText, " ").Trim(), "Content should be unchanged."); }
public void MaterialCitationsParser_WithValidZeroTestContent_ShouldReturnValidResponse() { var connector = new NetConnectorFactory(); var parser = new MaterialCitationsParser(connector, Encoding.UTF8); const string ZeroTestContent = @"<paragraph pn=""1"">Test with <detail>detail</detail></paragraph>"; var requestXml = new XmlDocument { PreserveWhitespace = false }; requestXml.LoadXml(ZeroTestContent); string result = parser.Invoke(requestXml.OuterXml).Result; var responseXml = new XmlDocument { PreserveWhitespace = false }; responseXml.LoadXml(result); Assert.AreEqual( requestXml.DocumentElement.LocalName, responseXml.DocumentElement.LocalName, "Local names of root elements should match."); Assert.AreEqual( this.matchWhitespace.Replace(requestXml.DocumentElement.InnerText, " ").Trim(), this.matchWhitespace.Replace(responseXml.DocumentElement.InnerText, " ").Trim(), "ZeroTestContent should be unchanged."); }
public void MaterialCitationsParser_WithWhitespaceContentInInvoke_ShouldThrowWithInnerArgumentNullException() { var connectorMock = new Mock <INetConnectorFactory>(); var parser = new MaterialCitationsParser(connectorMock.Object, Encoding.UTF8); try { var result = parser.Invoke(" ").Result; } catch (AggregateException e) { Assert.AreEqual(1, e.InnerExceptions.Count, "Number of inner exceptions should be 1."); Assert.AreEqual( typeof(ArgumentNullException).FullName, e.InnerExceptions.First().GetType().FullName, "Inner exception should be of type ArgumentNullException."); } }