Example #1
0
 public void BuildUnifiedXM45_Program_SmokeTest()
 {
     RunMSBuildTest(tmpDir => {
         string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
         {
             ProjectName = "XM45Example.csproj"
         });
         TI.BuildProject(projectPath, isUnified: true);
     });
 }
Example #2
0
 public void BuildFSharpUnifiedXM45_Program_SmokeTest()
 {
     RunMSBuildTest(tmpDir => {
         string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
         {
             FSharp = true, ProjectName = "FSharpXM45Example.fsproj"
         });
         TI.BuildProject(projectPath);
     });
 }
Example #3
0
 public void BuildUnifiedMobile_Program_SmokeTest()
 {
     RunMSBuildTest(tmpDir => {
         string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
         {
             ProjectName = "UnifiedExample.csproj"
         });
         TI.BuildProject(projectPath);
     });
 }
Example #4
0
        void TestBCLCore(string tmpDir, string projectName)
        {
            var    dll         = Path.GetFullPath(Path.Combine(TI.TestDirectory + "common", "mac", "System.Collections.Immutable.dll"));
            string reference   = $"<Reference Include=\"System.Collections.Immutable\"><HintPath>{dll}</HintPath></Reference>";
            string testCode    = "var v = System.Collections.Immutable.ImmutableArray.CreateRange (new int [] { 42 });";
            string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
            {
                ProjectName = projectName, References = reference, TestCode = testCode
            });

            TI.BuildProject(projectPath);
        }
Example #5
0
        void TestBCLCore(string tmpDir, string projectName)
        {
            File.Copy(Path.Combine(TI.AssemblyDirectory, TI.TestDirectory + "common/mac/System.Collections.Immutable.dll"), Path.Combine(tmpDir, "System.Collections.Immutable.dll"));
            string reference   = "<Reference Include=\"System.Collections.Immutable\"><HintPath>System.Collections.Immutable.dll</HintPath></Reference>";
            string testCode    = "var v = System.Collections.Immutable.ImmutableArray.CreateRange (new int [] { 42 });";
            string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
            {
                ProjectName = projectName, References = reference, TestCode = testCode
            });

            TI.BuildProject(projectPath);
        }
Example #6
0
        public void BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes(string project)
        {
            RunMSBuildTest(tmpDir => {
                var config = new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = project
                };
                string projectPath = TI.GenerateEXEProject(config);
                string buildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsTrue(buildOutput.Contains(@"Building target ""_CompileToNative"""));

                string secondBuildOutput = TI.BuildProject(projectPath).BuildOutput;
                Assert.IsFalse(secondBuildOutput.Contains(@"Building target ""_CompileToNative"""));
            });
        }
Example #7
0
        public void BuildUnifiedProject_WithJustNativeRefNoLinkWith_Builds()
        {
            RunMSBuildTest(tmpDir => {
                var dylib          = Path.GetFullPath(Path.Combine(TI.TestDirectory, "test-libraries", ".libs", "macos", "libtest.dylib"));
                string itemGroup   = $"<ItemGroup><NativeReference Include=\"{dylib}\"> <IsCxx>False</IsCxx><Kind>Dynamic</Kind> </NativeReference> </ItemGroup>";
                string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedExample.csproj", ItemGroup = itemGroup
                });
                var testResults = TI.BuildProject(projectPath);
                testResults.Messages.AssertNoMessage(2006);
                Assert.That(Path.Combine(tmpDir, $"bin", "Debug", "UnifiedExample.app", "Contents", "MonoBundle", Path.GetFileName(dylib)), Does.Exist, "dylib in app");

                Assert.AreEqual(0, ExecutionHelper.Execute("/usr/bin/otool", new [] { "-L", Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MacOS/UnifiedExample") }, out var output));
                Assert.IsTrue(output.ToString().Contains(Path.GetFileName(dylib)));
            });
        }
Example #8
0
        public void BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes()
        {
            RunMSBuildTest(tmpDir =>
            {
                foreach (var project in new string[] { "UnifiedExample.csproj", "XM45Example.csproj" })
                {
                    var config = new TI.UnifiedTestConfig(tmpDir)
                    {
                        ProjectName = project
                    };
                    string projectPath = TI.GenerateEXEProject(config);
                    string buildOutput = TI.BuildProject(projectPath);
                    Assert.IsTrue(buildOutput.Contains(@"Building target ""_CompileToNative"""));

                    string secondBuildOutput = TI.BuildProject(projectPath);
                    Assert.IsFalse(secondBuildOutput.Contains(@"Building target ""_CompileToNative"""));
                }
            });
        }
Example #9
0
        public void BuildUnifiedProject_WithJustNativeRefNoLinkWith_Builds()
        {
            RunMSBuildTest(tmpDir => {
                string dylibPath = Path.Combine(tmpDir, "dll/");
                Directory.CreateDirectory(dylibPath);
                File.Copy(Path.Combine(TI.AssemblyDirectory, TI.TestDirectory + "mac-binding-project/bin/SimpleClassDylib.dylib"), Path.Combine(dylibPath, "SimpleClassDylib.dylib"));
                string itemGroup   = "<ItemGroup><NativeReference Include=\".\\dll\\SimpleClassDylib.dylib\"> <IsCxx>False</IsCxx><Kind>Dynamic</Kind> </NativeReference> </ItemGroup>";
                string projectPath = TI.GenerateEXEProject(new TI.UnifiedTestConfig(tmpDir)
                {
                    ProjectName = "UnifiedExample.csproj", ItemGroup = itemGroup
                });
                string buildResults = TI.BuildProject(projectPath);
                Assert.IsFalse(buildResults.Contains("MM2006"), "BuildUnifiedProject_WittJustNativeRefNoLinkWith_Builds found 2006 warning: " + buildResults);
                Assert.IsTrue(File.Exists(Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MonoBundle/SimpleClassDylib.dylib")));

                StringBuilder output = new StringBuilder();
                Xamarin.Bundler.Driver.RunCommand("/usr/bin/otool", new [] { "-L", Path.Combine(tmpDir, "bin/Debug/UnifiedExample.app/Contents/MacOS/UnifiedExample") }, output);
                Assert.IsTrue(output.ToString().Contains("SimpleClassDylib.dylib"));
            });
        }