Skip to content

Commit

Permalink
Update Application for LocalFileExists.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed May 22, 2024
1 parent 0114e85 commit c1390ff
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### TestAdapter
- Add `GuidFromString` in the `TestCaseUtils`.
- Update `SplitTestName` to check `(` and `"`.
- Update Application for `LocalFileExists`.
### Tests
- Add `TestDoubleCase` with double with `.` in the name.

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.3.3-alpha</Version>
<Version>1.3.3-beta</Version>
</PropertyGroup>
</Project>
25 changes: 22 additions & 3 deletions ricaun.RevitTest.TestAdapter/Services/ApplicationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ public static async Task<bool> DownloadAsync(string applicationFolder, string ad
System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;
try
{
if (File.Exists(address))
if (LocalFileExists(address, out string localFilePath))
{
File.Copy(address, zipPath, true);
AdapterLogger.Logger.DebugOnlyLocal($"Download File Exists: {address}");
File.Copy(localFilePath, zipPath, true);
AdapterLogger.Logger.DebugOnlyLocal($"Download File CurrentDirectory: {Directory.GetCurrentDirectory()}");
AdapterLogger.Logger.DebugOnlyLocal($"Download File Exists: {localFilePath}");
}
else
{
Expand Down Expand Up @@ -135,6 +136,24 @@ public static async Task<bool> DownloadAsync(string applicationFolder, string ad
return result;
}

private static bool LocalFileExists(string filePath, out string localFilePath)
{
localFilePath = filePath;
if (File.Exists(localFilePath)) return true;
try
{
var assemblyDirectory = Path.GetDirectoryName(typeof(ApplicationUtils).Assembly.Location);
localFilePath = Path.Combine(assemblyDirectory, filePath);
if (File.Exists(localFilePath))
{
AdapterLogger.Logger.DebugOnlyLocal($"Download File AssemblyDirectory: {assemblyDirectory}");
return true;
}
}
catch { }
return false;
}

/// <summary>
/// Download and unzip Application Async
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions ricaun.RevitTest.Tests/TestsDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
[assembly: AssemblyMetadata("NUnit.Application", "RICAUN_REVIT_TEST_APPLICATION_DA4R_LOCAL")]
[assembly: AssemblyMetadata("NUnit.Application", "NUNIT_APPLICATION_TEST")]
[assembly: AssemblyMetadata("NUnit.Application", "RICAUN_REVIT_TEST_APPLICATION_DA4R_ONLINE_TEST")]
[assembly: AssemblyMetadata("NUnit.Application", "D:\\Users\\ricau\\source\\repos\\ricaun.RevitTest\\ricaun.RevitTest.Console\\bin\\Debug\\ricaun.RevitTest.Console.exe")]
//[assembly: AssemblyMetadata("NUnit.Language", "ENU /hosted")]
#if NET
[assembly: AssemblyMetadata("NUnit.Application", "..\\..\\..\\..\\ricaun.RevitTest.Console\\bin\\Debug\\net8.0-windows\\ricaun.RevitTest.Console.exe")]
#else
[assembly: AssemblyMetadata("NUnit.Application", "..\\..\\..\\..\\ricaun.RevitTest.Console\\bin\\Debug\\net48\\ricaun.RevitTest.Console.exe")]
#endif

//[assembly: AssemblyMetadata("NUnit.Application", "C:\\Users\\ricau\\Downloads\\SampleTest\\ricaun.DA4R.NUnit.Console.zip")]
//[assembly: AssemblyMetadata("NUnit.Application", "..\\..\\..\\ricaun.RevitTest.Console\\bin\\Debug\\ricaun.RevitTest.Console.exe")]
//[assembly: AssemblyMetadata("NUnit.Language", "ENU /hosted")]
#endif

namespace ricaun.RevitTest.Tests
Expand Down

0 comments on commit c1390ff

Please sign in to comment.