public void TestParseExamples() { // LUCENENET specific // Rather than relying on a file path somewhere, we store the // files zipped in an embedded resource and unzip them to a // known temp directory for the test. DirectoryInfo examplesDir = CreateTempDir("test-parse-examples"); using (var stream = GetType().getResourceAsStream("conf.zip")) { TestUtil.Unzip(stream, examplesDir); } // hackedy-hack-hack bool foundFiles = false; foreach (FileInfo algFile in examplesDir.EnumerateFiles("*.alg")) { try { Config config = new Config(new StreamReader(new FileStream(algFile.FullName, FileMode.Open, FileAccess.Read), Encoding.UTF8)); String contentSource = config.Get("content.source", null); if (contentSource != null) { if (Type.GetType(contentSource) == null) { throw ClassNotFoundException.Create(contentSource); } } config.Set("work.dir", CreateTempDir(LuceneTestCase.GetTestClass().Name).FullName); config.Set("content.source", typeof(MockContentSource).AssemblyQualifiedName); String dir = config.Get("content.source", null); if (dir != null) { if (Type.GetType(dir) == null) { throw ClassNotFoundException.Create(dir); } } config.Set("directory", typeof(RAMDirectory).AssemblyQualifiedName); if (config.Get("line.file.out", null) != null) { config.Set("line.file.out", CreateTempFile("linefile", ".txt").FullName); } string queryMaker = config.Get("query.maker", null); if (queryMaker != null) { if (Type.GetType(queryMaker) == null) { throw ClassNotFoundException.Create(queryMaker); } config.Set("query.maker", typeof(MockQueryMaker).AssemblyQualifiedName); } PerfRunData data = new PerfRunData(config); new Algorithm(data); } catch (Exception t) when(t.IsThrowable()) { throw AssertionError.Create("Could not parse sample file: " + algFile, t); } foundFiles = true; } if (!foundFiles) { fail("could not find any .alg files!"); } }