public void TestDelete()
 {
     this.expected["foo"] = this.actual["foo"] = "1";
     this.expected["bar"] = this.actual["bar"] = "2";
     this.expected.Remove("foo");
     Assert.IsTrue(this.actual.Remove("foo"));
     DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
 }
        public void TestAddItem()
        {
            var item = new KeyValuePair <string, string>("thekey", "thevalue");

            ((ICollection <KeyValuePair <string, string> >) this.expected).Add(item);
            this.actual.Add(item);
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestClearTwice()
        {
            this.expected["foo"] = this.actual["foo"] = "!";

            this.expected.Clear();
            this.actual.Clear();
            this.expected.Clear();
            this.actual.Clear();
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestAdds()
        {
            for (int i = 0; i < 10; ++i)
            {
                this.expected.Add(i.ToString(), i.ToString());
                this.actual.Add(i.ToString(), i.ToString());
            }

            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestRemoveItem()
        {
            var item = new KeyValuePair <string, string>("thekey", "thevalue");

            this.expected.Add(item.Key, item.Value);
            this.actual.Add(item.Key, item.Value);
            ((ICollection <KeyValuePair <string, string> >) this.expected).Remove(item);
            Assert.IsTrue(this.actual.Remove(item));
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestClear()
        {
            for (int i = 7; i >= 0; --i)
            {
                this.expected.Add(i.ToString(), i.ToString());
                this.actual.Add(i.ToString(), i.ToString());
            }

            this.expected.Clear();
            this.actual.Clear();
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestCloseAndReopen()
        {
            var rand = new Random();

            for (int i = 0; i < 100; ++i)
            {
                string k = rand.Next().ToString();
                string v = rand.NextDouble().ToString();
                this.expected.Add(k, v);
                this.actual.Add(k, v);
            }

            this.actual.Dispose();
            this.actual = new PersistentDictionary <string, string>(DictionaryLocation);
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
        public void TestCloseAndDelete()
        {
            var rand = new Random();

            for (int i = 0; i < 64; ++i)
            {
                string k = rand.NextDouble().ToString();
                string v = rand.Next().ToString();
                this.expected.Add(k, v);
                this.actual.Add(k, v);
            }

            this.actual.Dispose();
            PersistentDictionaryFile.DeleteFiles(DictionaryLocation);

            // Deleting the files clears the dictionary
            this.expected.Clear();

            this.actual = new PersistentDictionary <string, string>(DictionaryLocation);
            DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
        }
 public void TestReplace()
 {
     this.expected["foo"] = this.actual["foo"] = "1";
     this.expected["foo"] = this.actual["foo"] = "2";
     DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
 }
 public void TestEmptyDictionary()
 {
     DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
 }
 public void TestNullValue()
 {
     this.expected["a"] = this.actual["a"] = null;
     DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
 }
 public void TestClearEmptyDictionary()
 {
     this.expected.Clear();
     this.actual.Clear();
     DictionaryAssert.AreSortedAndEqual(this.expected, this.actual);
 }