public async Task ComputeChangeSetFromModList_WithConflictingMods_ThrowsInconsistentKraken() { using (var tidy = new DisposableKSP()) { var registry = Registry.Empty(); var module = TestData.FireSpitterModule(); module.conflicts = new List <RelationshipDescriptor> { new RelationshipDescriptor { name = "kOS" } }; registry.AddAvailable(module); registry.AddAvailable(TestData.kOS_014_module()); registry.RegisterModule(module, Enumerable.Empty <string>(), tidy.KSP); var mainList = new MainModList(null, null, new GUIUser()); var mod = new GUIMod(module, registry, tidy.KSP.Version()); var mod2 = new GUIMod(TestData.kOS_014_module(), registry, tidy.KSP.Version()); var mods = new List <GUIMod>() { mod, mod2 }; mainList.ConstructModList(mods, true); mainList.Modules = new ReadOnlyCollection <GUIMod>(mods); mod2.IsInstallChecked = true; var computeTask = mainList.ComputeChangeSetFromModList(registry, mainList.ComputeUserChangeSet(), null, tidy.KSP.Version()); await UtilStatic.Throws <InconsistentKraken>(() => computeTask); } }
public void TestSimple() { var modules = _registry.available_modules .Select((mod) => new GUIMod(mod.Value.Latest(), _registry, _instance.KSP.VersionCriteria())) .ToList(); // varargs method signature means we must call .ToArray() _listGui.Rows.AddRange(_modList.ConstructModList(modules).ToArray()); // the header row adds one to the count Assert.AreEqual(modules.Count + 1, _listGui.Rows.Count); // sort by a text column, this is the fuse-lighting _listGui.Sort(_listGui.Columns[6], ListSortDirection.Descending); // mark the mod for install, after completion we will get an exception var otherModule = modules.First((mod) => mod.Identifier.Contains("kOS")); otherModule.IsInstallChecked = true; Assert.IsTrue(otherModule.IsInstallChecked); Assert.IsFalse(otherModule.IsInstalled); Assert.DoesNotThrow(() => { // perform the install of the "other" module - now we need to sort ModuleInstaller.GetInstance(_instance.KSP, _manager.Cache, _manager.User).InstallList( _modList.ComputeUserChangeSet(null).Select(change => change.Mod.ToCkanModule()).ToList(), new RelationshipResolverOptions(), new NetAsyncModulesDownloader(_manager.User, _manager.Cache) ); // trying to refresh the GUI state will throw a NullReferenceException _listGui.Refresh(); }); }
public void ComputeChangeSetFromModList_WithEmptyList_HasEmptyChangeSet() { using (new DisposableKSP()) { var item = new MainModList(delegate { }); Assert.That(item.ComputeUserChangeSet(), Is.Empty); } }
public void ComputeChangeSetFromModList_WithEmptyList_HasEmptyChangeSet() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; var item = new MainModList(delegate { }); Assert.That(item.ComputeUserChangeSet(), Is.Empty); } }
public void ComputeChangeSetFromModList_WithEmptyList_HasEmptyChangeSet() { var item = new MainModList(delegate { }, delegate { return(null); }); Assert.That(item.ComputeUserChangeSet(), Is.Empty); }
public void ComputeChangeSetFromModList_WithConflictingMods_ThrowsInconsistentKraken() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; var registry = Registry.Empty(); var module = TestData.FireSpitterModule(); module.conflicts = new List <RelationshipDescriptor>() { new RelationshipDescriptor { name = "kOS" } }; registry.AddAvailable(TestData.FireSpitterModule()); registry.AddAvailable(TestData.kOS_014_module()); registry.RegisterModule(module, Enumerable.Empty <string>(), tidy.KSP); var main_mod_list = new MainModList(null); var mod = new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.Version()); var mod2 = new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.Version()); mod.IsInstallChecked = true; mod2.IsInstallChecked = true; var mod_list = main_mod_list.ConstructModList(new List <GUIMod> { mod, mod2 }); Assert.Throws <InconsistentKraken>(() => MainModList.ComputeChangeSetFromModList(registry, main_mod_list.ComputeUserChangeSet(), null, tidy.KSP.Version())); } }