Esempio n. 1
0
        public void SaveManyCredentials()
        {
            var fn = FileUtility.GetTempFileName(".txt");

            TextFileCredentials c = new TextFileCredentials(fn);

            for (int i = 0; i < 30; i++)
            {
                var pw  = "a".PadRight(i + 1, 'B');
                var svr = "server" + i;
                Logger.WriteLine(svr);
                Logger.WriteLine(pw);
                c.Save(svr, pw);
                Logger.WriteLine(c.GetPassword(svr));
            }

            for (int i = 0; i < 30; i++)
            {
                Assert.IsTrue(c.Contains("server" + 1));

                var pw  = "a".PadRight(i + 1, 'B');
                var svr = c.GetPassword("server" + i);
                Assert.AreEqual(svr, pw);
            }
        }
Esempio n. 2
0
        private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var cb = sender as ComboBox;

            if (cb == null)
            {
                return;
            }

            string sel = cb.SelectedItem.ToString().Trim();

            if (sel == clearItems)
            {
                var msg    = "OK to clear database list?";
                var result = MessageBox.Show(msg, "Clear Database List", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    dbList.Clear();
                    cb.Items.Clear();
                    Properties.Settings.Default.Save();
                }
                else
                {
                    cb.SelectedIndex = currentIdx;
                }
            }

            if (credentials.Contains(sel))
            {
                textBoxPassword.Text = credentials.GetPassword(sel);
            }
            else
            {
                textBoxPassword.Text = "";
            }
        }