コード例 #1
0
            public void Should_Redirect_Standard_Error()
            {
                var fixture = new NpmInstallerFixture();

                fixture.Settings.RedirectStandardError = true;

                var result = fixture.Run();

                Assert.True(result.Process.RedirectStandardError);
            }
コード例 #2
0
            public void Should_Add_Mandatory_Arguments()
            {
                // Given
                var fixture = new NpmInstallerFixture();

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

                // Then
                Assert.Equal("install", result.Args);
            }
コード例 #3
0
            public void Should_Throw_If_Scope_Does_Not_Start_With_At()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                // When
                var result = Record.Exception(() => fixture.Settings.AddScopedPackage("foo", "bar"));

                // Then
                Assert.IsType <ArgumentException>(result);
            }
コード例 #4
0
            public void Should_Add_Scoped_Package_To_Arguments()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.AddScopedPackage("foo", "@bar");

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

                // Then
                Assert.Equal("install @bar/foo", result.Args);
            }
コード例 #5
0
            public void Should_Add_Package_With_Tag_Containing_Space_To_Arguments()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.AddPackage("foo", "bar bla");

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

                // Then
                Assert.Equal("install foo@\"bar bla\"", result.Args);
            }
コード例 #6
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings = null;

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

                // Then
                result.IsArgumentNullException("settings");
            }
コード例 #7
0
            public void Should_Not_Add_Registry_To_Arguments_If_Not_Set()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.Registry = null;

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

                // Then
                Assert.Equal("install", result.Args);
            }
コード例 #8
0
            public void Should_Add_NoOptional_To_Arguments_If_Specified()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.NoOptional = true;

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

                // Then
                Assert.Equal("install --no-optional", result.Args);
            }
コード例 #9
0
            public void Should_Add_Production_To_Arguments_If_Not_Null()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.Production = true;

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

                // Then
                Assert.Equal("install --production", result.Args);
            }
コード例 #10
0
            public void Should_Add_Package_With_Version_To_Arguments()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.AddPackage("foo", "1.2.3");

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

                // Then
                Assert.Equal("install [email protected]", result.Args);
            }
コード例 #11
0
            public void Should_Add_Package_Url_To_Arguments()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.AddPackage(new Uri("https://www.example.com/mypackage.tgz"));

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

                // Then
                Assert.Equal("install https://www.example.com/mypackage.tgz", result.Args);
            }
コード例 #12
0
            public void Should_Throw_If_Not_Absolute_Uri()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                // When
                var result = Record.Exception(
                    () =>
                    fixture.Settings.AddPackage(
                        new Uri("https://www.example.com/foo/mypackage.tgz").MakeRelativeUri(new Uri("https://www.example.com"))));

                // Then
                Assert.IsType <UriFormatException>(result);
            }
コード例 #13
0
            public void Should_Add_Registry_To_Arguments_If_Set()
            {
                // Given
                var fixture  = new NpmInstallerFixture();
                var registry = new Uri("http://exampleregistry.com");

                fixture.Settings.Registry = registry;

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

                // Then
                Assert.Equal($"install --registry { registry }", result.Args);
            }
コード例 #14
0
            public void Should_Throw_If_Production_Is_Used_Together_With_Packages()
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.Production = true;
                fixture.Settings.Packages.Add("foo");

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

                // Then
                Assert.IsType <NotSupportedException>(result);
            }
コード例 #15
0
            public void Should_Use_Cake_LogLevel_If_LogLevel_Is_Set_To_Default(
                Verbosity verbosity,
                string expected)
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.CakeVerbosityLevel = verbosity;

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #16
0
            public void Should_Add_LogLevel_To_Arguments_If_Not_Null(
                NpmLogLevel logLevel,
                string expected)
            {
                // Given
                var fixture = new NpmInstallerFixture();

                fixture.Settings.LogLevel = logLevel;

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

                // Then
                Assert.Equal(expected, result.Args);
            }
コード例 #17
0
            public void Should_Pass_In_Arbitrary_Npm_Arguments(string[] npmArgs, string expected)
            {
                // Given
                var fixture = new NpmInstallerFixture();

                foreach (var npmArg in npmArgs)
                {
                    fixture.Settings.WithNpmArguments(npmArg);
                }

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

                // Then
                Assert.Equal(expected, result.Args);
            }