public void RecoverLastStatus() { var configurationFileName = ""; var configurationFileLocation = ""; try { Status.RecoverStatus(); if (Status.BackupContent.Count > 0) { configurationFileName = Status[ApplicationStatusBackup.StatusItem.ConfigurationFileName]; configurationFileLocation = Status[ApplicationStatusBackup.StatusItem.ConfigurationFileLocation]; Load(configurationFileLocation, configurationFileName); } else { Instances = new ArrangeableList <INamed>(); } } catch { Debug.WriteLine($"Could not load last configuration status from backup file. " + $"DATA: Status backup: {Status.StatusBackupPrefix + Status.StatusBackupConfigFileName} " + $"Configuration File Location: {configurationFileLocation} " + $" Configuration File Name: {configurationFileName}"); Status[ApplicationStatusBackup.StatusItem.ConfigurationFileName] = DEFAULT_CONFIGURATION_NAME; Status[ApplicationStatusBackup.StatusItem.ConfigurationFileLocation] = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } }
public void WhenTheListIsInitializedAppearsAsNOTChanged() { var arrangeableList = new ArrangeableList <string>(); arrangeableList.InitializeWith(new List <string> { "1", "2", "3" }); Assert.IsFalse(arrangeableList.ListHasChanged); }
public void GivenAnInputList_RemovingSelectedIndices_WillEndUpOnExpectedList(ArrangeableList <string> inputList, List <int> indicesToRemove, List <string> expectedList) { var removedIndices = inputList.RemoveAt(indicesToRemove); var movedAsExpected = !removedIndices .Select(x => expectedList[x] == inputList[x]) .Any(x => x == false); Assert.IsTrue(movedAsExpected); }
public void GivenAnInputList_MovingUpSelectedIndices_WillEndUpOnExpectedList(ArrangeableList <string> inputList, List <int> indicesToMove, List <string> expectedList) { var movedIndices = inputList.MoveItemsUpOnePosition(indicesToMove); var movedAsExpected = !movedIndices .Select(x => expectedList[x] == inputList[x]) .Any(x => x == false); Assert.IsTrue(movedAsExpected); }
public void WhenAnItemChangesTheListAppearsAsChanged() { var arrangeableList = new ArrangeableList <string>(); arrangeableList.InitializeWith(new List <string> { "1", "2", "3" }); arrangeableList.ReplaceAt(2, "changed element"); Assert.IsTrue(arrangeableList.ListHasChanged); }
public void WhenAnItemIsRemovedTheListAppearsAsChanged() { var arrangeableList = new ArrangeableList <string>(); arrangeableList.InitializeWith(new List <string> { "1", "2", "3" }); arrangeableList.RemoveAt(1); Assert.IsTrue(arrangeableList.ListHasChanged); }
public void WhenAnItemIsAddedTheListAppearsAsChanged() { var arrangeableList = new ArrangeableList <string>(); arrangeableList.InitializeWith(new List <string> { "1", "2", "3" }); arrangeableList.Add("new element"); Assert.IsTrue(arrangeableList.ListHasChanged); }
public void WhenAnItemIsMovedDownTheListAppearsAsChanged() { var arrangeableList = new ArrangeableList <string>(); arrangeableList.InitializeWith(new List <string> { "1", "2", "3" }); arrangeableList.MoveItemsDownOnePosition(new List <int> { 1 }); Assert.IsTrue(arrangeableList.ListHasChanged); }
private void AddNewScriptItem(ListView focusedListView) { var addForm = new frmAddEditScript(); addForm.MethodToGetErrorsOnItemInformation = _scriptsAppData.CheckForErrorsOnName; var dialogResult = addForm.ShowDialog(); if (dialogResult == DialogResult.OK) { var scriptList = ((ArrangeableList <INamed>)_scriptsAppData.Instances); if (scriptList == null) { scriptList = new ArrangeableList <INamed>(); _scriptsAppData.Instances = scriptList; } scriptList.Add(addForm.ItemInformation); var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList(); PopulateListView(scriptList, focusedListView, selectedIndices); } }
private void ClearContent() { Instances = new ArrangeableList <INamed>(); InitializeStatus(); }