Skip to content

Commit e5c4ba8

Browse files
authored
Merge pull request #80 from Numpsy/pathsep
fix hard coded path separators in tests
2 parents 624aac7 + b00ecc2 commit e5c4ba8

File tree

5 files changed

+230
-225
lines changed

5 files changed

+230
-225
lines changed

DocumentFormat.OpenXml.Tests/OpenXmlDomTaskLibrary/DataStorage/TestDataStorage.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,37 @@ public TestDataStorage()
3939
throw new Exception("Can't access the root folder of the TestDataStorage at: '" + TestUtil.TestDataStorage + "'");
4040
}
4141

42-
string o14IsoStrictFolder = Path.Combine(TestUtil.TestDataStorage, @"O14ISOStrict\");
43-
string o14ValidationFolder = Path.Combine(TestUtil.TestDataStorage, @"ValidationTestFiles\");
44-
string o15ConformanceFolder = Path.Combine(TestUtil.TestDataStorage, @"O15Conformance\");
45-
string robustnessFolder = Path.Combine(TestUtil.TestDataStorage, @"Robustness\");
46-
string lowLevelFolder = Path.Combine(TestUtil.TestDataStorage, @"SDKLowLevelTestFiles\");
42+
string o14IsoStrictFolder = Path.Combine(TestUtil.TestDataStorage, @"O14ISOStrict");
43+
string o14ValidationFolder = Path.Combine(TestUtil.TestDataStorage, @"ValidationTestFiles");
44+
string o15ConformanceFolder = Path.Combine(TestUtil.TestDataStorage, @"O15Conformance");
45+
string robustnessFolder = Path.Combine(TestUtil.TestDataStorage, @"Robustness");
46+
string lowLevelFolder = Path.Combine(TestUtil.TestDataStorage, @"SDKLowLevelTestFiles");
4747

4848
this.RegisterDataGroup(
4949
new FileDataGroup(
5050
DataGroups.O14IsoStrictWord.ToString(),
5151
"Wordprocessing Files in ISO Strict",
52-
o14IsoStrictFolder + @"Word\"));
52+
Path.Combine(o14IsoStrictFolder, @"Word")));
5353
this.RegisterDataGroup(
5454
new FileDataGroup(
5555
DataGroups.O14IsoStrictExcel.ToString(),
5656
"SpreadsheetML Files in ISO Strict",
57-
o14IsoStrictFolder + @"Excel\"));
57+
Path.Combine(o14IsoStrictFolder, @"Excel")));
5858
this.RegisterDataGroup(
5959
new FileDataGroup(
6060
DataGroups.O14IsoStrictPowerPoint.ToString(),
6161
"PresentationML Files in ISO Strict",
62-
o14IsoStrictFolder + @"PowerPoint\"));
62+
Path.Combine(o14IsoStrictFolder, @"PowerPoint")));
6363
this.RegisterDataGroup(
6464
new FileDataGroup(
6565
DataGroups.O14IsoStrictGraphics.ToString(),
6666
"DrawingML Files in ISO Strict",
67-
o14IsoStrictFolder + @"Graphics\"));
67+
Path.Combine(o14IsoStrictFolder, @"Graphics")));
6868
this.RegisterDataGroup(
6969
new FileDataGroup(
7070
DataGroups.O14IsoStrictAdditional.ToString(),
7171
"Additional Test Files in ISO Strict",
72-
o14IsoStrictFolder + @"AdditionalFiles\"));
72+
Path.Combine(o14IsoStrictFolder, @"AdditionalFiles")));
7373
this.RegisterDataGroup(
7474
new FileDataGroup(
7575
DataGroups.O14Validation.ToString(),
@@ -80,43 +80,43 @@ public TestDataStorage()
8080
new FileDataGroup(
8181
DataGroups.O15ConformanceWord.ToString(),
8282
"O15 Conformance WordprocessingML Test Files",
83-
o15ConformanceFolder + @"WD\"));
83+
Path.Combine(o15ConformanceFolder, @"WD")));
8484
this.RegisterDataGroup(
8585
new FileDataGroup(
8686
DataGroups.O15ConformanceExcel.ToString(),
8787
"O15 Conformance SpreadsheetML Test Files",
88-
o15ConformanceFolder + @"XL\"));
88+
Path.Combine(o15ConformanceFolder, @"XL")));
8989
this.RegisterDataGroup(
9090
new FileDataGroup(
9191
DataGroups.O15ConformancePowerPoint.ToString(),
9292
"O15 Conformance PresentationML Test Files",
93-
o15ConformanceFolder + @"PPT\"));
93+
Path.Combine(o15ConformanceFolder, @"PPT")));
9494
this.RegisterDataGroup(
9595
new FileDataGroup(
9696
DataGroups.O15ConformanceM2.ToString(),
9797
"O15 Conformance M2 Converted Test Files",
98-
o15ConformanceFolder + @"M2\"));
98+
Path.Combine(o15ConformanceFolder, @"M2")));
9999
this.RegisterDataGroup(
100100
new FileDataGroup(
101101
DataGroups.O15ConformanceBeta1.ToString(),
102102
"O15 Conformance Beta1 Converted Test Files",
103-
o15ConformanceFolder + @"Beta1\"));
103+
Path.Combine(o15ConformanceFolder, @"Beta1")));
104104

105105
this.RegisterDataGroup(
106106
new FileDataGroup(
107107
DataGroups.RobustnessOFCAT.ToString(),
108108
"Various Test Files created by non-Office products",
109-
robustnessFolder + @"OFCAT\"));
109+
Path.Combine(robustnessFolder, @"OFCAT")));
110110
this.RegisterDataGroup(
111111
new FileDataGroup(
112112
DataGroups.RobustnessWindowsPhone7.ToString(),
113113
"Various Test Files created by non-Office products",
114-
robustnessFolder + @"WP7\"));
114+
Path.Combine(robustnessFolder, @"WP7")));
115115
this.RegisterDataGroup(
116116
new FileDataGroup(
117117
DataGroups.RobustnessBugRegression.ToString(),
118118
"Various Test Files created by non-Office products",
119-
robustnessFolder + @"BugRegression\"));
119+
Path.Combine(robustnessFolder, @"BugRegression")));
120120

121121
this.RegisterDataGroup(
122122
new FileDataGroup(

DocumentFormat.OpenXml.Tests/OpenXmlDomTaskLibrary/TestScripts/OpenXmlTestBase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ public FileInfo GetSourceFile(FileInfo testFile)
283283
/// <param name="searchPattern">Search pattern of file name. Wildcard chars are allowed.</param>
284284
/// <param name="pred">Filter function which limits files to be searched.</param>
285285
/// <returns></returns>
286-
public IEnumerable<FileInfo> GetTestFiles(string sourceFolder)
286+
public IEnumerable<FileInfo> GetTestFiles(string sourceFolder, string subFolder)
287287
{
288-
string inputPath = Path.Combine(sourcePath, sourceFolder);
288+
string inputPath = Path.Combine(sourcePath, sourceFolder, subFolder);
289289
return new DirectoryInfo(inputPath).GetFiles("*", SearchOption.AllDirectories);
290290
}
291291

@@ -316,6 +316,10 @@ public IEnumerable<FileInfo> CopyTestFiles(string sourceFolder)
316316
Func<FileInfo, bool> pred = IsOpenXmlFile;
317317
return CopyTestFiles(sourceFolder, recursive, searchPattern, pred);
318318
}
319+
public IEnumerable<FileInfo> CopyTestFiles(string sourceFolder, string subFolder)
320+
{
321+
return CopyTestFiles(Path.Combine(sourceFolder, subFolder));
322+
}
319323
private static string[] _wordprocessingExtension = new string[] { ".docx", ".docm", ".dotx", ".dotm" };
320324
private static string[] _spreadsheetExtension = new string[] { ".xlam", ".xltm", ".xlsm", ".xltx", ".xlsx" };
321325
private static string[] _presentationExtension = new string[] { ".ppam", ".pptm", ".ppsm", ".potm", ".pptx", ".ppsx", ".potx" };

DocumentFormat.OpenXml.Tests/OpenXmlDomTest/DocumentTraverseTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Reflection;
55
using System.Xml.Linq;
6+
using System.IO;
67
using DocumentFormat.OpenXml;
78
using DocumentFormat.OpenXml.Packaging;
89
using DocumentFormat.OpenXml.Presentation;
@@ -269,7 +270,7 @@ public void TraverseWordDocument()
269270
{
270271
this.MyTestInitialize(TestContext.GetCurrentMethod());
271272
//description = " Case ID: 75567, 75568, 75505, 75506, 76083, 76084";
272-
foreach (var testfile in CopyTestFiles(@"wordprocessing\paragraph", false, 3))
273+
foreach (var testfile in CopyTestFiles(Path.Combine(@"wordprocessing", "paragraph"), false, 3))
273274
{
274275
Log.BeginGroup(testfile.Name);
275276

@@ -315,7 +316,7 @@ public void TraverseWordDocument()
315316
public void TraverseSpreadSheetDocument()
316317
{
317318
this.MyTestInitialize(TestContext.GetCurrentMethod());
318-
foreach (var testfile in CopyTestFiles(@"SpreadSheet\smallset", false, 3))
319+
foreach (var testfile in CopyTestFiles(Path.Combine(@"spreadsheet", "smallset"), false, 3))
319320
{
320321
Log.BeginGroup(testfile.Name);
321322
Log.Comment("open test file {0} for traversing", testfile);
@@ -362,7 +363,7 @@ public void TraverseSpreadSheetDocument()
362363
public void TraversePPTDocument()
363364
{
364365
this.MyTestInitialize(TestContext.GetCurrentMethod());
365-
foreach (var testfile in CopyTestFiles(@"presentation\smallset", false, 3))
366+
foreach (var testfile in CopyTestFiles(Path.Combine(@"presentation", "smallset"), false, 3))
366367
{
367368
Log.BeginGroup(testfile.Name);
368369
Log.Comment("open test file {0} for traversing", testfile);

0 commit comments

Comments
 (0)