public void ProjectTryResolveTest()
        {
            var man = new FakeProjectManager();

            var project1 = new MyFakeTypeProject(typeof(string));
            var project2 = new MyFakeNameProject(typeof(string), "string");

            man.Register(project1);
            man.Register(project2);

            var result3 = man.TryResolve(typeof(string), out var project3);
            var result4 = man.TryResolve(typeof(string), "string", out var project4);

            result3.ShouldBeTrue();
            result4.ShouldBeTrue();

            project3.ShouldNotBeNull();
            project4.ShouldNotBeNull();

            project3.Class.ShouldBe(ProjectClass.Typed);
            project4.Class.ShouldBe(ProjectClass.Named);

            project3.Type.ShouldBe(typeof(string));
            project4.Type.ShouldBe(typeof(string));

            project3.Name.ShouldBe("System.String");
            project4.Name.ShouldBe("string");
        }
 void RaisePackageRemovedEventWhenPackageReferenceAdded(
     FakeProjectManager projectManager,
     FakePackage newPackage,
     params PackageOperationEventArgs[] eventArgs)
 {
     projectManager.WhenAddPackageReferenceCalled(
         newPackage.Id,
         newPackage.Version,
         () => eventArgs.ToList().ForEach(eventArg => projectManager.FirePackageReferenceRemoved(eventArg)));
 }
        public void ProjectRegisterTest()
        {
            var man = new FakeProjectManager();

            var project1 = new MyFakeTypeProject(typeof(string));
            var project2 = new MyFakeNameProject(typeof(string), "string");

            man.Register(project1);
            man.Register(project2);

            man._typedProjects.Keys.Count.ShouldBe(1);
            man._namedTypeProjects.Keys.Count.ShouldBe(1);
        }
Пример #4
0
        void CreateProject(IPackageRepository sourceRepository)
        {
            fakePackageManagerFactory = new FakePackageManagerFactory();
            fakePackageManager        = fakePackageManagerFactory.FakePackageManager;
            fakeProjectManager        = fakePackageManager.FakeProjectManager;
            fakeProject             = new FakeDotNetProject();
            packageManagementEvents = new PackageManagementEvents();

            project = new PackageManagementProject(
                sourceRepository,
                fakeProject,
                packageManagementEvents,
                fakePackageManagerFactory);
        }
Пример #5
0
        void CreateProject(MSBuildBasedProject msbuildProject)
        {
            fakePackageManagerFactory   = new FakePackageManagerFactory();
            fakePackageManager          = fakePackageManagerFactory.FakePackageManager;
            fakeProjectManager          = fakePackageManager.FakeProjectManager;
            fakeSourceRepository        = new FakePackageRepository();
            fakePackageManagementEvents = new FakePackageManagementEvents();

            project = new PackageManagementProject(
                fakeSourceRepository,
                msbuildProject,
                fakePackageManagementEvents,
                fakePackageManagerFactory);
        }
        public void InstallPackage_OnePackageOperation_ProjectManagerProjectSystemLoggerIsOutputMessagesViewLogger()
        {
            CreatePackageManagementService();
            var projectSystem = new FakeProjectSystem();
            FakeProjectManager projectManager = fakePackageManagerFactory.FakePackageManager.FakeProjectManager;

            projectManager.Project = projectSystem;
            installPackageHelper.AddPackageInstallOperation();
            installPackageHelper.InstallTestPackage();

            ILogger expectedLogger = fakeOutputMessagesView;
            ILogger actualLogger   = projectSystem.Logger;

            Assert.AreEqual(expectedLogger, actualLogger);
        }
        void CreateProject()
        {
            fakePackageManagerFactory   = new FakePackageManagerFactory();
            fakePackageManager          = fakePackageManagerFactory.FakePackageManager;
            fakeProjectManager          = fakePackageManager.FakeProjectManager;
            fakeSourceRepository        = new FakePackageRepository();
            fakeMSBuildProject          = ProjectHelper.CreateTestProject();
            fakePackageManagementEvents = new FakePackageManagementEvents();

            project = new PackageManagementProject(
                fakeSourceRepository,
                fakeMSBuildProject,
                fakePackageManagementEvents,
                fakePackageManagerFactory);
        }
        public void ProjectResolveWithUnregisterTypeTest()
        {
            var man = new FakeProjectManager();

            var project1 = new MyFakeTypeProject(typeof(string));
            var project2 = new MyFakeNameProject(typeof(string), "string");

            man.Register(project1);
            man.Register(project2);

            var project3 = man.Resolve(typeof(int));
            var project4 = man.Resolve(typeof(int), "int");

            project3.ShouldBeNull();
            project4.ShouldBeNull();
        }
        public void InstalledPackagesViewModel_ProjectHasOneInstalledPackage_HasOnePackageViewModel()
        {
            CreatePackageManagementService();
            var projectManager = new FakeProjectManager();

            fakePackageManagementService.FakeActiveProjectManager = projectManager;
            FakePackage package = new FakePackage();

            projectManager.FakeLocalRepository.FakePackages.Add(package);
            CreateViewModel(fakePackageManagementService);

            IEnumerable <IPackage>         expectedPackages        = projectManager.FakeLocalRepository.FakePackages;
            IEnumerable <PackageViewModel> actualPackageViewModels = viewModel.InstalledPackagesViewModel.PackageViewModels;

            PackageCollectionAssert.AreEqual(expectedPackages, actualPackageViewModels);
        }
        public void InstallPackage_OldPackageReferenceIsRemovedOnInstalling_OldPackageIsUninstalled()
        {
            CreatePackageManager();
            var fakeProjectManager = new FakeProjectManager();

            packageManager.ProjectManager = fakeProjectManager;
            FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion("MyPackage", "1.0");
            FakePackage newPackage       = fakeFeedSourceRepository.AddFakePackageWithVersion("MyPackage", "1.1");
            var         eventArgs        = new PackageOperationEventArgs(installedPackage, null, null);

            RaisePackageRemovedEventWhenPackageReferenceAdded(fakeProjectManager, newPackage, eventArgs);
            var installAction = new FakeInstallPackageAction {
                Operations = new List <PackageOperation> ()
            };

            packageManager.InstallPackage(newPackage, installAction);

            Assert.IsFalse(fakeSolutionSharedRepository.FakePackages.Contains(installedPackage));
        }
        public void UpdatePackage_OldPackageReferenceIsRemovedOnUpdating_OldPackageIsUninstalled()
        {
            CreatePackageManager();
            var fakeProjectManager = new FakeProjectManager();

            packageManager.ProjectManager = fakeProjectManager;
            FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion("MyPackage", "1.0");
            FakePackage updatedPackage   = fakeFeedSourceRepository.AddFakePackageWithVersion("MyPackage", "1.1");
            var         eventArgs        = new PackageOperationEventArgs(installedPackage, null, null);

            RaisePackageRemovedEventWhenPackageReferenceUpdated(fakeProjectManager, updatedPackage, eventArgs);
            var updateAction = new FakeUpdatePackageAction {
                Operations         = new List <PackageOperation> (),
                UpdateDependencies = false
            };

            packageManager.UpdatePackage(updatedPackage, updateAction);

            Assert.IsFalse(fakeSolutionSharedRepository.FakePackages.Contains(installedPackage));
        }