Skip to content

Update baseline test #8014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 30 additions & 25 deletions test/SharedFx.UnitTests/SharedFxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,45 @@ public async Task BaselineTest(SharedFxConfig config)
}

var zipPath = Path.Combine(AppContext.BaseDirectory, zipName);
var tempDirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

if (!Directory.Exists(AppContext.BaseDirectory + "unzipped"))
try
{
ZipFile.ExtractToDirectory(AppContext.BaseDirectory, "unzipped");
}

var nugetAssembliesPath = Path.Combine(AppContext.BaseDirectory, "unzipped", "shared", config.Name, previousVersion);
Directory.CreateDirectory(tempDirectoryPath);
ZipFile.ExtractToDirectory(zipPath, tempDirectoryPath);
var nugetAssembliesPath = Path.Combine(tempDirectoryPath, "shared", config.Name, previousVersion);

var files = Directory.GetFiles(nugetAssembliesPath, "*.dll");
foreach (var file in files)
{
try
var files = Directory.GetFiles(nugetAssembliesPath, "*.dll");
foreach (var file in files)
{
var assemblyVersion = AssemblyName.GetAssemblyName(file).Version;
var dllName = Path.GetFileName(file);
nugetAssemblyVersions.Add(dllName, assemblyVersion);
try
{
var assemblyVersion = AssemblyName.GetAssemblyName(file).Version;
var dllName = Path.GetFileName(file);
nugetAssemblyVersions.Add(dllName, assemblyVersion);
}
catch (BadImageFormatException) { }
}
catch (BadImageFormatException) { }
}

files = Directory.GetFiles(dir, "*.dll");
files = Directory.GetFiles(dir, "*.dll");

Assert.All(files, file =>
{
try
Assert.All(files, file =>
{
var localAssemblyVersion = AssemblyName.GetAssemblyName(file).Version;
var dllName = Path.GetFileName(file);
Assert.True(nugetAssemblyVersions.ContainsKey(dllName), $"Expected {dllName} to be in the downloaded dlls");
Assert.True(localAssemblyVersion.CompareTo(nugetAssemblyVersions[dllName]) >= 0, $"Expected the local version of {dllName} to be greater than or equal to the already released version.");
}
catch (BadImageFormatException) { }
try
{
var localAssemblyVersion = AssemblyName.GetAssemblyName(file).Version;
var dllName = Path.GetFileName(file);
Assert.Contains(dllName, nugetAssemblyVersions.Keys);
Assert.InRange(localAssemblyVersion.CompareTo(nugetAssemblyVersions[dllName]), 0, int.MaxValue);
}
catch (BadImageFormatException) { }

});
});
}
finally
{
Directory.Delete(tempDirectoryPath, true);
}
}

[Theory]
Expand Down