示例#1
0
 public ProviderServices(
     ILicenseWindowOpener licenseWindowOpener,
     IProgressWindowOpener progressWindow,
     IScriptExecutor scriptExecutor,
     IOutputConsoleProvider outputConsoleProvider)
 {
     LicenseWindow = licenseWindowOpener;
     ProgressWindow = progressWindow;
     ScriptExecutor = scriptExecutor;
     OutputConsoleProvider = outputConsoleProvider;
 }
示例#2
0
 public ProviderServices(
     ILicenseWindowOpener licenseWindowOpener,
     IProgressWindowOpener progressWindow,
     IScriptExecutor scriptExecutor,
     IOutputConsoleProvider outputConsoleProvider)
 {
     LicenseWindow         = licenseWindowOpener;
     ProgressWindow        = progressWindow;
     ScriptExecutor        = scriptExecutor;
     OutputConsoleProvider = outputConsoleProvider;
 }
示例#3
0
 public OnlineProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider) :
     base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
     _packageManagerFactory    = packageManagerFactory;
     _licenseWindowOpener      = providerServices.LicenseWindow;
 }
示例#4
0
 public OnlineProvider(
     Project project,
     IProjectManager projectManager,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider)
     : base(project, projectManager, resources, providerServices, progressProvider)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _packageManagerFactory = packageManagerFactory;
     _licenseWindowOpener = providerServices.LicenseWindow;
 }
示例#5
0
        private static UpdatesProvider CreateUpdatesProvider(
            IVsPackageManager packageManager             = null,
            IProjectManager projectManager               = null,
            IPackageRepositoryFactory repositoryFactory  = null,
            IPackageSourceProvider packageSourceProvider = null,
            Project project = null,
            IScriptExecutor scriptExecutor           = null,
            ILicenseWindowOpener licenseWindowOpener = null)
        {
            if (packageManager == null)
            {
                var packageManagerMock = new Mock <IVsPackageManager>();
                var sourceRepository   = new MockPackageRepository();
                packageManagerMock.Setup(p => p.SourceRepository).Returns(sourceRepository);

                packageManager = packageManagerMock.Object;
            }

            if (projectManager == null)
            {
                projectManager = new Mock <IProjectManager>().Object;
            }

            if (repositoryFactory == null)
            {
                var repositoryFactoryMock = new Mock <IPackageRepositoryFactory>();
                repositoryFactoryMock.Setup(p => p.CreateRepository(It.IsAny <PackageSource>())).Returns(new MockPackageRepository());
                repositoryFactory = repositoryFactoryMock.Object;
            }

            if (packageSourceProvider == null)
            {
                var packageSourceProviderMock = new Mock <IPackageSourceProvider>();
                packageSourceProviderMock.Setup(p => p.GetPackageSources()).Returns(
                    new PackageSource[2] {
                    new PackageSource("Test1", "One"),
                    new PackageSource("Test2", "Two")
                }
                    );
                packageSourceProvider = packageSourceProviderMock.Object;
            }

            var factory = new Mock <IVsPackageManagerFactory>();

            factory.Setup(m => m.CreatePackageManager(It.IsAny <IPackageRepository>())).Returns(packageManager);

            var mockProgressWindowOpener = new Mock <IProgressWindowOpener>();

            if (licenseWindowOpener == null)
            {
                var mockLicenseWindowOpener = new Mock <ILicenseWindowOpener>();
                licenseWindowOpener = mockLicenseWindowOpener.Object;
            }

            if (project == null)
            {
                project = new Mock <Project>().Object;
            }

            if (scriptExecutor == null)
            {
                scriptExecutor = new Mock <IScriptExecutor>().Object;
            }

            var services = new ProviderServices(
                licenseWindowOpener,
                mockProgressWindowOpener.Object,
                scriptExecutor,
                new MockOutputConsoleProvider()
                );

            return(new UpdatesProvider(
                       project,
                       projectManager,
                       new System.Windows.ResourceDictionary(),
                       repositoryFactory,
                       packageSourceProvider,
                       factory.Object,
                       services,
                       new Mock <IProgressProvider>().Object));
        }
示例#6
0
        private static UpdatesProvider CreateUpdatesProvider(
            IVsPackageManager packageManager = null,
            IProjectManager projectManager = null,
            IPackageRepositoryFactory repositoryFactory = null,
            IPackageSourceProvider packageSourceProvider = null,
            Project project = null,
            IScriptExecutor scriptExecutor = null,
            ILicenseWindowOpener licenseWindowOpener = null)
        {
            if (packageManager == null) {
                var packageManagerMock = new Mock<IVsPackageManager>();
                var sourceRepository = new MockPackageRepository();
                packageManagerMock.Setup(p => p.SourceRepository).Returns(sourceRepository);

                packageManager = packageManagerMock.Object;
            }

            if (projectManager == null) {
                projectManager = new Mock<IProjectManager>().Object;
            }

            if (repositoryFactory == null) {
                var repositoryFactoryMock = new Mock<IPackageRepositoryFactory>();
                repositoryFactoryMock.Setup(p => p.CreateRepository(It.IsAny<PackageSource>())).Returns(new MockPackageRepository());
                repositoryFactory = repositoryFactoryMock.Object;
            }

            if (packageSourceProvider == null) {
                var packageSourceProviderMock = new Mock<IPackageSourceProvider>();
                packageSourceProviderMock.Setup(p => p.GetPackageSources()).Returns(
                        new PackageSource[2] {
                            new PackageSource("Test1", "One"),
                            new PackageSource("Test2", "Two")
                        }
                    );
                packageSourceProvider = packageSourceProviderMock.Object;
            }

            var factory = new Mock<IVsPackageManagerFactory>();
            factory.Setup(m => m.CreatePackageManager(It.IsAny<IPackageRepository>())).Returns(packageManager);

            var mockProgressWindowOpener = new Mock<IProgressWindowOpener>();

            if (licenseWindowOpener == null) {
                var mockLicenseWindowOpener = new Mock<ILicenseWindowOpener>();
                licenseWindowOpener = mockLicenseWindowOpener.Object;
            }

            if (project == null) {
                project = new Mock<Project>().Object;
            }

            if (scriptExecutor == null) {
                scriptExecutor = new Mock<IScriptExecutor>().Object;
            }

            var services = new ProviderServices(
                licenseWindowOpener,
                mockProgressWindowOpener.Object,
                scriptExecutor,
                new MockOutputConsoleProvider()
            );

            return new UpdatesProvider(
                project,
                projectManager,
                new System.Windows.ResourceDictionary(),
                repositoryFactory,
                packageSourceProvider,
                factory.Object,
                services,
                new Mock<IProgressProvider>().Object);
        }