Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/AppIconTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void TestXCAssetsImpl (ApplePlatform platform, string runtimeIdentifiers, Dictio

try {
var doc = AssetsTest.ProcessAssets (assetsCar, AssetsTest.GetFullSdkVersion (platform, runtimeIdentifiers));
Assert.IsNotNull (doc, "There was an issue processing the asset binary.");
Assert.That (doc, Is.Not.Null, "There was an issue processing the asset binary.");

var foundAssets = AssetsTest.FindAssets (platform, doc);

Expand All @@ -666,7 +666,7 @@ void TestXCAssetsImpl (ApplePlatform platform, string runtimeIdentifiers, Dictio
expectedAssets.Add (asset);
}

CollectionAssert.AreEquivalent (expectedAssets, foundAssets, "Incorrect assets");
Assert.That (foundAssets, Is.EquivalentTo (expectedAssets), "Incorrect assets");
} catch {
Console.WriteLine ($"Assets.car: {assetsCar}");
throw;
Expand Down
18 changes: 9 additions & 9 deletions tests/dotnet/UnitTests/AssetsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void TestXCAssetsImpl (ApplePlatform platform, string runtimeIdentifiers, bool i
Assert.That (assetsCar, Does.Exist, "Assets.car");

var doc = ProcessAssets (assetsCar, GetFullSdkVersion (platform, runtimeIdentifiers));
Assert.IsNotNull (doc, "There was an issue processing the asset binary.");
Assert.That (doc, Is.Not.Null, "There was an issue processing the asset binary.");

var foundAssets = FindAssets (platform, doc);

Expand All @@ -78,12 +78,12 @@ void TestXCAssetsImpl (ApplePlatform platform, string runtimeIdentifiers, bool i
throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
}

CollectionAssert.AreEquivalent (expectedAssets, foundAssets, $"Incorrect assets in {assetsCar}");
Assert.That (foundAssets, Is.EquivalentTo (expectedAssets), $"Incorrect assets in {assetsCar}");

var arm64txt = Path.Combine (resourcesDirectory, "arm64.txt");
var x64txt = Path.Combine (resourcesDirectory, "x64.txt");
Assert.AreEqual (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-arm64")), File.Exists (arm64txt), "arm64.txt");
Assert.AreEqual (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-x64")), File.Exists (x64txt), "x64.txt");
Assert.That (File.Exists (arm64txt), Is.EqualTo (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-arm64"))), "arm64.txt");
Assert.That (File.Exists (x64txt), Is.EqualTo (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-x64"))), "x64.txt");
}

void ConfigureAssets (string projectPath, string runtimeIdentifiers, string config, bool isStartingWithAssets)
Expand Down Expand Up @@ -128,7 +128,7 @@ void MakeSymlinks (string sourceDir, string destDir)
var executable = "ln";
var arguments = new string [] { "-s", sourceDir, destDir };
var rv = Execution.RunAsync (executable, arguments, timeout: TimeSpan.FromSeconds (60)).Result;
Assert.AreEqual (0, rv.ExitCode, $"Creating Symlink Error: {rv.Output.MergedOutput}. Unexpected ExitCode");
Assert.That (rv.ExitCode, Is.EqualTo (0), $"Creating Symlink Error: {rv.Output.MergedOutput}. Unexpected ExitCode");
}

public static string GetFullSdkVersion (ApplePlatform platform, string runtimeIdentifiers)
Expand Down Expand Up @@ -161,12 +161,12 @@ void ProcessUpdateSymlink (string xcassetsDir)
var assets = Directory.EnumerateFiles (xcassetsDir, "*.*", SearchOption.AllDirectories).ToArray ();

// assets first value is a .DS_Store file that work trigger MSBuild recompile so we want the second value
Assert.Greater (assets.Length, 1);
Assert.That (assets.Length, Is.GreaterThan (1));

var executable = "touch";
var arguments = new string [] { assets [1] };
var rv = Execution.RunAsync (executable, arguments, timeout: TimeSpan.FromSeconds (120)).Result;
Assert.AreEqual (0, rv.ExitCode, $"Processing Update Symlink Error: {rv.Output.MergedOutput}. Unexpected ExitCode");
Assert.That (rv.ExitCode, Is.EqualTo (0), $"Processing Update Symlink Error: {rv.Output.MergedOutput}. Unexpected ExitCode");
}

public static JsonDocument ProcessAssets (string assetsPath, string sdkVersion)
Expand All @@ -176,7 +176,7 @@ public static JsonDocument ProcessAssets (string assetsPath, string sdkVersion)
var tmpfile = Path.Combine (tmpdir, "Assets.json");
var arguments = new string [] { "--sdk", sdkVersion, "assetutil", "--info", assetsPath, "-o", tmpfile };
var rv = Execution.RunAsync (executable, arguments, timeout: TimeSpan.FromSeconds (120)).Result;
Assert.AreEqual (0, rv.ExitCode, $"Processing Assets Error: {rv.Output.StandardError}. Unexpected ExitCode");
Assert.That (rv.ExitCode, Is.EqualTo (0), $"Processing Assets Error: {rv.Output.StandardError}. Unexpected ExitCode");
var s = File.ReadAllText (tmpfile);

try {
Expand Down Expand Up @@ -212,7 +212,7 @@ public static HashSet<string> FindAssets (ApplePlatform platform, JsonDocument d
case ApplePlatform.MacCatalyst:
case ApplePlatform.iOS:
case ApplePlatform.TVOS:
Assert.AreEqual ("2", schemaVersion.ToString (), "Verify SchemaVersion");
Assert.That (schemaVersion.ToString (), Is.EqualTo ("2"), "Verify SchemaVersion");
break;
default:
throw new ArgumentOutOfRangeException ($"Unknown platform: {platform}");
Expand Down
10 changes: 5 additions & 5 deletions tests/dotnet/UnitTests/BundleStructureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers, CodeSignat
var appExecutable = GetNativeExecutable (platform, appPath);

CheckAppBundleContents (platform, appPath, rids, signature, isReleaseBuild);
CollectionAssert.AreEqual (expectedWarnings, warningMessages, "Warnings");
Assert.That (warningMessages, Is.EqualTo (expectedWarnings), "Warnings");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

// touch AppDelegate.cs, and rebuild should succeed and do the right thing
Expand All @@ -692,7 +692,7 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers, CodeSignat
warningMessages = FilterWarnings (warnings);

CheckAppBundleContents (platform, appPath, rids, signature, isReleaseBuild);
CollectionAssert.AreEqual (expectedWarnings, warningMessages, "Warnings Rebuild 1");
Assert.That (warningMessages, Is.EqualTo (expectedWarnings), "Warnings Rebuild 1");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

// remove the bin directory, and rebuild should succeed and do the right thing
Expand All @@ -704,7 +704,7 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers, CodeSignat
warningMessages = FilterWarnings (warnings);

CheckAppBundleContents (platform, appPath, rids, signature, isReleaseBuild);
CollectionAssert.AreEqual (expectedWarnings, warningMessages, "Warnings Rebuild 2");
Assert.That (warningMessages, Is.EqualTo (expectedWarnings), "Warnings Rebuild 2");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

// a simple rebuild should succeed
Expand All @@ -713,7 +713,7 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers, CodeSignat
warningMessages = FilterWarnings (warnings);

CheckAppBundleContents (platform, appPath, rids, signature, isReleaseBuild);
CollectionAssert.AreEqual (expectedWarnings, warningMessages, "Warnings Rebuild 3");
Assert.That (warningMessages, Is.EqualTo (expectedWarnings), "Warnings Rebuild 3");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
}

Expand Down Expand Up @@ -794,7 +794,7 @@ static void AssertLibraryArchitectures (string appBundle, string [] runtimeIdent
});
foreach (var lib in libraries) {
var libArchitectures = renderArchitectures (MachO.GetArchitectures (lib));
Assert.AreEqual (expectedArchitectures, libArchitectures, $"Architectures in {lib}");
Assert.That (libArchitectures, Is.EqualTo (expectedArchitectures), $"Architectures in {lib}");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/dotnet/UnitTests/DotNetUnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="NUnit" Version="$(NUnitPackageVersion)" />
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnit3TestAdapterPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Mono.Cecil" Version="$(MonoCecilPackageVersion)" />
<PackageReference Include="MSBuild.StructuredLogger" Version="$(MSBuildStructuredLoggerPackageVersion)" />
<PackageReference Include="NUnitXml.TestLogger" Version="$(NUnitXmlTestLoggerPackageVersion)" />
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/UnitTests/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void AssertWarnings (this IEnumerable<BuildLogEvent> actualWarning
Console.WriteLine ($"If this is expected, an updated list of expected warnings in stored in {fn}");
File.WriteAllText (fn, sb.ToString ());

// Rather than doing an Assert.IsEmpty, which produces a horrendous error message, we'll do an Assert.Multiple which generates a
// Rather than doing an Assert.That(..., Is.Empty), which produces a horrendous error message, we'll do an Assert.Multiple which generates a
// nice enumerated output of all the failures.
Assert.Multiple (() => {
// fail for each of the new warnings
Expand Down
21 changes: 10 additions & 11 deletions tests/dotnet/UnitTests/MauiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,18 @@ void BuildMauiAppImpl (ApplePlatform platform, string runtimeIdentifiers, bool d
AssertThatLinkerExecuted (rv);
var infoPlistPath = GetInfoPListPath (platform, appPath);
var infoPlist = PDictionary.OpenFile (infoPlistPath);
Assert.AreEqual ("com.xamarin.mymauiapp", infoPlist.GetString ("CFBundleIdentifier").Value, "CFBundleIdentifier");
Assert.AreEqual ("MyMauiApp", infoPlist.GetString ("CFBundleDisplayName").Value, "CFBundleDisplayName");
Assert.AreEqual ("1", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion");
Assert.AreEqual ("1.0", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
Assert.That (infoPlist.GetString ("CFBundleIdentifier").Value, Is.EqualTo ("com.xamarin.mymauiapp"), "CFBundleIdentifier");
Assert.That (infoPlist.GetString ("CFBundleDisplayName").Value, Is.EqualTo ("MyMauiApp"), "CFBundleDisplayName");
Assert.That (infoPlist.GetString ("CFBundleVersion").Value, Is.EqualTo ("1"), "CFBundleVersion");
Assert.That (infoPlist.GetString ("CFBundleShortVersionString").Value, Is.EqualTo ("1.0"), "CFBundleShortVersionString");

Assert.That (BinLog.TryFindPropertyValue (rv.BinLogPath, "TrimMode", out var trimModeValue), Is.True, "Could not find the property 'TrimMode' in the binlog.");
Assert.That (BinLog.TryFindPropertyValue (rv.BinLogPath, "_LinkMode", out var linkModeValue), Is.True, "Could not find the property '_LinkMode' in the binlog.");
Assert.That (BinLog.TryFindPropertyValue (rv.BinLogPath, "MtouchLink", out var mtouchLinkValue), Is.True, "Could not find the property 'MtouchLink' in the binlog.");

Assert.IsTrue (BinLog.TryFindPropertyValue (rv.BinLogPath, "TrimMode", out var trimModeValue), "Could not find the property 'TrimMode' in the binlog.");
Assert.IsTrue (BinLog.TryFindPropertyValue (rv.BinLogPath, "_LinkMode", out var linkModeValue), "Could not find the property '_LinkMode' in the binlog.");
Assert.IsTrue (BinLog.TryFindPropertyValue (rv.BinLogPath, "MtouchLink", out var mtouchLinkValue), "Could not find the property 'MtouchLink' in the binlog.");

Assert.AreEqual ("copy", trimModeValue, "TrimMode");
Assert.AreEqual ("None", linkModeValue, "LinkMode");
Assert.AreEqual ("None", mtouchLinkValue, "MtouchLink");
Assert.That (trimModeValue, Is.EqualTo ("copy"), "TrimMode");
Assert.That (linkModeValue, Is.EqualTo ("None"), "LinkMode");
Assert.That (mtouchLinkValue, Is.EqualTo ("None"), "MtouchLink");
}

[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")]
Expand Down
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/MlaunchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void GetMlaunchInstallArguments (ApplePlatform platform, string runtimeId
expectedArguments.Append ("--installdev ");
expectedArguments.Append (appPath.Substring (Path.GetDirectoryName (project_path)!.Length + 1)).Append ('/');
expectedArguments.Append ($" --wait-for-exit:false");
Assert.AreEqual (expectedArguments.ToString (), mlaunchInstallArguments);
Assert.That (mlaunchInstallArguments, Is.EqualTo (expectedArguments.ToString ()));

var scriptContents = File.ReadAllText (outputPath).Trim ('\n');
var expectedScriptContents = mlaunchPath + " " + expectedArguments.ToString ();
Assert.AreEqual (expectedScriptContents, scriptContents, "Script contents");
Assert.That (scriptContents, Is.EqualTo (expectedScriptContents), "Script contents");
}

public static object [] GetMlaunchRunArgumentsTestCases ()
Expand Down
14 changes: 7 additions & 7 deletions tests/dotnet/UnitTests/PackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void BindingOldStyleImpl (ApplePlatform platform, Dictionary<string, string>? pr

var rv = DotNet.AssertPackFailure (project_path, properties, msbuildParallelism: false);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, errors.Length, "Error count");
Assert.AreEqual ($"Creating a NuGet package is not supported for projects that have ObjcBindingNativeLibrary items. Migrate to use NativeReference items instead.", errors [0].Message, "Error message");
Assert.That (errors.Length, Is.EqualTo (1), "Error count");
Assert.That (errors [0].Message, Is.EqualTo ($"Creating a NuGet package is not supported for projects that have ObjcBindingNativeLibrary items. Migrate to use NativeReference items instead."), "Error message");
}

[Test]
Expand Down Expand Up @@ -191,8 +191,8 @@ void BindingXcFrameworksProjectImpl (ApplePlatform platform, bool noBindingEmbed
var assemblyName = "bindings-framework-test";

if (!noBindingEmbedding) {
Assert.IsFalse (platformSpecificXcframework, "Invalid test variation: platformSpecificXcframework");
Assert.IsFalse (compressedXcframework, "Invalid test variation: compressedXcframework");
Assert.That (platformSpecificXcframework, Is.False, "Invalid test variation: platformSpecificXcframework");
Assert.That (compressedXcframework, Is.False, "Invalid test variation: compressedXcframework");
}

if (!platformSpecificXcframework) {
Expand Down Expand Up @@ -365,7 +365,7 @@ void BindingCompressedXcFrameworksProjectImpl (ApplePlatform platform, bool comp
using var archive = ZipFile.OpenRead (nupkg);
var files = archive.Entries.Select (v => v.FullName).ToHashSet ();
var tfm = platform.ToFrameworkWithPlatformVersion (isExecutable: false);
Assert.AreEqual (compressed ? 6 : 9, archive.Entries.Count, $"nupkg file count - {nupkg}");
Assert.That (archive.Entries.Count, Is.EqualTo (compressed ? 6 : 9), $"nupkg file count - {nupkg}");
Assert.That (files, Does.Contain (assemblyName + ".nuspec"), "nuspec");
Assert.That (files, Does.Contain ("_rels/.rels"), ".rels");
Assert.That (files, Does.Contain ("[Content_Types].xml"), "[Content_Types].xml");
Expand All @@ -382,7 +382,7 @@ void BindingCompressedXcFrameworksProjectImpl (ApplePlatform platform, bool comp
"XStaticArTest.xcframework.zip",
"XStaticObjectTest.xcframework.zip",
};
CollectionAssert.AreEqual (innerZipContents.OrderBy (v => v), innerZip.OrderBy (v => v), "Inner zip");
Assert.That (innerZip.OrderBy (v => v), Is.EqualTo (innerZipContents.OrderBy (v => v)), "Inner zip");
manifest = ZipHelpers.GetInnerString (nupkg, resourcesZip, "manifest");
} else {
Assert.That (files, Does.Contain ($"lib/{tfm}/{assemblyName}.resources/manifest"), $"manifest");
Expand Down Expand Up @@ -431,7 +431,7 @@ void BindingCompressedXcFrameworksProjectImpl (ApplePlatform platform, bool comp
</NativeReference>
</BindingAssembly>
""";
Assert.AreEqual (expectedManifest, manifest, "manifest contents");
Assert.That (manifest, Is.EqualTo (expectedManifest), "manifest contents");
}

[Test]
Expand Down
14 changes: 7 additions & 7 deletions tests/dotnet/UnitTests/PartialAppManifestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers)

var infoPlistPath = GetInfoPListPath (platform, appPath);
var infoPlist = PDictionary.OpenFile (infoPlistPath);
Assert.AreEqual ("com.xamarin.mypartialappmanifestapp", infoPlist.GetString ("CFBundleIdentifier").Value, "CFBundleIdentifier");
Assert.AreEqual ("MyPartialAppManifestApp", infoPlist.GetString ("CFBundleDisplayName").Value, "CFBundleDisplayName");
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion");
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
Assert.AreEqual ("SomeValue", infoPlist.GetString ("Something").Value, "Something");
Assert.That (infoPlist.GetString ("CFBundleIdentifier").Value, Is.EqualTo ("com.xamarin.mypartialappmanifestapp"), "CFBundleIdentifier");
Assert.That (infoPlist.GetString ("CFBundleDisplayName").Value, Is.EqualTo ("MyPartialAppManifestApp"), "CFBundleDisplayName");
Assert.That (infoPlist.GetString ("CFBundleVersion").Value, Is.EqualTo ("3.14"), "CFBundleVersion");
Assert.That (infoPlist.GetString ("CFBundleShortVersionString").Value, Is.EqualTo ("3.14"), "CFBundleShortVersionString");
Assert.That (infoPlist.GetString ("Something").Value, Is.EqualTo ("SomeValue"), "Something");

var partialAppManifestPath = Path.Combine (Path.GetDirectoryName (project_path)!, "..", "Partial.plist");
Configuration.Touch (partialAppManifestPath);
Expand Down Expand Up @@ -56,13 +56,13 @@ public void AppWithLibraryWithResourcesReference (ApplePlatform platform, string

var infoPlistPath = GetInfoPListPath (platform, appPath);
var infoPlist = PDictionary.OpenFile (infoPlistPath);
Assert.AreEqual ("Here I am", infoPlist.GetString ("LibraryWithResources").Value, "LibraryWithResources 1");
Assert.That (infoPlist.GetString ("LibraryWithResources").Value, Is.EqualTo ("Here I am"), "LibraryWithResources 1");

// build again, nothing should change
DotNet.AssertBuild (project_path, properties);

infoPlist = PDictionary.OpenFile (infoPlistPath);
Assert.AreEqual ("Here I am", infoPlist.GetString ("LibraryWithResources").Value, "LibraryWithResources 2");
Assert.That (infoPlist.GetString ("LibraryWithResources").Value, Is.EqualTo ("Here I am"), "LibraryWithResources 2");
}
}
}
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/PostBuildTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ public void PublishFailureTest (ApplePlatform platform, string runtimeIdentifier

var rv = DotNet.AssertPublishFailure (project_path, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.AreEqual (1, errors.Length, "Error Count");
Assert.That (errors.Length, Is.EqualTo (1), "Error Count");
string expectedErrorMessage;
if (runtimeIdentifiers.IndexOf (';') >= 0) {
expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' are simulator architectures.";
} else {
expectedErrorMessage = $"A runtime identifier for a device architecture must be specified in order to publish this project. '{runtimeIdentifiers}' is a simulator architecture.";
}
Assert.AreEqual (expectedErrorMessage, errors [0].Message, "Error Message");
Assert.That (errors [0].Message, Is.EqualTo (expectedErrorMessage), "Error Message");

Assert.That (pkgPath, Does.Not.Exist, "ipa/pkg creation");
}
Expand Down
Loading
Loading