public Merge ( string enabledLanguages, |
||
enabledLanguages | string | |
cache | ||
Результат | void |
private void mergeBuiltInCommands(bool updateDefinitions, ProfileLocator profiles) { var builtInFile = Path.Combine(profiles.AppRootPath, "oi-definitions.json"); var builtInCache = new DefinitionCache(); if (File.Exists(builtInFile)) { builtInCache = appendDefinitions(builtInFile); var updated = builtInCache.GetOldestItem(); if (updateDefinitions && updated != null && fileTime(System.Reflection.Assembly.GetExecutingAssembly().Location) > updated.Updated) { builtInCache = writeBuiltInCommands(builtInFile, profiles); } } else { if (updateDefinitions) { Logger.Write("Could not find definition file: " + builtInFile); builtInCache = writeBuiltInCommands(builtInFile, profiles); } } _cache.Merge(_enabledLanguages, builtInCache); }
public void Can_merge_two_definition_caches() { var type = DefinitionCacheItemType.Script; var time = DateTime.Now; var cache = new DefinitionCache(); cache .Add(type, "", time, false, true, "cmd1", "") .Append(type, "", time, false, true, "cmd2", "") .Append(type, "", time, false, true, "cmd3", "") .Append(type, "", time, false, false, "-g", ""); var another = new DefinitionCache(); another .Add(type, "", time, false, true, "cmdAnother", "") .Append(type, "", time, false, true, "cmdAnother2", ""); cache.Merge(another); Assert.That(cache.Definitions.Length, Is.EqualTo(2)); }
public void When_merging_two_definition_caches_it_will_not_add_duplicate_commands() { var type = DefinitionCacheItemType.Script; var time = DateTime.Now; var cache = new DefinitionCache(); cache .Add(type, "", time, false, true, "cmd1", "") .Append(type, "", time, false, true, "cmd2", "") .Append(type, "", time, false, true, "cmd3", "") .Append(type, "", time, false, false, "-g", ""); var another = new DefinitionCache(); another .Add(type, "", time, false, true, "cmd1", "") .Append(type, "", time, false, true, "cmdAnother", ""); cache.Merge(another); Assert.That(cache.Definitions.Length, Is.EqualTo(1)); }