Skip to content

Commit

Permalink
Fixed file relatated tests for AppVeyor and Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
axunonb committed Jan 5, 2021
1 parent a98801c commit 7fc3fd9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 0 additions & 6 deletions MailMergeLib.Tests/MessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ public class MessageFactory
public const string PdfFile = "Sample.pdf";
public const string Subject = "Logfile for {Date:yyyy-MM-dd}";
public const string MyContentId = "my.content.id";
public string PathRelativeToCodebase {
get{
char slash = Path.DirectorySeparatorChar;
return $"..{slash}..{slash}TestFiles{slash}";
}
}

public static MailMergeMessage GetHtmlMailWithInlineAndOtherAttachments()
{
Expand Down
2 changes: 1 addition & 1 deletion MailMergeLib.Tests/Message_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void MessageConfig_FileBaseDirectory_cannot_be_changed_by_Html_Base_Tag()
mmm.Config.FileBaseDirectory = Path.GetTempPath();

var hbb = new HtmlBodyBuilder(mmm, (object) null);
Assert.AreEqual(new Uri(mmm.Config.FileBaseDirectory), hbb.DocBaseUri);
Assert.AreEqual( new Uri(mmm.Config.FileBaseDirectory), hbb.DocBaseUri);
}

[Test]
Expand Down
18 changes: 13 additions & 5 deletions MailMergeLib.Tests/TestFileFolders.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
using System.IO;
using System.Runtime;

namespace MailMergeLib.Tests
{
internal static class TestFileFolders
{
public static string PathRelativeToCodebase {
get{
char slash = Path.DirectorySeparatorChar;
return $"..{slash}..{slash}..{slash}TestFiles{slash}";
private static string Get_TestFiles_Path_From_CodeBase()
{
var codeBaseDir = Helper.GetCodeBaseDirectory();
var di = new DirectoryInfo(codeBaseDir);
while (di.Parent != null)
{
di = di.Parent;
var testFileDirectory = Path.Combine(di.FullName, "TestFiles" + Path.DirectorySeparatorChar);
if (Directory.Exists(testFileDirectory)) return testFileDirectory;
}

return di.Root.FullName;
}

public static string FilesAbsPath = Path.GetFullPath(Path.Combine(Helper.GetCodeBaseDirectory(), PathRelativeToCodebase));
public static string FilesAbsPath = Get_TestFiles_Path_From_CodeBase();
}
}

0 comments on commit 7fc3fd9

Please sign in to comment.