예제 #1
0
        public void NewPackageCmdletThrowsIfNoSolutionIsClosed()
        {
            // Arrange
            var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var cmdlet = new NewPackageCommand(TestUtils.GetSolutionManager(isSolutionOpen: false, defaultProjectName: null), packageManagerFactory.Object, null);

            // Act and Assert
            ExceptionAssert.Throws<InvalidOperationException>(() => cmdlet.GetResults(), "The current environment doesn't have a solution open.");
        }
예제 #2
0
        public void NewPackageCmdletThrowsIfNoSolutionIsClosed()
        {
            // Arrange
            var packageManagerFactory = new Mock <IVsPackageManagerFactory>();

            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var cmdlet = new NewPackageCommand(TestUtils.GetSolutionManager(isSolutionOpen: false, defaultProjectName: null), packageManagerFactory.Object, null);

            // Act and Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => cmdlet.GetResults(), "The current environment doesn't have a solution open.");
        }
예제 #3
0
        public void NewPackageCmdletThrowsIfProjectSpecifiedDoesNotExist()
        {
            // Arrange
            var project = "does-not-exist";
            var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var solutionManager = TestUtils.GetSolutionManager(defaultProjectName: "test", projects: new[] { TestUtils.GetProject("test") });
            var cmdlet = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);
            cmdlet.ProjectName = project;

            // Act and Assert            
            ExceptionAssert.Throws<ItemNotFoundException>(() => cmdlet.GetResults(),
                String.Format("Project '{0}' is not found.", project));
        }
예제 #4
0
        public void NewPackageCmdletThrowsIfMultipleSpecFilesExistAndSpecParameterDoesNotExist()
        {
            // Arrange
            var projectName = "test";
            var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var project = TestUtils.GetProject(projectName, projectFiles: new[] { "foo.nuspec", "bar.nuspec", "foo.dll" });
            var solutionManager = TestUtils.GetSolutionManager(projects: new[] { project });
            var cmdlet = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);
            cmdlet.ProjectName = projectName;

            // Act and Assert
            ExceptionAssert.Throws<InvalidOperationException>(() => cmdlet.GetResults(),
                "More than one .nuspec files were found.");
        }
예제 #5
0
        public void NewPackageCmdletThrowsIfSpecFileDoesNotExistAndSpecParameterDoesNotExist()
        {
            // Arrange
            var projectName = "test";
            var packageManagerFactory = new Mock<IVsPackageManagerFactory>();
            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var project = TestUtils.GetProject(projectName, projectFiles: new[] { "test.cs", "assembly.info", "foo.dll" });
            var solutionManager = TestUtils.GetSolutionManager(projects: new[] { project });
            var cmdlet = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);
            cmdlet.ProjectName = projectName;

            // Act and Assert
            ExceptionAssert.Throws<ItemNotFoundException>(() => cmdlet.GetResults(),
                "Unable to locate a .nuspec file in the specified project.");
        }
예제 #6
0
        public void NewPackageCmdletThrowsIfProjectSpecifiedDoesNotExist()
        {
            // Arrange
            var project = "does-not-exist";
            var packageManagerFactory = new Mock <IVsPackageManagerFactory>();

            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var solutionManager = TestUtils.GetSolutionManager(defaultProjectName: "test", projects: new[] { TestUtils.GetProject("test") });
            var cmdlet          = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);

            cmdlet.ProjectName = project;

            // Act and Assert
            ExceptionAssert.Throws <ItemNotFoundException>(() => cmdlet.GetResults(),
                                                           String.Format("Project '{0}' is not found.", project));
        }
예제 #7
0
        public void NewPackageCmdletThrowsIfMultipleSpecFilesExistAndSpecParameterDoesNotExist()
        {
            // Arrange
            var projectName           = "test";
            var packageManagerFactory = new Mock <IVsPackageManagerFactory>();

            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var project         = TestUtils.GetProject(projectName, projectFiles: new[] { "foo.nuspec", "bar.nuspec", "foo.dll" });
            var solutionManager = TestUtils.GetSolutionManager(projects: new[] { project });
            var cmdlet          = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);

            cmdlet.ProjectName = projectName;

            // Act and Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => cmdlet.GetResults(),
                                                               "More than one .nuspec files were found.");
        }
예제 #8
0
        public void NewPackageCmdletThrowsIfSpecFileDoesNotExistAndSpecParameterDoesNotExist()
        {
            // Arrange
            var projectName           = "test";
            var packageManagerFactory = new Mock <IVsPackageManagerFactory>();

            packageManagerFactory.Setup(m => m.CreatePackageManager()).Returns((IVsPackageManager)null);
            var project         = TestUtils.GetProject(projectName, projectFiles: new[] { "test.cs", "assembly.info", "foo.dll" });
            var solutionManager = TestUtils.GetSolutionManager(projects: new[] { project });
            var cmdlet          = new NewPackageCommand(solutionManager, packageManagerFactory.Object, null);

            cmdlet.ProjectName = projectName;

            // Act and Assert
            ExceptionAssert.Throws <ItemNotFoundException>(() => cmdlet.GetResults(),
                                                           "Unable to locate a .nuspec file in the specified project.");
        }