Ejemplo n.º 1
0
        public void GetProjects_SolutionHasTwoProjectsAndOneProjectSelectedInProjectsBrowser_ReturnsProjectSelectedInProjects()
        {
            CreateFakeSolution();
            List <IProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService();
            IProject        project = projectsAddedToSolution[1];

            project.Name = "MyProject";
            fakeSolution.FakeActiveMSBuildProject = project;

            var fakeProject = fakeSolution.AddFakeProjectToReturnFromGetProject("MyProject");

            CreateSelectedProjects();

            var fakePackage = new FakePackage();
            var projects    = new List <IPackageManagementSelectedProject>();

            projects.AddRange(selectedProjects.GetProjects(fakePackage));

            var expectedProject  = new FakeSelectedProject("MyProject", selected: false, enabled: true);
            var expectedProjects = new List <IPackageManagementSelectedProject>();

            expectedProjects.Add(expectedProject);

            SelectedProjectCollectionAssert.AreEqual(expectedProjects, projects);
        }
Ejemplo n.º 2
0
        public void GetProjects_SolutionHasTwoProjectsAndOneProjectSelectedInProjectsBrowserAndPackageIsInstalledInProject_ReturnsProjectAndIsSelectedIsTrue()
        {
            CreateFakeSolution();
            List <IProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService();

            projectsAddedToSolution[0].Name = "Aaa";
            IProject msbuildProject = projectsAddedToSolution[1];

            msbuildProject.Name = "MyProject";
            fakeSolution.FakeActiveMSBuildProject = msbuildProject;

            var fakePackage = new FakePackage();
            var fakeProject = fakeSolution.AddFakeProjectToReturnFromGetProject("MyProject");

            fakeProject.FakePackages.Add(fakePackage);
            fakeSolution.AddFakeProjectToReturnFromGetProject("Aaa");

            CreateSelectedProjects();

            List <IPackageManagementSelectedProject> projects =
                selectedProjects.GetProjects(fakePackage).ToList();

            var expectedProject  = new FakeSelectedProject("MyProject", selected: true);
            var expectedProjects = new List <IPackageManagementSelectedProject>();

            expectedProjects.Add(expectedProject);

            SelectedProjectCollectionAssert.AreEqual(expectedProjects, projects);
            Assert.AreEqual(fakePackage.FakePackageRepository, fakeSolution.RepositoryPassedToGetProject);
            Assert.AreEqual(msbuildProject, fakeSolution.ProjectPassedToGetProject);
        }
        void AddTwoProjectsSelected(string projectName1, string projectName2)
        {
            AddProjectToSolution();
            AddProjectToSolution();
            fakeSolution.FakeDotNetProjects [0].Name = projectName1;
            fakeSolution.FakeDotNetProjects [1].Name = projectName2;
            fakeSolution.NoProjectsSelected();

            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName1);
            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName2);
        }
        void CreateViewModelWithTwoProjectsSelected(string projectName1, string projectName2)
        {
            CreateViewModel();
            AddProjectToSolution();
            AddProjectToSolution();
            fakeSolution.FakeMSBuildProjects[0].Name = projectName1;
            fakeSolution.FakeMSBuildProjects[1].Name = projectName2;
            fakeSolution.NoProjectsSelected();

            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName1);
            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName2);
        }
        List <IProject> AddSolutionWithTwoProjectsToProjectService(string projectName1, string projectName2)
        {
            ISolution       solution = ProjectHelper.CreateSolution();
            TestableProject project1 = ProjectHelper.CreateTestProject(solution, projectName1);
            TestableProject project2 = ProjectHelper.CreateTestProject(solution, projectName2);

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

            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName1);
            fakeSolution.AddFakeProjectToReturnFromGetProject(projectName2);

            return(fakeSolution.FakeMSBuildProjects);
        }
        void ProjectHasOnePackageReferenceNeedingReinstall(string packageId)
        {
            var package = FakePackage.CreatePackageWithVersion(packageId, "1.2.3.4");

            package.AddFile(@"lib\net45\MyPackage.dll");
            package.AddFile(@"lib\net40\MyPackage.dll");

            FakePackageManagementProject packageManagementProject =
                solution.AddFakeProjectToReturnFromGetProject(project.Name);

            packageManagementProject.FakePackages.Add(package);

            string xml = String.Format(
                @"<packages>
					<package id='{0}' version='1.2.3.4' targetFramework='net40'/>
				</packages>"                ,
                packageId);

            SetProjectPackagesConfigFileContents(xml);
        }