Пример #1
0
        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);
            }
        }
Пример #2
0
        public void WhenTheListIsInitializedAppearsAsNOTChanged()
        {
            var arrangeableList = new ArrangeableList <string>();

            arrangeableList.InitializeWith(new List <string> {
                "1", "2", "3"
            });

            Assert.IsFalse(arrangeableList.ListHasChanged);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public void WhenAnItemIsRemovedTheListAppearsAsChanged()
        {
            var arrangeableList = new ArrangeableList <string>();

            arrangeableList.InitializeWith(new List <string> {
                "1", "2", "3"
            });

            arrangeableList.RemoveAt(1);
            Assert.IsTrue(arrangeableList.ListHasChanged);
        }
Пример #7
0
        public void WhenAnItemIsAddedTheListAppearsAsChanged()
        {
            var arrangeableList = new ArrangeableList <string>();

            arrangeableList.InitializeWith(new List <string> {
                "1", "2", "3"
            });

            arrangeableList.Add("new  element");
            Assert.IsTrue(arrangeableList.ListHasChanged);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
 private void ClearContent()
 {
     Instances = new ArrangeableList <INamed>();
     InitializeStatus();
 }