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_WithValidConnectorAndValidEncodingInConstructor_ShouldReturnValidObject() { var connectorMock = new Mock <INetConnectorFactory>(); var parser = new MaterialCitationsParser(connectorMock.Object, Encoding.UTF32); Assert.IsNotNull(parser, "Parser should not be null object."); }
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_WithNullConnectorAndValidEncodingInConstructor_ShouldThrowArgumentNullExceptionWithCorrectParameterName() { try { var parser = new MaterialCitationsParser(null, Encoding.UTF32); } catch (ArgumentNullException e) { Assert.AreEqual("connectorFactory", e.ParamName, "ParamName should be connector."); } }
public void MaterialCitationsParser_WithValidConnectorAndNullEncodingInConstructor_ShouldThrowArgumentNullExceptionWithCorrectParameterName() { try { var connectorMock = new Mock <INetConnectorFactory>(); var parser = new MaterialCitationsParser(connectorMock.Object, null); } catch (ArgumentNullException e) { Assert.AreEqual("encoding", e.ParamName, "ParamName should be encoding."); } }
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."); } }
public void MaterialCitationsParser_WithValidConnectorAndNullEncodingInConstructor_ShouldThrowArgumentNullException() { var connectorMock = new Mock <INetConnectorFactory>(); var parser = new MaterialCitationsParser(connectorMock.Object, null); }
public void MaterialCitationsParser_WithNullConnectorAndValidEncodingInConstructor_ShouldThrowArgumentNullException() { var parser = new MaterialCitationsParser(null, Encoding.UTF32); }
public void MaterialCitationsParser_WithNullConnectorInDefaultConstructor_ShouldThrowArgumentNullException() { var parser = new MaterialCitationsParser(null); }