예제 #1
0
        public void MalformedXML()
        {
            string malformed = "this is some malformed xml!";

            try
            {
                NCBI.EsearchResults results = NCBI.ParseSearchResults(malformed);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                // Verify the error is thrown
                Assert.IsTrue(ex.Message == "Unable to process XML returned by the NCBI server. Offending XML has been written to pubharvester_error.log.");

                // Read the last 6 lines of pubharvester_error.log
                StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\pubharvester_error.log");
                string[]     lines  = reader.ReadToEnd().Split('\n');
                Assert.IsTrue(lines[lines.Length - 5].Trim() == malformed.Trim());
            }
        }
예제 #2
0
        public void NormalResults()
        {
            string xml = @"<?xml version=""1.0""?>
<!DOCTYPE eSearchResult PUBLIC ""-//NLM//DTD eSearchResult, 11 May 2002//EN"" ""http://www.ncbi.nlm.nih.gov/entrez/query/DTD/eSearch_020511.dtd"">
<eSearchResult>
	<Count>99</Count>
	<RetMax>1</RetMax>
	<RetStart>0</RetStart>
	<QueryKey>1</QueryKey>
	<WebEnv>01jHC0pmRm0V5DX0SCaTpJ0OqIA1N2LSKc2-Uus4KHDqRMj7m9Lz@@u66F4IOFk0AAH4@OH4AAAAQ</WebEnv>

	<IdList>
		<Id>15904469</Id>
	</IdList>
	<TranslationSet>
		<Translation>
			<From>STELLMAN SD</From>
			<To>STELLMAN SD[Author]</To>

		</Translation>
	</TranslationSet>
	<TranslationStack>
		<TermSet>
			<Term>STELLMAN SD[Author]</Term>
			<Field>Author</Field>
			<Count>99</Count>

			<Explode>Y</Explode>
		</TermSet>
		<OP>GROUP</OP>
	</TranslationStack>
</eSearchResult>";

            NCBI.EsearchResults results = NCBI.ParseSearchResults(xml);
            Assert.IsTrue(results.WebEnv == "01jHC0pmRm0V5DX0SCaTpJ0OqIA1N2LSKc2-Uus4KHDqRMj7m9Lz@@u66F4IOFk0AAH4@OH4AAAAQ");
            Assert.IsTrue(results.QueryKey == 1);
            Assert.IsTrue(results.Count == 99);
            Assert.IsTrue(results.Found == true);
        }