Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpovazan committed Jul 11, 2024
1 parent f2f732d commit 7786482
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/dotnet/ExtensionConsumer/iOS/ExtensionConsumer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySimpleApp", "MySimpleApp.csproj", "{23664512-6B06-4135-9A94-C012BDA93CB1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionConsumer", "ExtensionConsumer.csproj", "{23664512-6B06-4135-9A94-C012BDA93CB1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionProject", "..\..\ExtensionProject\iOS\ExtensionProject.csproj", "{8A72DB8F-4C30-4462-9F7A-6095E41D5D46}"
EndProject
Expand Down
55 changes: 39 additions & 16 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,46 +1063,69 @@ public void KillEverything ()
}


[TestCase (ApplePlatform.iOS)]
[TestCase (ApplePlatform.TVOS)]
[TestCase (ApplePlatform.MacOSX)]
[TestCase (ApplePlatform.iOS, "ios-arm64", false)]
[TestCase (ApplePlatform.iOS, "ios-arm64", true)]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", false)]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", true)]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", false)]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
// [TestCase ("MacCatalyst", "")] - No extension support yet
public void BuildProjectsWithExtensions (ApplePlatform platform)
public void BuildProjectsWithExtensions (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
var consumingProjectDir = GetProjectPath ("ExtensionConsumer", platform: platform);
var consumingProjectDir = GetProjectPath ("ExtensionConsumer", runtimeIdentifier, platform, out var appPath);
var extensionProjectDir = GetProjectPath ("ExtensionProject", platform: platform);

Clean (extensionProjectDir);
Clean (consumingProjectDir);

DotNet.AssertBuild (consumingProjectDir, verbosity);
var properties = GetDefaultProperties (runtimeIdentifier);

if (isNativeAot)
{
properties ["PublishAot"] = "true";
properties ["_IsPublishing"] = "true";
}

DotNet.AssertBuild (consumingProjectDir, properties);

var extensionPath = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug", platform.ToFramework (), GetDefaultRuntimeIdentifier (platform), "MySimpleApp.app", GetPlugInsRelativePath (platform), "ExtensionProject.appex");
var extensionPath = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug", platform.ToFramework (), runtimeIdentifier, "ExtensionConsumer.app", GetPlugInsRelativePath (platform), "ExtensionProject.appex");
Assert.That (Directory.Exists (extensionPath), $"App extension directory does not exist: {extensionPath}");

var pathToSearch = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug");
string [] configFiles = Directory.GetFiles (pathToSearch, "*.runtimeconfig.*", SearchOption.AllDirectories);
Assert.AreNotEqual (0, configFiles.Length, "runtimeconfig.json file does not exist");
}

[TestCase (ApplePlatform.iOS)]
[TestCase (ApplePlatform.TVOS)]
[TestCase (ApplePlatform.MacOSX)]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", false)]
[TestCase (ApplePlatform.iOS, "iossimulator-x64", true)]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", false)]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
// [TestCase ("MacCatalyst", "")] - No extension support yet
public void BuildProjectsWithExtensionsAndFrameworks (ApplePlatform platform)
public void BuildProjectsWithExtensionsAndFrameworks (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
var runtimeIdentifiers = GetDefaultRuntimeIdentifier (platform);
var consumingProjectDir = GetProjectPath ("ExtensionConsumerWithFrameworks", runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
var consumingProjectDir = GetProjectPath ("ExtensionConsumerWithFrameworks", runtimeIdentifiers: runtimeIdentifier, platform: platform, out var appPath);
var extensionProjectDir = GetProjectPath ("ExtensionProjectWithFrameworks", platform: platform);

Clean (extensionProjectDir);
Clean (consumingProjectDir);

DotNet.AssertBuild (consumingProjectDir, verbosity);
var properties = GetDefaultProperties (runtimeIdentifier);

if (isNativeAot)
{
properties ["PublishAot"] = "true";
properties ["_IsPublishing"] = "true";
}

DotNet.AssertBuild (consumingProjectDir, properties);

var extensionPath = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug", platform.ToFramework (), GetDefaultRuntimeIdentifier (platform), "ExtensionConsumerWithFrameworks.app", GetPlugInsRelativePath (platform), "ExtensionProjectWithFrameworks.appex");
var extensionPath = Path.Combine (Path.GetDirectoryName (consumingProjectDir)!, "bin", "Debug", platform.ToFramework (), runtimeIdentifier, "ExtensionConsumerWithFrameworks.app", GetPlugInsRelativePath (platform), "ExtensionProjectWithFrameworks.appex");
Assert.That (Directory.Exists (extensionPath), $"App extension directory does not exist: {extensionPath}");
var extensionFrameworksPath = Path.Combine (extensionPath, GetFrameworksRelativePath (platform));
Assert.IsFalse (Directory.Exists (extensionFrameworksPath), $"App extension framework directory exists when it shouldn't: {extensionFrameworksPath}");
Expand All @@ -1119,7 +1142,7 @@ public void BuildProjectsWithExtensionsAndFrameworks (ApplePlatform platform)
Assert.That (File.Exists (Path.Combine (appFrameworksPath, "UnknownE.framework", "UnknownE")), "UnknownE");

var appExecutable = GetNativeExecutable (platform, appPath);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifier, appExecutable);
}


Expand Down

0 comments on commit 7786482

Please sign in to comment.