Beispiel #1
0
            public void Should_Throw_If_No_Tool_Was_Intercepted()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Action = context => { };

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

                // Then
                AssertEx.IsCakeException(result, "No tool was started.");
            }
Beispiel #2
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
Beispiel #3
0
            public void Should_Throw_If_Output_File_Is_Null()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.OutputPath = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "outputPath");
            }
Beispiel #4
0
            public void Should_Throw_If_Action_Is_Null()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Action = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "action");
            }
Beispiel #5
0
            public void Should_Capture_Tool_And_Arguments_From_Action()
            {
                // Given
                var fixture = new OpenCoverFixture();

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #6
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Context = null;

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

                // Then
                Assert.IsArgumentNullException(result, "context");
            }
Beispiel #7
0
            public void Should_Use_Specified_Register()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.Register = "Path32";

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:Path32 -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #8
0
            public void Should_Append_LogLevel()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.LogLevel = OpenCoverLogLevel.All;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-log:All", result.Args);
            }
Beispiel #9
0
            public void Should_Append_SkipAutoProps()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.SkipAutoProps = true;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-skipautoprops " +
                             "-register:user -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #10
0
            public void Should_Append_MergeByHash()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.MergeByHash = true;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-mergebyhash", result.Args);
            }
Beispiel #11
0
            public void Should_Append_TargetDir()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.TargetDirectory = "TarDir";

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-targetdir:\"/Working/TarDir\"", result.Args);
            }
Beispiel #12
0
            public void Should_Append_NoDefaultFilters()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.NoDefaultFilters = true;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-nodefaultfilters", result.Args);
            }
Beispiel #13
0
            public void Should_Add_ReturnTargetCode_If_ReturnTargetCodeOffset_Is_Set()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.ReturnTargetCodeOffset = 100;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user " +
                             "-returntargetcode:100 " +
                             "-output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #14
0
            public void Should_Not_break_when_old_string_registrations_are_used()
            {
                // Given
                var fixture = new OpenCoverFixture();

#pragma warning disable CS0618 // Type or member is obsolete
                fixture.Settings.Register = "Path64";
#pragma warning restore CS0618 // Type or member is obsolete

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:Path64 -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #15
0
            public void Should_Append_File_Filters()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.ExcludedFileFilters.Add("filter1");
                fixture.Settings.ExcludedFileFilters.Add("filter2");

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-excludebyfile:\"filter1;filter2\" " +
                             "-register:user -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #16
0
            public void Should_Append_Search_Directories()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.SearchDirectories.Add("dir1");
                fixture.Settings.SearchDirectories.Add("dir2");

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-searchdirs:\"/Working/dir1;/Working/dir2\"", result.Args);
            }
Beispiel #17
0
            public void Should_Append_HideSkipped()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Settings.HideSkippedOption = OpenCoverHideSkippedOption.File
                                                     | OpenCoverHideSkippedOption.MissingPdb
                                                     | OpenCoverHideSkippedOption.Filter
                                                     | OpenCoverHideSkippedOption.All
                                                     | OpenCoverHideSkippedOption.Attribute;

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-targetargs:\"-argument\" " +
                             "-register:user -output:\"/Working/result.xml\" " +
                             "-hideskipped:All", result.Args);
            }
Beispiel #18
0
            public void Should_Not_Capture_Arguments_From_Action_If_Excluded(string arguments)
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.Action = context =>
                {
                    context.ProcessRunner.Start(
                        new FilePath("/Working/tools/Test.exe"),
                        new ProcessSettings()
                    {
                        Arguments = arguments
                    });
                };

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

                // Then
                Assert.Equal("-target:\"/Working/tools/Test.exe\" " +
                             "-register:user -output:\"/Working/result.xml\"", result.Args);
            }
Beispiel #19
0
            public void Should_Capture_NUnit()
            {
                // Given
                var fixture = new OpenCoverFixture();

                fixture.FileSystem.CreateFile("/Working/tools/nunit-console.exe");
                fixture.Action = context =>
                {
                    context.NUnit(
                        new FilePath[] { "./Test.dll" },
                        new NUnitSettings {
                        ShadowCopy = false
                    });
                };

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

                // Then
                Assert.Equal("-target:\"/Working/tools/nunit-console.exe\" " +
                             "-targetargs:\"\\\"/Working/Test.dll\\\" -noshadow\" " +
                             "-register:user -output:\"/Working/result.xml\"", result.Args);
            }