Skip to content

Commit 6cfb94e

Browse files
Fix Dll tests so that they verify each dll file version against an approved list (#3264)
Fix Dll tests so that they verify each dll file version against an approved list.
1 parent 4b99b6b commit 6cfb94e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

test/Libraries/RevitIntegrationTests/RegressionTests.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ public void PackageDllTest()
360360
message.AppendLine("Version Mismatched DLLs:");
361361
foreach (var dll in versionMismatchedDlls)
362362
{
363-
var approvedVersion = approvedDlls.First(ad => ad.Path == dll.Path).Version;
364-
message.AppendLine($"{dll.Path} | Current Version: {dll.Version}, Approved Version: {approvedVersion}");
363+
var approvedDll = approvedDlls.First(ad => ad.Path == dll.Path);
364+
var approvedVersionStr = approvedDll.Version?.ToString() ?? approvedDll.VersionWildcard;
365+
message.AppendLine($"{dll.Path} | Current Version: {dll.Version}, Approved Version: {approvedVersionStr}");
365366
}
366367
}
367368

@@ -466,8 +467,9 @@ public void InstallDllTest()
466467
message.AppendLine("Version Mismatched DLLs:");
467468
foreach (var dll in versionMismatchedDlls)
468469
{
469-
var approvedVersion = approvedDlls.First(ad => ad.Path == dll.Path).Version;
470-
message.AppendLine($"{dll.Path} | Current Version: {dll.Version}, Approved Version: {approvedVersion}");
470+
var approvedDll = approvedDlls.First(ad=> ad.Path == dll.Path);
471+
var approvedVersionStr = approvedDll.Version?.ToString() ?? approvedDll.VersionWildcard;
472+
message.AppendLine($"{dll.Path} | Current Version: {dll.Version}, Approved Version: {approvedVersionStr}");
471473
}
472474
}
473475

@@ -537,22 +539,13 @@ private static List<RegressionTestData> SetupRevitRegressionTests()
537539
return testParameters;
538540
}
539541

540-
private Version GetAssemblyVersion(string assemblyPath)
542+
private static Version GetAssemblyVersion(string assemblyPath)
541543
{
542544
try
543-
{
544-
AssemblyName assemblyName = AssemblyName.GetAssemblyName(assemblyPath);
545-
return assemblyName.Version;
546-
}
547-
catch (BadImageFormatException ex)
548545
{
549546
var versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assemblyPath);
550-
if (!string.IsNullOrEmpty(versionInfo.FileVersion))
551-
{
552-
Version version = new Version(versionInfo.FileMajorPart, versionInfo.FileMinorPart, versionInfo.FileBuildPart, versionInfo.FilePrivatePart);
553-
return version;
554-
}
555-
else return new Version(0, 0, 0, 0);
547+
Version version = new Version(versionInfo.FileMajorPart, versionInfo.FileMinorPart, versionInfo.FileBuildPart, versionInfo.FilePrivatePart);
548+
return version;
556549
}
557550
catch (Exception ex)
558551
{
@@ -586,6 +579,9 @@ public override String ToString()
586579

587580
public bool MatchesPattern(string pattern)
588581
{
582+
if (pattern.Equals("*"))
583+
return true;
584+
589585
string versionStr = this.Version.ToString();
590586
if (pattern.EndsWith("*"))
591587
{

0 commit comments

Comments
 (0)