public void Should_Add_Mandatory_Arguments()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\"", result.Args);
            }
            public void Should_Quote_Test_File_Path()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture {
                    TestFiles = new[] { (FilePath)"./test/cake unit tests/cake core tests.csproj" }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/cake unit tests/cake core tests.csproj\"", result.Args);
            }
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" }
                };

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
            }
            public void Should_Add_Host_Arguments()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" }
                };

                fixture.Settings.DiagnosticOutput = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("--diagnostics vstest \"/Working/test/unit.tests.csproj\"", result.Args);
            }
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" }
                };

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process was not started.");
            }
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = null
                };

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
            public void Should_Add_ResultsDirectory_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        ResultsDirectory = "./artifacts/TestResults"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --ResultsDirectory:\"/Working/artifacts/TestResults\"", result.Args);
            }
            public void Should_Add_Diag_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        DiagnosticFile = "./artifacts/logging/diagnostics.txt"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --Diag:\"/Working/artifacts/logging/diagnostics.txt\"", result.Args);
            }
            public void Should_Add_Port_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        Port = 8000
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --Port:8000", result.Args);
            }
Beispiel #10
0
            public void Should_Add_Logger_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        Logger = @"trx;LogFileName=/Working/logfile.trx"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --logger:\"trx;LogFileName=/Working/logfile.trx\"", result.Args);
            }
Beispiel #11
0
            public void Should_Add_TestCaseFilter_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        TestCaseFilter = "FullyQualifiedName~Cake.Common.Core.DotNetCore"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --TestCaseFilter:\"FullyQualifiedName~Cake.Common.Core.DotNetCore\"", result.Args);
            }
Beispiel #12
0
            public void Should_Add_Framework_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        Framework = "dnxcore50"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --Framework:dnxcore50", result.Args);
            }
Beispiel #13
0
            public void Should_Add_TestAdapter_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        TestAdapterPath = @"/Working/custom-test-adapter"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --TestAdapterPath:\"/Working/custom-test-adapter\"", result.Args);
            }
Beispiel #14
0
            public void Should_Add_Tests_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        TestsToRun = new[] { "TestMethod1", "TestMethod2" }
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --Tests:TestMethod1,TestMethod2", result.Args);
            }
Beispiel #15
0
            public void Should_Add_Settings_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        Settings = "./test/demo.runsettings"
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" --Settings:\"/Working/test/demo.runsettings\"", result.Args);
            }
Beispiel #16
0
            public void Should_Add_Extra_Argument()
            {
                // Given
                var fixture = new DotNetCoreVSTesterFixture
                {
                    TestFiles = new[] { (FilePath)"./test/unit.tests.csproj" },
                    Settings  = new DotNetCoreVSTestSettings
                    {
                        Arguments =
                        {
                            { "Arg1", "Value1" },
                            { "Arg2", "Value2" },
                        }
                    }
                };

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("vstest \"/Working/test/unit.tests.csproj\" Arg1:\"Value1\" Arg2:\"Value2\"", result.Args);
            }