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.");
        }
コード例 #2
0
        public void NetConnectorFactory_Constructor_ShouldReturnValidObject()
        {
            var connectorFactory = new NetConnectorFactory();

            Assert.IsNotNull(connectorFactory, "ConnectorFactory should be a valid object.");
            Assert.IsInstanceOf <INetConnectorFactory>(connectorFactory, "ConnectorFactory should be a instance of {0}.", nameof(INetConnectorFactory));
        }
        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.");
        }
コード例 #4
0
        public void NetConnectorFactory_CreateWithValidBaseAddress_ShouldReturnValidObject(string baseAddress)
        {
            var connectorFactory = new NetConnectorFactory();
            var connector        = connectorFactory.Create(baseAddress);

            Assert.IsNotNull(connector, "Connector should be a valid object.");
            Assert.IsInstanceOf <INetConnector>(connector, "Connector should be a instance of {0}.", nameof(INetConnector));
        }
コード例 #5
0
        public void NetConnectorFactory_ParameterlessCreate_ShouldReturnValidObject()
        {
            var connectorFactory = new NetConnectorFactory();
            var connector        = connectorFactory.Create();

            Assert.IsNotNull(connector, "Connector should be a valid object.");
            Assert.IsInstanceOf <INetConnector>(connector, "Connector should be a instance of {0}.", nameof(INetConnector));
        }
        public void GbifTaxaClassificationResolver_DefaultConstructor_ShouldWork()
        {
            var connectorFactory = new NetConnectorFactory();
            var requester        = new GbifApiV09DataRequester(connectorFactory);
            var service          = new GbifTaxaClassificationResolver(requester);

            Assert.IsNotNull(service, "Service should not be null");
        }
コード例 #7
0
 public void NetConnectorFactory_CreateWithInvalidBaseAddress_ShouldThrowUriFormatException(string baseAddress)
 {
     Assert.Catch <UriFormatException>(
         () =>
     {
         var connectorFactory = new NetConnectorFactory();
         var connector        = connectorFactory.Create(baseAddress);
     },
         "Constructor should throw UriFormatException");
 }
コード例 #8
0
 public void NetConnectorFactory_CreateWithNullOrWhiteSpaceBaseAddress_ShouldThrowArgumentNullException(string baseAddress)
 {
     Assert.Catch <ArgumentNullException>(
         () =>
     {
         var connectorFactory = new NetConnectorFactory();
         var connector        = connectorFactory.Create(baseAddress);
     },
         "Constructor With Null BaseAddress should throw {0}",
         nameof(ArgumentNullException));
 }
コード例 #9
0
 public void NetConnectorFactory_CreateWithNullOrWhiteSpaceBaseAddress_ShouldThrowArgumentNullExceptionWithCorrectParamName(string baseAddress)
 {
     try
     {
         var connectorFactory = new NetConnectorFactory();
         var connector        = connectorFactory.Create(baseAddress);
     }
     catch (ArgumentNullException e)
     {
         Assert.AreEqual("BaseAddress", e.ParamName, "ParamName should be BaseAddress");
     }
 }
        public void GbifTaxaClassificationResolver_Resolve_ShouldWork()
        {
            const string        CanonicalName = "Coleoptera";
            const TaxonRankType Rank          = TaxonRankType.Order;

            var connectorFactory = new NetConnectorFactory();
            var requester        = new GbifApiV09DataRequester(connectorFactory);
            var service          = new GbifTaxaClassificationResolver(requester);
            var response         = service.Resolve(CanonicalName).Result;

            var defaultClassification = response.FirstOrDefault();

            Assert.AreEqual(CanonicalName, defaultClassification.CanonicalName, "CanonicalName should match.");
            Assert.AreEqual(Rank, defaultClassification.Rank, "Rank should match.");
        }