void CreateCmdlet()
 {
     cmdlet = new TestableGetProjectCmdlet();
     fakeTerminatingError = cmdlet.FakeCmdletTerminatingError;
     fakeCommandRuntime   = cmdlet.FakeCommandRuntime;
     fakeConsoleHost      = cmdlet.FakePackageManagementConsoleHost;
     fakeSolution         = cmdlet.FakeSolution;
     defaultProject       = base.AddDefaultProjectToConsoleHost();
 }
示例#2
0
 void CreateInstaller()
 {
     project             = ProjectHelper.CreateTestProject();
     packageReferences   = new List <PackageReference>();
     fakeActionRunner    = new FakePackageActionRunner();
     fakeProjectFactory  = new FakePackageManagementProjectFactory();
     fakeRepositoryCache = new FakePackageRepositoryFactory();
     installer           = new PackageReferenceInstaller(fakeRepositoryCache, fakeActionRunner, fakeProjectFactory);
 }
示例#3
0
        void CreateReferences()
        {
            project            = new TestableDTEProject();
            msbuildProject     = project.TestableProject;
            fakeProjectService = project.FakeProjectService;
            ProjectObject projectObject = (ProjectObject)project.Object;

            references = (References)projectObject.References;
        }
示例#4
0
        Solution CreateSolutionWithOneProject()
        {
            TestableProject project  = ProjectHelper.CreateTestProject();
            Solution        solution = project.ParentSolution;

            solution.AddFolder(project);

            return(solution);
        }
        void CreateReference(string name)
        {
            project        = new TestableDTEProject();
            msbuildProject = project.TestableProject;
            var referenceProjectItem = msbuildProject.AddReference(name);

            fakeProjectService = project.FakeProjectService;
            reference          = new Reference(project, referenceProjectItem);
        }
        ProjectNode AddProjectToProjectBrowser(string projectFileName)
        {
            project          = ProjectHelper.CreateTestProject();
            project.FileName = projectFileName;

            projectBrowser.ViewSolution(project.ParentSolution);
            var solutionNode = projectBrowser.RootNode as SolutionNode;

            return(solutionNode.FirstNode as ProjectNode);
        }
        public void BuildProject_OneProjectInSubFolderInsideSolutionFolderAndUniqueNameMatchesProject_ProjectPassedToProjectBuilder()
        {
            CreateSolutionBuild(@"d:\projects\MyProject\MySolution.sln");
            string          projectFileName = @"d:\projects\MyProject\SubFolder\MyProject.csproj";
            TestableProject expectedProject = solutionHelper.AddProjectToSolutionWithFileName("MyProject", projectFileName);

            solutionBuild.BuildProject("Debug", @"SubFolder\MyProject.csproj", true);

            Assert.AreEqual(expectedProject, projectBuilder.ProjectPassedToBuild);
        }
示例#8
0
 void CreateProjectWithOneFileInProjectFolder(
     string include,
     string projectFileName = @"c:\projects\MyProject\MyProject.csproj")
 {
     project                 = new TestableDTEProject();
     msbuildProject          = project.TestableProject;
     fakeFileService         = project.FakeFileService;
     msbuildProject.FileName = new FileName(projectFileName);
     msbuildProject.AddFile(include);
 }
        void CreateSelectedFolderNode(string folder)
        {
            projectForSelectedFolder = TestableProject.CreateProject();
            projectNode = new ProjectNode(projectForSelectedFolder);

            directoryNode = new DirectoryNode(folder);
            directoryNode.AddTo(projectNode);

            selectedFolderNode = new SelectedFolderNodeInProjectsView(directoryNode);
        }
示例#10
0
        void RunCommandWithExceptionThrowingPackageReferences(Exception exception)
        {
            var exceptionThrowingPackageReferences = new ExceptionThrowingPackageReferencesForProject();

            exceptionThrowingPackageReferences.ExceptionToThrowOnInstall = exception;
            command.FakePackageReferencesForProject = exceptionThrowingPackageReferences;
            TestableProject project = CreateFakeProject("Test");

            RunCommandWithProjectCreateInfoAsOwner(project);
        }
示例#11
0
        public void SourceProject_ReferenceIsProjectReference_ReturnsReferencedProject()
        {
            TestableProject referencedProject = CreateProjectReference();

            referencedProject.FileName = @"d:\projects\referencedproject.csproj";

            global::EnvDTE.Project project = reference.SourceProject;

            Assert.AreEqual(@"d:\projects\referencedproject.csproj", project.FileName);
        }
示例#12
0
        void CreateReference(string name)
        {
            project              = new TestableDTEProject();
            msbuildProject       = project.TestableProject;
            referenceProjectItem = msbuildProject.AddReference(name);
            fakeProjectService   = project.FakeProjectService;
            CreateReference(project, referenceProjectItem);
            IWorkbench workbench = MockRepository.GenerateStub <IWorkbench>();

            ICSharpCode.SharpDevelop.SD.Services.AddService(typeof(IWorkbench), workbench);
        }
        public void BuildProject_ProjectIsSecondProjectInSolution_CorrectProjectPassedToProjectBuilder()
        {
            CreateSolutionBuild(@"d:\projects\MyProject\MySolution.sln");
            solutionHelper.AddProjectToSolution("FirstProject");
            string          projectFileName = @"d:\projects\MyProject\MyProject.csproj";
            TestableProject expectedProject = solutionHelper.AddProjectToSolutionWithFileName("MyProject", projectFileName);

            solutionBuild.BuildProject("Debug", "MyProject.csproj", true);

            Assert.AreEqual(expectedProject, projectBuilder.ProjectPassedToBuild);
        }
示例#14
0
        List <IProject> AddSolutionWithTwoProjectsToProjectService()
        {
            ISolution       solution = ProjectHelper.CreateSolution();
            TestableProject project1 = ProjectHelper.CreateTestProject(solution, "Test1");
            TestableProject project2 = ProjectHelper.CreateTestProject("Test2");

            fakeSolution.FakeMSBuildProjects.Add(project1);
            fakeSolution.FakeMSBuildProjects.Add(project2);

            return(fakeSolution.FakeMSBuildProjects);
        }
示例#15
0
        void CreateProject()
        {
            msbuildProject = ProjectHelper.CreateTestProject();
            helper         = new ProjectContentHelper();

            fakeProjectService = MockRepository.GenerateStub <IPackageManagementProjectService>();
            fakeProjectService.Stub(service => service.GetProjectContent(msbuildProject)).Return(helper.ProjectContent);

            fakeFileService = MockRepository.GenerateStub <IPackageManagementFileService>();
            project         = new Project(msbuildProject, fakeProjectService, fakeFileService);
        }
示例#16
0
        public void Run_OneProjectCreatedByNewProjectDialog_ProjectUsedToCreatePackageReferences()
        {
            CreateCommand();
            TestableProject expectedProject = CreateFakeProject("Test");

            RunCommandWithProjectCreateInfoAsOwner(expectedProject);

            MSBuildBasedProject project = command.ProjectPassedToCreatePackageReferencesForProject;

            Assert.AreEqual(expectedProject, project);
        }
示例#17
0
        public void Run_OneProjectCreatedByNewProjectDialog_ProjectReferencesAreRemoved()
        {
            CreateCommand();
            TestableProject project = CreateFakeProject("Test");

            RunCommandWithProjectCreateInfoAsOwner(project);

            bool removed = command.FakePackageReferencesForProject.IsRemovePackageReferencesCalled;

            Assert.IsTrue(removed);
        }
示例#18
0
        public void GetProjects_SolutionHasOneProject_MSBuildProjectUsedToCreateProject()
        {
            CreateSolution();
            TestableProject expectedProject           = AddProjectToOpenProjects("MyProject");
            var             repository                = new FakePackageRepository();
            List <IPackageManagementProject> projects = solution.GetProjects(repository).ToList();

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
        void CreateProjectWithOneFile(string fileName)
        {
            project         = new TestableDTEProject();
            msbuildProject  = project.TestableProject;
            fakeFileService = project.FakeFileService;

            fileProjectItem = new FileProjectItem(msbuildProject, ItemType.Compile)
            {
                FileName = fileName
            };
        }
示例#20
0
        TestableProject CreateProjectReference()
        {
            project        = new TestableDTEProject();
            msbuildProject = project.TestableProject;
            TestableProject             referencedProject    = ProjectHelper.CreateTestProject();
            ProjectReferenceProjectItem referenceProjectItem = msbuildProject.AddProjectReference(referencedProject);

            fakeProjectService = project.FakeProjectService;
            CreateReference(project, referenceProjectItem);
            return(referencedProject);
        }
示例#21
0
        public void HasMultipleProjects_OneProjectInSolution_ReturnsFalse()
        {
            CreateSolution();
            TestableProject project = ProjectHelper.CreateTestProject();

            fakeProjectService.AddFakeProject(project);

            bool hasMultipleProjects = solution.HasMultipleProjects();

            Assert.IsFalse(hasMultipleProjects);
        }
示例#22
0
        public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingRepository()
        {
            CreateSolution();
            TestableProject expectedProject    = AddProjectToOpenProjects("Test");
            var             expectedRepository = new FakePackageRepository();

            solution.GetProject(expectedRepository, expectedProject);

            IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;

            Assert.AreEqual(expectedRepository, repository);
        }
示例#23
0
        public void ActiveSolutionProjects_SolutionHasOneProject_ReturnsArrayContainingProject()
        {
            CreateDTE();
            TestableProject expectedProject = AddProjectToSolution("ProjectA");

            Array projects = dte.ActiveSolutionProjects as Array;

            Project project = projects.GetValue(0) as Project;
            string  name    = project.Name;

            Assert.AreEqual("ProjectA", name);
        }
示例#24
0
        public void Run_OneProjectCreatedByNewProjectDialog_PackageRepositoryCacheUsedToCreatePackageReferences()
        {
            CreateCommand();
            TestableProject project = CreateFakeProject("Test");

            RunCommandWithProjectCreateInfoAsOwner(project);

            IPackageRepositoryCache cache         = command.PackageRepositoryCachePassedToCreatePackageReferencesForProject;
            IPackageRepositoryCache expectedCache = command.FakePackageRepositoryCache;

            Assert.AreEqual(expectedCache, cache);
        }
        public void GetMSBuildProjects_TwoProjectsInOpenSolutionButOneIsNotMSBuildBased_ReturnsOneMSBuildBasedProject()
        {
            CreateSolution();
            TestableProject project = AddProjectToOpenProjects("A");

            AddNonMSBuildBasedProjectToOpenProjects();

            IEnumerable <IProject> projects = solution.GetMSBuildProjects();
            var expectedProjects            = new IProject[] { project };

            CollectionAssert.AreEqual(expectedProjects, projects);
        }
示例#26
0
        public void GetProject_RepositoryAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var             repository      = new FakePackageRepository();

            solution.GetProject(repository, "TEST");

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
示例#27
0
        public void GetProject_PackagesRepositoryAndProjectPassed_ReturnsProjectCreatedFromProjectFactory()
        {
            CreateSolution();
            TestableProject msbuildProject = AddProjectToOpenProjects("Test");
            var             repository     = new FakePackageRepository();

            IPackageManagementProject project = solution.GetProject(repository, msbuildProject);

            FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;

            Assert.AreEqual(expectedProject, project);
        }
示例#28
0
        public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingProjectPassed()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var             repository      = new FakePackageRepository();

            solution.GetProject(repository, expectedProject);

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
示例#29
0
        public void GetProject_PackagesSourceAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName()
        {
            CreateSolution();
            TestableProject expectedProject = AddProjectToOpenProjects("Test");
            var             source          = new PackageSource("http://sharpdevelop.net");

            solution.GetProject(source, "TEST");

            MSBuildBasedProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;

            Assert.AreEqual(expectedProject, project);
        }
        void CreateProjectItemProperties()
        {
            project                = new TestableDTEProject();
            msbuildProject         = project.TestableProject;
            msbuildFileProjectItem = new SD.FileProjectItem(msbuildProject, SD.ItemType.Compile);
            projectItem            = new ProjectItem(project, msbuildFileProjectItem);
            properties             = (ICSharpCode.PackageManagement.EnvDTE.Properties)projectItem.Properties;

            IWorkbench workbench = MockRepository.GenerateStub <IWorkbench>();

            ICSharpCode.SharpDevelop.SD.Services.AddService(typeof(IWorkbench), workbench);
        }