public void BuildBundledResources(string platform, string prefix) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "BundledResources"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.csproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's one resource in the binding assembly, and its name var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count, Is.EqualTo(2), "2 resources"); // Sort the resources before we assert, since we don't care about the order, and sorted order makes the asserts simpler. var resources = ad.MainModule.Resources.OrderBy(v => v.Name).ToArray(); Assert.That(resources [0].Name, Is.EqualTo($"__{prefix}_content_basn3p08.png"), $"__{prefix}_content_basn3p08.png"); Assert.That(resources [1].Name, Is.EqualTo($"__{prefix}_content_xamvideotest.mp4"), $"__{prefix}_content_xamvideotest.mp4"); }
public void BuildFSharpLibraryTest(string platform) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "fsharplibrary"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.fsproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's no resources in the assembly var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count(), Is.EqualTo(2), "2 resources"); // There are 2 embedded resources by default by the F# compiler. }
public void BuildBindingsTest2(string platform) { Configuration.IgnoreIfIgnoredPlatform(platform); var assemblyName = "bindings-test2"; var dotnet_bindings_dir = Path.Combine(Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine(dotnet_bindings_dir, platform); var project_path = Path.Combine(project_dir, $"{assemblyName}.csproj"); Clean(project_path); Configuration.CopyDotNetSupportingFiles(dotnet_bindings_dir); var result = DotNet.AssertBuild(project_path, verbosity); var lines = BinLog.PrintToLines(result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = FilterToAssembly(lines, assemblyName); Assert.That(assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic Assert.That(assemblies.Distinct().Count(), Is.EqualTo(1), "Unique assemblies"); var asm = assemblies.First(); Assert.That(asm, Does.Exist, "Assembly existence"); // Verify that there's one resource in the binding assembly, and its name var ad = AssemblyDefinition.ReadAssembly(asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That(ad.MainModule.Resources.Count, Is.EqualTo(1), "1 resource"); Assert.That(ad.MainModule.Resources [0].Name, Is.EqualTo("libtest2.a"), "libtest2.a"); }
// [TestCase ("watchOS")] // No watchOS Touch.Client project for .NET yet // [TestCase ("macOS")] // No macOS Touch.Client project for .NET yet public void BuildInterdependentBindingProjects (string platform) { Configuration.IgnoreIfIgnoredPlatform (platform); var assemblyName = "interdependent-binding-projects"; var dotnet_bindings_dir = Path.Combine (Configuration.SourceRoot, "tests", assemblyName, "dotnet"); var project_dir = Path.Combine (dotnet_bindings_dir, platform); var project_path = Path.Combine (project_dir, $"{assemblyName}.csproj"); Clean (project_path); Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir); Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir.Replace (assemblyName, "bindings-test")); Configuration.CopyDotNetSupportingFiles (dotnet_bindings_dir.Replace (assemblyName, "bindings-test2")); var cleanupSupportFiles = Configuration.CopyDotNetSupportingFiles (Path.Combine (Configuration.SourceRoot, "external", "Touch.Unit", "Touch.Client/dotnet")); try { var result = DotNet.AssertBuild (project_path, verbosity); var lines = BinLog.PrintToLines (result.BinLogPath); // Find the resulting binding assembly from the build log var assemblies = lines. Select (v => v.Trim ()). Where (v => { if (v.Length < 10) return false; if (v [0] != '/') return false; if (!v.EndsWith ($"{assemblyName}.dll", StringComparison.Ordinal)) return false; if (!v.Contains ("/bin/", StringComparison.Ordinal)) return false; if (!v.Contains ($"{assemblyName}.app", StringComparison.Ordinal)) return false; return true; }); Assert.That (assemblies, Is.Not.Empty, "Assemblies"); // Make sure there's no other assembly confusing our logic assemblies = assemblies.Distinct (); Assert.That (assemblies.Count (), Is.EqualTo (1), $"Unique assemblies: {string.Join (", ", assemblies)}"); var asm = assemblies.First (); Assert.That (asm, Does.Exist, "Assembly existence"); // Verify that the resources have been linked away var asmDir = Path.GetDirectoryName (asm); var ad = AssemblyDefinition.ReadAssembly (asm, new ReaderParameters { ReadingMode = ReadingMode.Deferred }); Assert.That (ad.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for interdependent-binding-projects.dll"); var ad1 = AssemblyDefinition.ReadAssembly (Path.Combine (asmDir, "bindings-test.dll"), new ReaderParameters { ReadingMode = ReadingMode.Deferred }); // The native library is removed from the resources by the linker Assert.That (ad1.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for bindings-test.dll"); var ad2 = AssemblyDefinition.ReadAssembly (Path.Combine (asmDir, "bindings-test2.dll"), new ReaderParameters { ReadingMode = ReadingMode.Deferred }); // The native library is removed from the resources by the linker Assert.That (ad2.MainModule.Resources.Count, Is.EqualTo (0), "0 resources for bindings-test2.dll"); } finally { foreach (var file in cleanupSupportFiles) File.Delete (file); } }