public void TestConcurrentAccess() { var sourceFiles1 = new[] { Environment.CurrentDirectory+@"\xyzzy\Example.cs", Environment.CurrentDirectory+@"\foo\bar\MissingFile.cs", Environment.CurrentDirectory+@"\zork\Example.cs", Environment.CurrentDirectory+@"\path\to\file\data.cpp", Environment.CurrentDirectory+@"\path\to\file\data1.cpp", Environment.CurrentDirectory+@"\path\to\file\data2.cpp", Environment.CurrentDirectory+@"\path\to\file\data3.cpp", Environment.CurrentDirectory+@"\path\to\file\data4.cpp", Environment.CurrentDirectory+@"\path\to\file\data5.cpp", Environment.CurrentDirectory+@"\path\to\file\data6.cpp", Environment.CurrentDirectory+@"\path\to\file\data7.cpp", Environment.CurrentDirectory+@"\path\to\file\data8.cpp", Environment.CurrentDirectory+@"\path\to\file\data9.cpp", Environment.CurrentDirectory+@"\path\to\file\data10.cpp", Environment.CurrentDirectory+@"\path\to\file\data11.c" }; var sourceFiles2 = new[] { Environment.CurrentDirectory+@"\foo\bar\Example.cs", Environment.CurrentDirectory+@"\path\to\file\data.cpp", Environment.CurrentDirectory+@"\path\to\file\data1.cpp", Environment.CurrentDirectory+@"\path\to\file\data2.cpp", Environment.CurrentDirectory+@"\foo\bar\ImportantData.cpp", Environment.CurrentDirectory+@"\path\to\file\data3.cpp", Environment.CurrentDirectory+@"\path\to\file\data4.cpp", Environment.CurrentDirectory+@"\path\to\file\data5.cpp", Environment.CurrentDirectory+@"\path\to\file\data6.cpp", Environment.CurrentDirectory+@"\path\to\file\data7.cpp", Environment.CurrentDirectory+@"\path\to\file\data8.cpp", Environment.CurrentDirectory+@"\path\to\file\data9.cpp", Environment.CurrentDirectory+@"\other\dir\Sample.h", Environment.CurrentDirectory+@"\path\to\file\data10.cpp", Environment.CurrentDirectory+@"\path\to\file\data11.c" }; var xmlFiles = new[] { Environment.CurrentDirectory+@"\mappingTest\Example.cs.1.xml", Environment.CurrentDirectory+@"\mappingTest\MissingFile.cs.1.xml", Environment.CurrentDirectory+@"\mappingTest\Example.cs.2.xml", Environment.CurrentDirectory+@"\mappingTest\data.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data1.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data2.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data3.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data4.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data5.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data6.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data7.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data8.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data9.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data10.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\data11.c.1.xml", Environment.CurrentDirectory+@"\mappingTest\Example.cs.3.xml", Environment.CurrentDirectory+@"\mappingTest\ImportantData.cpp.1.xml", Environment.CurrentDirectory+@"\mappingTest\Sample.h.1.xml", }; var map = new SrcMLFileNameMapping("mappingTest"); var worker = new Thread(() => ConcurrentWorker(map, sourceFiles2)); worker.Start(); foreach(var file in sourceFiles1) { map.GetTargetPath(file); } worker.Join(5000); map.SaveMapping(); var obsSourceFiles = new HashSet<string>(); var obsXmlFiles = new HashSet<string>(); foreach(var entry in File.ReadAllLines("mappingTest\\mapping.txt")) { var fields = entry.Split('|'); obsSourceFiles.Add(fields[0]); obsXmlFiles.Add(fields[1]); } var sourceFiles = sourceFiles1.Union(sourceFiles2); Assert.AreEqual(sourceFiles.Count(), obsSourceFiles.Count); Assert.AreEqual(xmlFiles.Count(), obsXmlFiles.Count); foreach(var file in obsSourceFiles) { Assert.IsTrue(sourceFiles.Contains(file)); } foreach(var file in obsXmlFiles) { Assert.IsTrue(xmlFiles.Contains(file)); } }