示例#1
0
        public void ShouldFindExecutableIfToolPathNotProvided()
        {
            // Given
            var fixture = new NewmanFixture();
            // When
            var result = fixture.Run();

            // Then
            result.Path.FullPath.Should().Be("/Working/tools/newman");
        }
示例#2
0
        public void ShouldThrowIfProcessWasNotStarted()
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.GivenProcessCannotStart();
            var action = new Action(() => fixture.Run());

            action.ShouldThrow <CakeException>().WithMessage("Newman: Process was not started.");
        }
        public void ShouldSpecifyBailWhenInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.ExitOnFirstFailure());

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

            // Then
            result.Args().Should().Be("--bail");
        }
        public void ShouldSetTimeoutWhenInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.SetRequestTimeout(25));

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

            // Then
            result.Args().Should().Be("--timeout-request 25");
        }
        public void ShouldSetDelayWhenInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.SetRequestDelay(50));

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

            // Then
            result.Args().Should().Be("--delay-request 50");
        }
        public void ShouldSpecifyInsecureWhenAliasInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.DisableStrictSSL());

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

            // Then
            result.Args().Should().Be("--insecure");
        }
        public void ShouldSpecifyIgnoreRedirectsWhenInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.IgnoreRedirects());

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

            // Then
            result.Args().Should().Be("--ignore-redirects");
        }
            public void ShouldSetEnvironmentFilePathWhenInvoked()
            {
                // Given
                var fixture = new NewmanFixture(s => s.WithEnvironment("./environments.json"));

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

                // Then
                result.Args().Should().Be("--environment \"environments.json\"");
            }
            public void ShouldSetGlobalsPathWhenInvoked()
            {
                // Given
                var fixture = new NewmanFixture(s => s.WithGlobals("./globals.json"));

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

                // Then
                result.Args().Should().Be("--globals \"globals.json\"");
            }
            public void ShouldSetCollectionExportWhenInvoked()
            {
                // Given
                var fixture = new NewmanFixture(s => s.ExportCollectionTo("./export.json"));

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

                // Then
                result.Args().Should().Be("--export-collection \"export.json\"");
            }
            public void ShouldSetEnvironmentsExportWhenInvoked()
            {
                // Given
                var fixture = new NewmanFixture(s => s.ExportEnvironmentTo("./environment.json"));

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

                // Then
                result.Args().Should().Be("--export-environment \"environment.json\"");
            }
            public void ShouldSetGlobalsExportWhenInvoked()
            {
                // Given
                var fixture = new NewmanFixture(s => s.ExportGlobalsTo("./globals.json"));

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

                // Then
                result.Args().Should().Be("--export-globals \"globals.json\"");
            }
        public void ShouldSetFolderWhenInvoked()
        {
            // Given
            var fixture = new NewmanFixture(s => s.RunOnlyFolder("Services"));

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

            // Then
            result.Args().Should().Be("--folder \"Services\"");
        }
示例#14
0
        public void ShouldThrowIfExecutableWasNotFound()
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.GivenDefaultToolDoNotExist();
            // When
            var action = new Action(() => fixture.Run());

            // Then
            action.ShouldThrow <CakeException>().WithMessage("Newman: Could not locate executable.");
        }
示例#15
0
            public void ShouldIncludeIgnoreRedirectsWhenSet()
            {
                var fixture = new NewmanFixture();

                fixture.Settings.IgnoreRedirects = true;

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

                // Then
                result.Args().Should().Be("--ignore-redirects");
            }
示例#16
0
            public void ShouldIncludeBailWhenSet()
            {
                var fixture = new NewmanFixture();

                fixture.Settings.ExitOnFirstFailure = true;

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

                // Then
                result.Args().Should().Be("--bail");
            }
示例#17
0
        public void ShouldSetRequestDelayWhenSet(int delay)
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.Settings.RequestDelay = delay;

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

            // Then
            result.Args().Should().Be($"--delay-request {delay}");
        }
示例#18
0
            public void ShouldSpecifyEnvironmentsFile()
            {
                // Given
                var fixture = new NewmanFixture();

                fixture.Settings.EnvironmentFile = "./collection.json";

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

                // Then
                result.Args().Should().Be("--environment \"collection.json\"", "file paths are quoted and trimmed");
            }
示例#19
0
            public void ShouldSpecifyGlobalsFile()
            {
                // Given
                var fixture = new NewmanFixture();

                fixture.Settings.GlobalVariablesFile = "./vars/globals.json";

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

                // Then
                result.Args().Should().Be("--globals \"vars/globals.json\"", "file paths are quoted and trimmed");
            }
示例#20
0
            public void ShouldSpecifyGlobalsPath()
            {
                // Given
                var fixture = new NewmanFixture();

                fixture.Settings.ExportGlobalsPath = "./export/globals.json";

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

                // Then
                result.Args().Should().Be("--export-globals \"export/globals.json\"", "file paths are quoted and trimmed");
            }
示例#21
0
            public void ShouldSpecifyEnvironmentExportPath()
            {
                // Given
                var fixture = new NewmanFixture();

                fixture.Settings.ExportEnvironmentPath = "./export/environment.json";

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

                // Then
                result.Args().Should().Be("--export-environment \"export/environment.json\"", "file paths are quoted and trimmed");
            }
示例#22
0
            public void ShouldIncludeInsecureWhenSet()
            {
                // Given
                var fixture = new NewmanFixture();

                fixture.Settings.DisableStrictSSL = true;

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

                // Then
                result.Args().Should().Be("--insecure");
            }
示例#23
0
        public void ShouldThrowOnNullCollectionFile()
        {
            // Given
            var fixture = new NewmanFixture {
                InputFile = null
            };

            // When
            Action action = () => fixture.Run();

            // Then
            action.Should().Throw <ArgumentNullException>().WhereMessageContains("collectionFile", "null collection file provided");
        }
示例#24
0
        public void ShouldSpecifyRequestTimeoutWhenSet(int timeout)
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.Settings.RequestTimeout = timeout;

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

            // Then
            result.Args().Should().Be($"--timeout-request {timeout}");
        }
示例#25
0
        public void ShouldSpecifyFolderWhenSet()
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.Settings.Folder = "Api Service";

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

            // Then
            result.Args().Should().Be("--folder \"Api Service\"", "Cake should have quoted this argument");
        }
示例#26
0
        public void ShouldSpecifyIterationCountWhenSet(int iterationCount)
        {
            // Given
            var fixture = new NewmanFixture {
                Settings = { IterationCount = iterationCount }
            };

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

            // Then
            result.Args().Should().Be($"--iteration-count {iterationCount}");
        }
示例#27
0
            public void ShouldSpecifyDataFile()
            {
                // Given
                var fixture = new NewmanFixture {
                    Settings = { DataFile = "./vars/data.json" }
                };

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

                // Then
                result.Args().Should().Be("-d \"vars/data.json\"", "file paths are quoted and trimmed");
            }
示例#28
0
        public void ShouldSpecifyScriptTimeoutWhenSet(int timeout)
        {
            // Given
            var fixture = new NewmanFixture {
                Settings = { ScriptTimeout = timeout }
            };

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

            // Then
            result.Args().Should().Be($"--timeout-script {timeout}");
        }
示例#29
0
        public void ShouldThrowIfFileDoesNotExist()
        {
            // Given
            var fixture = new NewmanFixture();

            fixture.InputFile = "./nonexistent.json";

            // When
            Action action = () => fixture.Run();

            // Then
            action.ShouldThrow <FileNotFoundException>().WithMessage("nonexistent.json", "input file doesn't exist");
        }
示例#30
0
        public void ShouldThrowOnNullSettings()
        {
            // Given
            var fixture = new NewmanFixture {
                Settings = null
            };

            // When
            Action action = () => fixture.Run();

            // Then
            action.Should().Throw <ArgumentNullException>().WhereMessageContains("settings", "null settings object provided");
        }