Skip to content

Commit

Permalink
Merge pull request #45 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 1.3.3
  • Loading branch information
ricaun authored May 23, 2024
2 parents f8ce1a1 + 627fd93 commit 433a27f
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 19 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.3.3] / 2024-05-22
### Fixed
- Fix `TestCase` with the same Guid using `GuidFromString`. (Fix: #43)
- Fix `TestCase` with `.` in the name. (Fix: #44)
### TestAdapter
- Add `GuidFromString` in the `TestCaseUtils`.
- Update `SplitTestName` to check `(` and `"`.
- Update Application for `LocalFileExists`.
### Tests
- Add `TestDoubleCase` with double with `.` in the name.

## [1.3.2] / 2024-05-09
### Fixed
- Fix `ApplicationUtils` to clear temp folder after some minutes. (Fix: #41)
Expand Down Expand Up @@ -409,6 +420,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [x] TestsFail

[vNext]: ../../compare/1.0.0...HEAD
[1.3.3]: ../../compare/1.3.2...1.3.3
[1.3.2]: ../../compare/1.3.1...1.3.2
[1.3.1]: ../../compare/1.3.0...1.3.1
[1.3.0]: ../../compare/1.2.1...1.3.0
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.2</Version>
<Version>1.3.3</Version>
</PropertyGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
44 changes: 33 additions & 11 deletions ricaun.RevitTest.TestAdapter/TestCaseUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using System.Linq;

namespace ricaun.RevitTest.TestAdapter
{
Expand Down Expand Up @@ -26,32 +27,53 @@ public static TestCase Create(string source, string testName)
var testCase = new TestCase(fullyQualifiedName, TestAdapter.ExecutorUri, source)
{
DisplayName = displayName,
Id = GuidFromString(testName),
};

return testCase;
}

/// <summary>
/// GuidFromString using EqtHash
/// </summary>
/// <param name="testName"></param>
/// <returns></returns>
/// <remarks>
/// <code>
/// Reference:
/// https://github.com/microsoft/vstest/blob/main/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs#L173
/// https://github.com/microsoft/vstest/blob/main/src/Microsoft.TestPlatform.ObjectModel/Utilities/EqtHash.cs#L20
/// </code>
/// </remarks>
private static System.Guid GuidFromString(string testName)
{
return Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.EqtHash.GuidFromString(testName);
}

#region private

private static void SplitTestName(string testName, out string fullyQualifiedName, out string displayName)
{
var indexOf = LastIndexOfDisplayName(testName);
fullyQualifiedName = testName.Substring(0, indexOf);
displayName = testName.Substring(indexOf + 1);
var splitDots = testName.Split('.');

var index = LastIndexSplitOfDisplayName(splitDots);

fullyQualifiedName = string.Join(".", splitDots.Take(index));
displayName = string.Join(".", splitDots.Skip(index));

AdapterLogger.Logger.DebugOnlyLocal($"SplitTestName: {testName} - {index} {fullyQualifiedName} {displayName}");
}

private static int LastIndexOfDisplayName(string testName)
private static int LastIndexSplitOfDisplayName(string[] splitDots)
{
var lastIndexOfDot = testName.LastIndexOf('.');
var indexOf = testName.IndexOf('"');
if (indexOf != -1)
for (int i = 0; i < splitDots.Length; i++)
{
lastIndexOfDot = testName.LastIndexOf('.', indexOf);
var name = splitDots[i];
if (name.Contains('(') | name.Contains('"'))
return i;
}

return lastIndexOfDot;
return splitDots.Length - 1;
}

#endregion
}
}
11 changes: 11 additions & 0 deletions ricaun.RevitTest.Tests/TestsCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,16 @@ public void TestStringCase_IsNot(string value)
Console.WriteLine(value);
Assert.IsFalse(string.IsNullOrWhiteSpace(value));
}

[TestCase(1.0)]
[TestCase(2.0)]
[TestCase(3.0)]
[TestCase(4.2)]
[TestCase(5.3)]
[TestCase(6.4)]
public void TestDoubleCase(double scale)
{
Assert.NotZero(scale);
}
}
}
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 433a27f

Please sign in to comment.