private void ValidateConnectionSwitch(Action connectionSwitchAction)
        {
            OctaneConfiguration.Url = Guid.NewGuid().ToString();

            CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Invalid initial history");

            WorkspaceSessionPersistanceManager.UpdateHistory("1");
            var defect = new Defect(111)
            {
                SubType = WorkItem.SUBTYPE_DEFECT
            };

            WorkspaceSessionPersistanceManager.SetActiveEntity(defect);

            connectionSwitchAction();

            CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Mismatched history after reset");
            ValidateActiveEntity(null);

            WorkspaceSessionPersistanceManager.UpdateHistory("2");
            WorkspaceSessionPersistanceManager.SetActiveEntity(defect);

            CollectionAssert.AreEqual(new List <string> {
                "2"
            }, WorkspaceSessionPersistanceManager.History, "Mismatched history");
            ValidateActiveEntity(defect);
        }
Exemplo n.º 2
0
        private void SearchInternal(object parameter)
        {
            if (string.IsNullOrEmpty(SearchFilter) || string.IsNullOrEmpty(SearchFilter.Trim()))
            {
                return;
            }

            SearchFilter = SearchFilter.Trim();

            WorkspaceSessionPersistanceManager.UpdateHistory(SearchFilter);
            NotifyPropertyChanged("SearchHistory");

            PluginWindowManager.ShowSearchWindow(MainWindow.PluginPackage, SearchFilter);
        }
        public void WorkspaceSessionPersistanceManagerTests_UpdateHistory_EmptyFilter_Success()
        {
            OctaneConfiguration.Url = Guid.NewGuid().ToString();

            CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Invalid initial history");

            WorkspaceSessionPersistanceManager.UpdateHistory("a");
            WorkspaceSessionPersistanceManager.UpdateHistory("b");
            var expectedHistory = new List <string> {
                "b", "a"
            };

            CollectionAssert.AreEqual(expectedHistory, WorkspaceSessionPersistanceManager.History, "Mismatched history");

            WorkspaceSessionPersistanceManager.UpdateHistory(string.Empty);

            CollectionAssert.AreEqual(expectedHistory, WorkspaceSessionPersistanceManager.History, "Mismatched history after trying to add empty string");
        }
        public void WorkspaceSessionPersistanceManagerTests_UpdateHistory_SaveExactlyMaxElements_Success()
        {
            OctaneConfiguration.Url = Guid.NewGuid().ToString();

            CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Invalid initial history");

            var expectedHistory = new List <string>();

            for (var i = 0; i < WorkspaceSessionPersistanceManager.MaxSearchHistorySize; i++)
            {
                expectedHistory.Add(i.ToString());
                WorkspaceSessionPersistanceManager.UpdateHistory(i.ToString());
            }

            expectedHistory.Reverse();

            CollectionAssert.AreEqual(expectedHistory, WorkspaceSessionPersistanceManager.History, "Mismatched history");
        }
        public void WorkspaceSessionPersistanceManagerTests_UpdateHistory_ResetApplication_Success()
        {
            OctaneConfiguration.Url = Guid.NewGuid().ToString();

            CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Invalid initial history");

            WorkspaceSessionPersistanceManager.UpdateHistory("1");

            var exposedHistoryManager = ExposedClass.From(typeof(WorkspaceSessionPersistanceManager));

            exposedHistoryManager._metadata = null;

            CollectionAssert.AreEqual(new List <string> {
                "1"
            }, WorkspaceSessionPersistanceManager.History, "Mismatched history after reset");

            WorkspaceSessionPersistanceManager.UpdateHistory("2");

            CollectionAssert.AreEqual(new List <string> {
                "2", "1"
            }, WorkspaceSessionPersistanceManager.History, "Mismatched history");
        }