Skip to content

Commit cc6ac49

Browse files
committed
New XUnit tests
1 parent 9085f77 commit cc6ac49

File tree

883 files changed

+21938
-4374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

883 files changed

+21938
-4374
lines changed

Clean.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ri -Recurse .\DocumentFormat.OpenXml.Tests\bin
2+
ri -Recurse .\DocumentFormat.OpenXml.Tests\obj
3+
ri -Recurse .\DocumentFormat.OpenXml.WB.Tests\bin
4+
ri -Recurse .\DocumentFormat.OpenXml.WB.Tests\obj
5+
ri -Recurse .\System.IO.Packaging.Tests\bin
6+
ri -Recurse .\System.IO.Packaging.Tests\obj

DocumentFormat.OpenXml.Tests/BaseFixture.cs

+24-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,28 @@ namespace DocumentFormat.OpenXml.Tests
3636
[SuppressMessage("ReSharper", "VirtualMemberNeverOverriden.Global")]
3737
public class BaseFixture : IDisposable
3838
{
39-
protected const string TestFilesPath = @"..\..\..\TestFiles";
39+
protected static string s_TestFileLocation = null;
40+
41+
public static string TestFilesPath
42+
{
43+
get
44+
{
45+
if (s_TestFileLocation != null)
46+
return s_TestFileLocation;
47+
// find the directory, wherever it may be, to get to the TestFiles directory
48+
var dir = new DirectoryInfo(Environment.CurrentDirectory);
49+
while (true)
50+
{
51+
if (dir.Name == "DocumentFormat.OpenXml.Tests" || dir.Name == "DocumentFormat.OpenXml.WB.Tests")
52+
break;
53+
dir = dir.Parent;
54+
}
55+
dir = dir.Parent; // go up one more, to the parent of the above dirs
56+
var testDataStorageDirInfo = new DirectoryInfo(Path.Combine(dir.FullName, "TestFiles/"));
57+
s_TestFileLocation = testDataStorageDirInfo.FullName;
58+
return s_TestFileLocation;
59+
}
60+
}
4061

4162
protected BaseFixture()
4263
{
@@ -64,7 +85,8 @@ protected static string GetTestFilePath(string path)
6485
if (path == null)
6586
throw new ArgumentNullException("path");
6687

67-
return Path.Combine(TestFilesPath, Path.GetFileName(path));
88+
var combinedPath = Path.Combine(TestFilesPath, Path.GetFileName(path));
89+
return combinedPath;
6890
}
6991

7092
/// <summary>

DocumentFormat.OpenXml.Tests/Common/TestContext.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
using System;
23
using System.Collections.Generic;
34
using System.Diagnostics;
45
using System.Linq;

DocumentFormat.OpenXml.Tests/Common/VerifiableLog.cs

+561
Large diffs are not rendered by default.

DocumentFormat.OpenXml.Tests/ConformanceTest/ChartTrackingRefBased/ChartTrackingRefBasedTest.cs

+40-57
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -8,14 +9,18 @@ namespace DocumentFormat.OpenXml.Tests.ChartTrackingRefBased
89
using Xunit;
910
using DocumentFormat.OpenXml.Tests.TaskLibraries;
1011
using DocumentFormat.OpenXml.Tests.ChartTrackingRefBasedClass;
12+
using LogUtil;
13+
using System.IO;
14+
using OxTest;
1115

1216
public class ChartTrackingRefBasedTest : OpenXmlTestBase
1317
{
14-
private readonly string generateDocumentFile = "TestChartTrackingRefBasedBase.pptx";
15-
private readonly string editDocumentFile = "EditedChartTrackingRefBased.pptx";
16-
private readonly string deleteDocumentFile = "DeletedChartTrackingRefBased.pptx";
17-
private readonly string addDocumentFile = "AddedChartTrackingRefBased.pptx";
18-
18+
//private readonly string generateDocumentFile = "TestChartTrackingRefBasedBase.pptx";
19+
private readonly string generateDocumentFile = Path.Combine(TestUtil.TestResultsDirectory, Guid.NewGuid().ToString() + ".pptx");
20+
private readonly string editDocumentFile = Path.Combine(TestUtil.TestResultsDirectory, Guid.NewGuid().ToString() + ".pptx");
21+
private readonly string deleteDocumentFile = Path.Combine(TestUtil.TestResultsDirectory, Guid.NewGuid().ToString() + ".pptx");
22+
private readonly string addDocumentFile = Path.Combine(TestUtil.TestResultsDirectory, Guid.NewGuid().ToString() + ".pptx");
23+
1924
private TestEntities testEntities = null;
2025

2126
#region Constructor
@@ -24,8 +29,6 @@ public class ChartTrackingRefBasedTest : OpenXmlTestBase
2429
/// </summary>
2530
public ChartTrackingRefBasedTest()
2631
{
27-
// Set the flag to notify MSTest of Ots Log failure
28-
this.OtsLogFailureToFailTest = true;
2932
}
3033
#endregion
3134

@@ -36,17 +39,10 @@ public ChartTrackingRefBasedTest()
3639
/// <param name="createFilePath">Create Power Point file path</param>
3740
private void Initialize(string createFilePath)
3841
{
39-
try
40-
{
41-
GeneratedDocument generatedDocument = new GeneratedDocument();
42-
generatedDocument.CreatePackage(createFilePath);
43-
44-
this.testEntities = new TestEntities(createFilePath);
45-
}
46-
catch (Exception e)
47-
{
48-
this.Log.Fail(string.Format(e.Message + ". :File path={0}", createFilePath));
49-
}
42+
GeneratedDocument generatedDocument = new GeneratedDocument();
43+
generatedDocument.CreatePackage(createFilePath);
44+
45+
this.testEntities = new TestEntities(createFilePath);
5046
}
5147
#endregion
5248

@@ -68,20 +64,13 @@ protected override void TestInitializeOnce()
6864
public void ChartTrackingRefBasedTest01()
6965
{
7066
this.MyTestInitialize(TestContext.GetCurrentMethod());
71-
try
72-
{
73-
string originalFilepath = this.GetTestFilePath(this.generateDocumentFile);
74-
string editFilePath = this.GetTestFilePath(this.editDocumentFile);
75-
76-
System.IO.File.Copy(originalFilepath, editFilePath, true);
77-
78-
this.testEntities.EditElements(editFilePath, this.Log);
79-
this.testEntities.VerifyElements(editFilePath, this.Log);
80-
}
81-
catch (Exception e)
82-
{
83-
this.Log.Fail(e.Message);
84-
}
67+
string originalFilepath = this.GetTestFilePath(this.generateDocumentFile);
68+
string editFilePath = this.GetTestFilePath(this.editDocumentFile);
69+
70+
System.IO.File.Copy(originalFilepath, editFilePath, true);
71+
72+
this.testEntities.EditElements(editFilePath, this.Log);
73+
this.testEntities.VerifyElements(editFilePath, this.Log);
8574
}
8675

8776
/// <summary>
@@ -91,30 +80,24 @@ public void ChartTrackingRefBasedTest01()
9180
public void ChartTrackingRefBasedTest03DeleteElement()
9281
{
9382
this.MyTestInitialize(TestContext.GetCurrentMethod());
94-
try
95-
{
96-
string originalFilepath = this.GetTestFilePath(this.generateDocumentFile);
97-
string deleteFilePath = this.GetTestFilePath(this.deleteDocumentFile);
98-
string addFilePath = this.GetTestFilePath(this.addDocumentFile);
99-
100-
System.IO.File.Copy(originalFilepath, deleteFilePath, true);
101-
this.Log.Comment("File copy [{0}] to [{1}]", originalFilepath, deleteFilePath);
102-
103-
this.testEntities.DeleteElements(deleteFilePath, this.Log);
104-
this.testEntities.VerifyDeleteElements(deleteFilePath, this.Log);
105-
106-
System.IO.File.Copy(deleteFilePath, addFilePath, true);
107-
this.Log.Comment("File copy [{0}] to [{1}]", originalFilepath, deleteFilePath);
108-
109-
this.testEntities.AddElements(addFilePath, this.Log);
110-
this.testEntities.VerifyAddElements(addFilePath, this.Log);
111-
112-
this.Log.Pass("Element deletion is complete.");
113-
}
114-
catch (Exception e)
115-
{
116-
this.Log.Fail(e.Message);
117-
}
83+
84+
string originalFilepath = this.GetTestFilePath(this.generateDocumentFile);
85+
string deleteFilePath = this.GetTestFilePath(this.deleteDocumentFile);
86+
string addFilePath = this.GetTestFilePath(this.addDocumentFile);
87+
88+
System.IO.File.Copy(originalFilepath, deleteFilePath, true);
89+
this.Log.Comment("File copy [{0}] to [{1}]", originalFilepath, deleteFilePath);
90+
91+
this.testEntities.DeleteElements(deleteFilePath, this.Log);
92+
this.testEntities.VerifyDeleteElements(deleteFilePath, this.Log);
93+
94+
System.IO.File.Copy(deleteFilePath, addFilePath, true);
95+
this.Log.Comment("File copy [{0}] to [{1}]", originalFilepath, deleteFilePath);
96+
97+
this.testEntities.AddElements(addFilePath, this.Log);
98+
this.testEntities.VerifyAddElements(addFilePath, this.Log);
99+
100+
this.Log.Pass("Element deletion is complete.");
118101
}
119102

120103
#endregion

DocumentFormat.OpenXml.Tests/ConformanceTest/ChartTrackingRefBased/GeneratedDocument.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
12
using DocumentFormat.OpenXml.Packaging;
23
using DocumentFormat.OpenXml.Presentation;
34
using P = DocumentFormat.OpenXml.Presentation;

0 commit comments

Comments
 (0)