public void LibrariesEmbeddedProperly(BindingProjectType type, bool useProjectReference) { MMPTests.RunMMPTest(tmpDir => { var projects = BindingProjectTests.GenerateTestProject(type, tmpDir); BindingProjectTests.SetNoEmbedding(projects.Item1); string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: true).Item2; AssertNoResourceWithName(tmpDir, projects.Item1.ProjectName, "SimpleClassDylib.dylib"); AssertFileInBundle(tmpDir, type, "MonoBundle/SimpleClassDylib.dylib"); }); }
public void FrameworksEmbeddedProperly(BindingProjectType type, bool useProjectReference) { MMPTests.RunMMPTest(tmpDir => { string frameworkPath = FrameworkBuilder.CreateThinFramework(tmpDir); var projects = BindingProjectTests.GenerateTestProject(type, tmpDir); BindingProjectTests.SetNoEmbedding(projects.Item1); projects.Item1.ItemGroup = NativeReferenceTests.CreateSingleNativeRef(frameworkPath, "Framework"); string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, false).Item2; AssertNoResourceWithName(tmpDir, projects.Item1.ProjectName, "Foo"); AssertFileInBundle(tmpDir, type, "Frameworks/Foo.framework/Foo", assertIsSymLink: true); }); }
public void MultipleNativeReferences(bool useProjectReference) { MMPTests.RunMMPTest(tmpDir => { // This is a bit of a hack, you can't just rename dylibs like this string secondNativeLibPath = Path.Combine(tmpDir, "SimpleClassDylib2.dylib"); File.Copy(NativeReferenceTests.SimpleDylibPath, secondNativeLibPath); var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir); BindingProjectTests.SetNoEmbedding(projects.Item1); projects.Item1.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(secondNativeLibPath, "Dynamic"); BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: true); // manifest and 2 dylibs Assert.AreEqual(3, Directory.GetFiles(Path.Combine(tmpDir, "bin/Debug/MobileBinding.resources")).Length); // 2 dylibs + libMonoPosixHelper.dylib Assert.AreEqual(3, Directory.GetFiles(Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MonoBundle")).Where(x => x.EndsWith(".dylib")).Count()); }); }
public void ShouldNotUnnecessarilyRebuildFinalProject(bool useProjectReference, bool framework) { MMPTests.RunMMPTest(tmpDir => { var projects = BindingProjectTests.GenerateTestProject(BindingProjectType.Modern, tmpDir); BindingProjectTests.SetNoEmbedding(projects.Item1); const string BuildString = "xcrun -sdk macosx clang"; string frameworkPath = null; if (framework) { frameworkPath = FrameworkBuilder.CreateThinFramework(tmpDir); projects.Item1.ItemGroup += NativeReferenceTests.CreateSingleNativeRef(Path.GetFullPath(frameworkPath), "Framework"); } string appBuildLog = BindingProjectTests.SetupAndBuildLinkedTestProjects(projects.Item1, projects.Item2, tmpDir, useProjectReference, setupDefaultNativeReference: !framework).Item2; Assert.True(appBuildLog.Contains(BuildString), $"First build did not run mmp? {TI.PrintRedirectIfLong (appBuildLog)}"); string projectPath = Path.Combine(tmpDir, "UnifiedExample.csproj"); string mainPath = Path.Combine(tmpDir, "Main.cs"); // No change build should not string buildLog = TI.BuildProject(projectPath, true); Assert.False(buildLog.Contains(BuildString), $"Rebuild ran mmp again? {TI.PrintRedirectIfLong (buildLog)}"); if (useProjectReference) { // Touching the binding definition should Touch(Path.Combine(tmpDir, "ApiDefinition.cs")); buildLog = TI.BuildProject(projectPath, true); Assert.True(buildLog.Contains(BuildString), $"Binding definition build did not run mmp again? {TI.PrintRedirectIfLong (buildLog)}"); } else { // Touching the binding assembly should Touch(Path.Combine(tmpDir, "bin/Debug/MobileBinding.dll")); buildLog = TI.BuildProject(projectPath, true); Assert.True(buildLog.Contains(BuildString), $"Binding build did not run mmp again? {TI.PrintRedirectIfLong (buildLog)}"); } }); }