Exemplo n.º 1
0
        //TODO how to build .net app/lib in osx/unix? need mono? need mono on ci server?
        public void TestAppWithArgs451()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("net451/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppWithArgs", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build {LogArgs}")
            .Should().Pass();

            test("dotnet")
            .Execute($"run {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 2
0
        public void DifferentDotnetInPATH()
        {
            var rootPath = Temp.CreateDirectory().Path;

            var fakeDotnetDir = Path.Combine(rootPath, "dotnetsdk");

            Directory.CreateDirectory(fakeDotnetDir);
            CreateNoopExe(fakeDotnetDir, "dotnet", fail: true);

            var appDir = Path.Combine(rootPath, "TestApp");

            TestAssets.CopyDirTo("TestLibrary", appDir);
            TestAssets.CopyDirTo("TestSuiteProps", appDir);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = appDir
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            var dotnetPath = Microsoft.DotNet.Cli.Utils.Env.GetCommandPath("dotnet");

            var newPATHEnvVar = fakeDotnetDir + Path.PathSeparator + GetEnvironmentVariable("PATH");

            test(dotnetPath)
            .WithEnvironmentVariable("PATH", newPATHEnvVar)
            .Execute($"build {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 3
0
        public void TestAppWithResNet451()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("net451/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppWithRes", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build {LogArgs}")
            .Should().Pass();

            var result = test("dotnet").ExecuteWithCapturedOutput($"run {LogArgs}");

            result.Should().Pass();

            Assert.NotNull(result.StdOut);
            Assert.Equal("Hi!", result.StdOut.Trim());
        }
Exemplo n.º 4
0
        public void TestMultipleLibraryInSameDir()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("TestLibrary", rootPath);
            TestAssets.CopyDirTo("TestMultipleLibraryInSameDir", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore TestLibrary.fsproj {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"restore TestLibrary2.fsproj {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build TestLibrary.fsproj {LogArgs}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build TestLibrary2.fsproj {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 5
0
        public void TestApp()
        {
            var rootPath = Temp.CreateDirectory().Path;

            foreach (var a in new[] { "TestLibrary", "TestApp" })
            {
                var projDir = Path.Combine(rootPath, a);
                TestAssets.CopyDirTo(a, projDir);
                TestAssets.CopyDirTo("TestSuiteProps", projDir);
            }

            var appDir = Path.Combine(rootPath, "TestApp");

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = appDir
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build {LogArgs}")
            .Should().Pass();

            test("dotnet")
            .Execute($"run {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 6
0
        public void TestImplicitFrameworkDefines()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("netcoreapp1.0/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppDefines", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build {LogArgs}")
            .Should().Pass();

            var result = test("dotnet").ExecuteWithCapturedOutput($"run {LogArgs}");

            result.Should().Pass();

            Assert.NotNull(result.StdOut);
            Assert.Contains($"TFM: 'NETCOREAPP1_0'", result.StdOut.Trim());
        }
Exemplo n.º 7
0
        public void TestAppWithArgs451()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("net451/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppWithArgs", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            string rid = GetCurrentRID();

            test("msbuild")
            .Execute($"/t:Restore /p:RuntimeIdentifier={rid} {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("msbuild")
            .Execute($"/t:Build /p:RuntimeIdentifier={rid} {LogArgs}")
            .Should().Pass();

            test(Path.Combine(rootPath, "bin", "Debug", "net451", rid, "ConsoleApp.exe"))
            .Execute($"arg1 arg2")
            .Should().Pass();
        }
Exemplo n.º 8
0
        public void TestAppWithResNet451()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("net451/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppWithRes", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            string rid = GetCurrentRID();

            test("msbuild")
            .Execute($"/t:Restore /p:RuntimeIdentifier={rid} {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("msbuild")
            .Execute($"/t:Build /p:RuntimeIdentifier={rid} {LogArgs}")
            .Should().Pass();


            var result =
                test(Path.Combine(rootPath, "bin", "Debug", "net451", rid, "ConsoleApp.exe"))
                .ExecuteWithCapturedOutput("");

            result.Should().Pass();

            Assert.NotNull(result.StdOut);
            Assert.Equal("Hi!", result.StdOut.Trim());
        }
Exemplo n.º 9
0
        //TODO how to build .net app/lib in osx/unix? need mono? need mono on ci server?
        public void TestAppWithArgs451()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("TestAppWithArgs-netfw", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            string rid = GetCurrentRID();

            test("dotnet")
            .Execute($"restore -r {rid} {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build -r {rid} {LogArgs}")
            .Should().Pass();

            test(Path.Combine(rootPath, "bin", "Debug", "net451", "TestAppWithArgs.exe"))
            .Execute($"arg1 arg2")
            .Should().Pass();
        }
Exemplo n.º 10
0
        public void TestPathWithBlank()
        {
            var rootPath = Path.Combine(Temp.CreateDirectory().Path, "path with blank");

            TestAssets.CopyDirTo("TestLibrary", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("dotnet")
            .Execute($"build {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 11
0
        public void TestLibrary()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("TestLibrary", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("msbuild")
            .Execute($"/t:Restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            test("msbuild")
            .Execute($"/t:Build {LogArgs}")
            .Should().Pass();
        }
Exemplo n.º 12
0
        private void CreateNoopExe(string intoDir, string name, bool fail = false)
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("Noop", rootPath);

            Func <string, TestCommand> test = n => new TestCommand(n)
            {
                WorkingDirectory = rootPath
            };

            string msbuildArgs = $"/p:AssemblyName={name} " + (fail? "/p:Fail=true" : "");

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()} {msbuildArgs}")
            .Should().Pass();

            test("dotnet")
            .Execute($"publish -o \"{intoDir}\" {msbuildArgs}")
            .Should().Pass();
        }
Exemplo n.º 13
0
        public void TestImplicitConfigurationDefines()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("netcoreapp1.0/TestConsoleAppTemplate", rootPath);
            TestAssets.CopyDirTo("TestAppDefines", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            var configurations = new Dictionary <string, string> {
                { "release", "RELEASE" },
                { "debug", "DEBUG" },
            };

            foreach (var kv in configurations)
            {
                test("dotnet")
                .Execute($"build {LogArgs} -c {kv.Key}")
                .Should().Pass();

                var result = test("dotnet").ExecuteWithCapturedOutput($"run -c {kv.Key} {LogArgs}");

                result.Should().Pass();

                Assert.NotNull(result.StdOut);
                Assert.Contains($"CONF: '{kv.Value}'", result.StdOut.Trim());
            }
        }
Exemplo n.º 14
0
        public void TestXmlDoc()
        {
            var rootPath = Temp.CreateDirectory().Path;

            TestAssets.CopyDirTo("TestLibrary", rootPath);
            TestAssets.CopyDirTo("TestSuiteProps", rootPath);

            Func <string, TestCommand> test = name => new TestCommand(name)
            {
                WorkingDirectory = rootPath
            };

            test("dotnet")
            .Execute($"restore {RestoreDefaultArgs} {RestoreSourcesArgs(NugetConfigSources)} {RestoreProps()}")
            .Should().Pass();

            Assert.Equal(false, File.Exists(Path.Combine(rootPath, "doc.xml")));

            test("dotnet")
            .Execute($"build {LogArgs} /p:DocumentationFile=doc.xml")
            .Should().Pass();

            Assert.Equal(true, File.Exists(Path.Combine(rootPath, "doc.xml")));
        }