Ejemplo n.º 1
0
        public void Test()
        {
            SearchHistory sh = new SearchHistory(3);

            sh.QueryStrings.Add("");
            sh.QueryStrings.Add("");
            sh.QueryStrings.Add("");
            Assert.AreEqual("", sh.QueryStrings[0]);
            Assert.AreEqual("", sh.QueryStrings[1]);
            Assert.AreEqual("", sh.QueryStrings[2]);
            sh.Save();
            sh.Load();
            Assert.AreEqual(0, sh.QueryStrings.Count);
            sh.PushSearch("assaf");
            Assert.AreEqual("assaf", sh.QueryStrings[0]);
            Assert.AreEqual(1, sh.QueryStrings.Count);
            sh.PushSearch("lavie");
            Assert.AreEqual("lavie", sh.QueryStrings[0]);
            Assert.AreEqual("assaf", sh.QueryStrings[1]);
            Assert.AreEqual(2, sh.QueryStrings.Count);
            sh.PushSearch("again");
            Assert.AreEqual("again", sh.QueryStrings[0]);
            Assert.AreEqual("lavie", sh.QueryStrings[1]);
            Assert.AreEqual("assaf", sh.QueryStrings[2]);
            Assert.AreEqual(3, sh.QueryStrings.Count);
            sh.PushSearch("again");
            Assert.AreEqual("again", sh.QueryStrings[0]);
            Assert.AreEqual("lavie", sh.QueryStrings[1]);
            Assert.AreEqual("assaf", sh.QueryStrings[2]);
            sh.PushSearch("assaf");
            Assert.AreEqual("assaf", sh.QueryStrings[0]);
            Assert.AreEqual("again", sh.QueryStrings[1]);
            Assert.AreEqual("lavie", sh.QueryStrings[2]);
            sh.PushSearch("again");
            Assert.AreEqual("again", sh.QueryStrings[0]);
            Assert.AreEqual("assaf", sh.QueryStrings[1]);
            Assert.AreEqual("lavie", sh.QueryStrings[2]);
            sh.Save();
            SearchHistory sh2 = new SearchHistory(4);

            sh2.Load();
            Assert.AreEqual("again", sh.QueryStrings[0]);
            Assert.AreEqual("assaf", sh.QueryStrings[1]);
            Assert.AreEqual("lavie", sh.QueryStrings[2]);
            Assert.AreEqual(3, sh.QueryStrings.Count);
            sh2.Save();
            SearchHistory sh3 = new SearchHistory(2);

            sh3.Load();
            Assert.AreEqual("again", sh.QueryStrings[0]);
            Assert.AreEqual("assaf", sh.QueryStrings[1]);
        }
Ejemplo n.º 2
0
        private void loadSettings()
        {
            _history = new SearchHistory(int.Parse(ConfigurationManager.AppSettings["SearchFilterHistorySize"]));
            _history.Load();

            _key = Registry.CurrentUser.OpenSubKey("Software\\VisionMap\\CaseTracker");
            if (_key == null)
            {
                _username = "";
                _password = "";
                _server   = "";
            }
            else
            {
                _username = (String)_key.GetValue("email", "");
                if (string.IsNullOrEmpty(_username))
                {
                    _username = (String)_key.GetValue("username", "");
                }

                _server = (String)_key.GetValue("server", "");

                if (_server == "")
                {
                    _server = ConfigurationManager.AppSettings["FogBugzBaseURL"];
                }

                RecoverPassword(_key);

                var newLoc = new Point();
                timerRetryLogin.Interval = int.Parse(ConfigurationManager.AppSettings["RetryLoginInterval_ms"]);

                newLoc.X = (int)_key.GetValue("LastX", Location.X);
                newLoc.Y = (int)_key.GetValue("LastY", Location.Y);
                Location = newLoc;

                Width = (int)_key.GetValue("LastWidth", Width);
                timerUpdateCases.Interval =
                    (int)
                    _key.GetValue("PollingInterval",
                                  1000 * int.Parse(ConfigurationManager.AppSettings["UpdateCaseListIntervalSeconds"]));
                _switchToNothinUponClosing =
                    (int)_key.GetValue("SwitchToNothingWhenClosing", _switchToNothinUponClosing ? 1 : 0) != 0;
                _ignoreBaseSearch  = (int)_key.GetValue("IgnoreBaseSearch", _ignoreBaseSearch ? 1 : 0) != 0;
                _includeNoEstimate = (int)_key.GetValue("IncludeNoEstimate", _includeNoEstimate ? 1 : 0) != 0;

                _key.Close();
            }
        }