Пример #1
0
            public void Should_Not_Throw_If_Install_Path_Is_Null()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture {
                    InstallPath = null
                };

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

                // Then
                Assert.Null(result);
            }
Пример #2
0
            public void Should_Use_Custom_Source_If_RelativeUri_Is_Used()
            {
                var fixture = new NpmPackageInstallerFixture {
                    Package = new PackageReference("npm:?package=yo")
                };

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

                // Then
                Assert.Null(result);
                fixture.Config.Received().GetValue(NPM_CONFIGKEY);
            }
Пример #3
0
            public void Should_Not_Be_Able_To_Install_If_Scheme_Is_Incorrect()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture {
                    Package = new PackageReference("dnf:?package=glxgears")
                };

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

                // Then
                Assert.False(result);
            }
Пример #4
0
            public void Should_Throw_If_URI_Is_Null()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture {
                    Package = null
                };

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("package", ((ArgumentNullException)result).ParamName);
            }
Пример #5
0
            public void Should_Throw_If_Content_Resolver_Is_Null()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture {
                    ContentResolver = null
                };

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("contentResolver", ((ArgumentNullException)result).ParamName);
            }
Пример #6
0
            public void Should_Ignore_Custom_Source_If_AbsoluteUri_Is_Used()
            {
                var fixture = new NpmPackageInstallerFixture
                {
                    Package = new PackageReference("npm:http://absolute/?package=windirstat")
                };

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

                // Then
                Assert.Null(result);
                fixture.Config.DidNotReceive().GetValue(NPM_CONFIGKEY);
            }
Пример #7
0
            public void Should_Not_Check_For_Npm_If_NpmCmd_Can_Be_Found()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture
                {
                    ToolLocatorSetup = l => l.Resolve("npm.cmd").Returns(new FilePath("npm.cmd"))
                };

                // When
                fixture.Install();

                // Then
                fixture.ToolLocator.Received().Resolve("npm.cmd");
                fixture.ToolLocator.Received(0).Resolve("npm");
            }
Пример #8
0
            public void Should_Throw_If_Npm_Can_Not_Be_Found()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture
                {
                    ToolLocatorSetup = l => l.Resolve(string.Empty).ReturnsForAnyArgs((FilePath)null)
                };

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

                // Then
                Assert.IsType <FileNotFoundException>(result);
                Assert.Equal("npm could not be found.", ((FileNotFoundException)result).Message);
            }