Skip to content

Commit 9afacbb

Browse files
committed
Fix bug when running the unit test on a linux enviroment for GitHub actions.
1 parent ad502db commit 9afacbb

3 files changed

Lines changed: 5 additions & 19 deletions

File tree

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73

84
namespace TestPeterPiper.Support
95
{
106
public static class PathSupport
117
{
12-
public static string AssemblyDirectory
13-
{
14-
get
15-
{
16-
string codeBase = System.Reflection.Assembly.GetExecutingAssembly().Location;
17-
UriBuilder uri = new UriBuilder(codeBase);
18-
string path = Uri.UnescapeDataString(uri.Path);
19-
var DirInfo = new DirectoryInfo(path);
20-
return DirInfo.Parent!.FullName; ;
21-
}
22-
}
8+
public static string AssemblyDirectory => AppContext.BaseDirectory;
239
}
2410
}

TestPeterPiper/TestModel/TestBase64.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class TestBase64
1919
[TestMethod]
2020
public void DecoderTest()
2121
{
22-
string path = Support.PathSupport.AssemblyDirectory + @"\TestResource\ED Data Test.zip";
22+
string path = Path.Combine(Support.PathSupport.AssemblyDirectory, "TestResource", "ED Data Test.zip");
2323

2424
string NewPath = String.Empty;
2525
byte[] item = File.ReadAllBytes(path);

TestPeterPiper/TestModel/TestHl7Reader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TestHl7Reader
2121
public void Hl7ReaderConstructorTest()
2222
{
2323

24-
string path = Support.PathSupport.AssemblyDirectory + @"\TestResource\TestSetOfMsg.dat";
24+
string path = Path.Combine(Support.PathSupport.AssemblyDirectory, "TestResource", "TestSetOfMsg.dat");
2525

2626
Hl7StreamReader target = new Hl7StreamReader(path);
2727
target.Close();
@@ -57,8 +57,8 @@ public void Hl7ReaderConstructorTest()
5757
public void ReadTest()
5858
{
5959

60-
string readpath = Support.PathSupport.AssemblyDirectory + "\\TestResource\\TestSetOfMsg.dat";
61-
string writepath = Support.PathSupport.AssemblyDirectory + "\\TestResource\\TestSetOfMsg2.dat";
60+
string readpath = Path.Combine(Support.PathSupport.AssemblyDirectory, "TestResource", "TestSetOfMsg.dat");
61+
string writepath = Path.Combine(Support.PathSupport.AssemblyDirectory, "TestResource", "TestSetOfMsg2.dat");
6262
if (File.Exists(writepath))
6363
File.Delete(writepath);
6464

0 commit comments

Comments
 (0)