Пример #1
0
        public void UpdateCheckerIgnoresInstallUnitWithUnknownDescriptorFactoryId()
        {
            EngineEnvironmentSettings.SettingsLoader.Components.Register(typeof(MockNupkgUpdater));

            IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor()
            {
                Details                = new Dictionary <string, string>(),
                FactoryId              = new Guid("AB7803DC-5EC2-49D2-B3C4-EBC2F8B6322B"), // no factory is registered with this Id
                Identifier             = "Fake descriptor",
                MountPointId           = new Guid("40BC6026-D593-4AFE-A79C-F86319FB3BD0"),
                UserReadableIdentifier = "Fake descriptor"
            };

            IUpdateUnitDescriptor updateDescriptor = new UpdateUnitDescriptor(installDescriptor, "FakeDescriptor::1.0.0", "Fake Descriptor Version 1.0.0");

            MockNupkgUpdater.SetMockUpdates(new List <IUpdateUnitDescriptor>()
            {
                updateDescriptor
            });

            TemplateUpdateChecker updateChecker = new TemplateUpdateChecker(EngineEnvironmentSettings);
            IReadOnlyList <IUpdateUnitDescriptor> foundUpdates = updateChecker.CheckForUpdatesAsync(new List <IInstallUnitDescriptor>()
            {
                installDescriptor
            }).Result;

            Assert.Equal(0, foundUpdates.Count);
        }
        public async Task NoUpdatersRegisteredSuccessfullyDoesNothing()
        {
            // start with nothing "installed", so checking what was installed can happen.
            MockInstaller installer = new MockInstaller();

            IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor()
            {
                Details      = new Dictionary <string, string>(),
                FactoryId    = NupkgInstallUnitDescriptorFactory.FactoryId,
                Identifier   = "MockPackage",
                MountPointId = new Guid("C5A4D83F-7005-4B38-BF47-DFF5CB5F5881"),
            };

            CliTemplateUpdater updater = new CliTemplateUpdater(EngineEnvironmentSettings, installer, "new");

            Assert.Empty(installer.Installed);

            List <IInstallUnitDescriptor> installsToUpdate = new List <IInstallUnitDescriptor>()
            {
                installDescriptor
            };
            bool updateResult = await updater.CheckForUpdatesAsync(installsToUpdate, true);

            Assert.True(updateResult);
            Assert.Empty(installer.Installed);
        }
Пример #3
0
        public void NoUpdatesFoundDoesNothing()
        {
            EngineEnvironmentSettings.SettingsLoader.Components.Register(typeof(MockNupkgUpdater));

            // start with nothing "installed", so checking what was installed can happen.
            MockInstaller installer = new MockInstaller();

            IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor()
            {
                Details                = new Dictionary <string, string>(),
                FactoryId              = NupkgInstallUnitDescriptorFactory.FactoryId,
                Identifier             = "MockPackage",
                MountPointId           = new Guid("C5A4D83F-7005-4B38-BF47-DFF5CB5F5881"),
                UserReadableIdentifier = "Mock Package"
            };

            TemplateUpdateCoordinator coordinator = new TemplateUpdateCoordinator(EngineEnvironmentSettings, installer);

            Assert.Empty(installer.Installed);

            List <IInstallUnitDescriptor> installsToUpdate = new List <IInstallUnitDescriptor>();

            coordinator.UpdateTemplates(installsToUpdate, () => Console.ReadLine(), true);
            Assert.Empty(installer.Installed);
        }
        public async Task UpdateIsFoundAndApplied()
        {
            EngineEnvironmentSettings.SettingsLoader.Components.Register(typeof(MockNupkgUpdater));

            IInstallUnitDescriptor installDescriptor = new MockInstallUnitDescriptor()
            {
                Details      = new Dictionary <string, string>(),
                FactoryId    = NupkgInstallUnitDescriptorFactory.FactoryId,
                Identifier   = "MockPackage",
                MountPointId = new Guid("C5A4D83F-7005-4B38-BF47-DFF5CB5F5881"),
            };
            List <IInstallUnitDescriptor> installsToUpdate = new List <IInstallUnitDescriptor>()
            {
                installDescriptor
            };

            IUpdateUnitDescriptor updateDescriptor = new UpdateUnitDescriptor(installDescriptor, "MockPackageToInstall", "Mock Package To Install");

            MockNupkgUpdater.SetMockUpdates(new List <IUpdateUnitDescriptor>()
            {
                updateDescriptor
            });

            // start with nothing "installed", so checking what was installed can happen.
            MockInstaller installer = new MockInstaller();

            CliTemplateUpdater updater = new CliTemplateUpdater(EngineEnvironmentSettings, installer, "new");

            Assert.Empty(installer.Installed);

            bool updateResult = await updater.CheckForUpdatesAsync(installsToUpdate, true);

            Assert.True(updateResult);
            Assert.Single(installer.Installed);
        }