Пример #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_Throw_If_Uri_Is_Null()
            {
                // Given
                var fixture = new NpmPackageInstallerFixture {
                    Package = null
                };

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("package", ((ArgumentNullException)result).ParamName);
            }
Пример #4
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);
            }
Пример #5
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");
            }
Пример #6
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);
            }