Beispiel #1
0
        protected SettingsMigratorTest(MockRepository factory = null)
        {
            _factory = factory ?? new MockRepository(MockBehavior.Strict);
            _vimApplicationSettings = _factory.Create<IVimApplicationSettings>(MockBehavior.Loose);
            _vimApplicationSettings.SetupAllProperties();
            _legacySettings = _factory.Create<ILegacySettings>(MockBehavior.Loose);
            _legacySettings.SetupGet(x => x.RemovedBindings).Returns(EmptyBindings);
            var dte = MockObjectFactory.CreateDteWithCommands();

            _settingsMigrator = new SettingsMigrator(
                dte.Object,
                _vimApplicationSettings.Object,
                _legacySettings.Object);
        }
        /// <summary>
        /// Migrate the legacy settings into our new storage if necessary
        /// </summary>
        internal void MigrateLegacySettings(_DTE dte, ILegacySettings legacySettings)
        {
            if (!LegacySettingsMigrated)
            {
                var legacySettingsUsed = legacySettings.HaveUpdatedKeyBindings || legacySettings.IgnoredConflictingKeyBinding || legacySettings.RemovedBindings.Count > 0;
                if (legacySettingsUsed)
                {
                    var settingsMigrator = new SettingsMigrator(dte, this, legacySettings);
                    settingsMigrator.DoMigration();
                }

                LegacySettingsMigrated = true;
            }
        }
        protected SettingsMigratorTest(MockRepository factory = null, SVsServiceProvider serviceProvider = null)
        {
            _factory = factory ?? new MockRepository(MockBehavior.Strict);
            _vimApplicationSettings = _factory.Create<IVimApplicationSettings>(MockBehavior.Loose);
            _legacySettings = _factory.Create<ILegacySettings>(MockBehavior.Loose);
            _legacySettings.SetupGet(x => x.RemovedBindings).Returns(EmptyBindings);
            _protectedOperations = _factory.Create<IProtectedOperations>();
            if (serviceProvider == null)
            {
                var dte = MockObjectFactory.CreateDteWithCommands();
                serviceProvider = MockObjectFactory.CreateVsServiceProvider(Tuple.Create<Type, object>(typeof(SDTE), dte.Object)).Object;
            }

            _settingsMigrator = new SettingsMigrator(
                serviceProvider,
                _vimApplicationSettings.Object,
                _legacySettings.Object,
                _protectedOperations.Object);
        }
        /// <summary>
        /// Migrate the legacy settings into our new storage if necessary
        /// </summary>
        internal void MigrateLegacySettings(_DTE dte, ILegacySettings legacySettings)
        {
            if (!LegacySettingsMigrated)
            {
                var legacySettingsUsed = legacySettings.HaveUpdatedKeyBindings || legacySettings.IgnoredConflictingKeyBinding || legacySettings.RemovedBindings.Count > 0;
                if (legacySettingsUsed)
                {
                    var settingsMigrator = new SettingsMigrator(dte, this, legacySettings);
                    settingsMigrator.DoMigration();
                }

                LegacySettingsMigrated = true;
            }
        }