public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Return the property Current in Dictionary KeyCollection Enumerator 2");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer = new Dictionary<string, string>.KeyCollection(dic).GetEnumerator();
         while (keyEnumer.MoveNext())
         {
             if (keyEnumer.Current != "1")
             {
                 TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult");
                 retVal = false;
             }
         }
         keyEnumer.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the MoveNext method in Dictionary ValueCollection Enumerator");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         Dictionary<string, string>.ValueCollection.Enumerator ValEnumer1 = new Dictionary<string, string>.ValueCollection(dic).GetEnumerator();
         if (ValEnumer1.Current != null || ValEnumer1.MoveNext() != true)
         {
             TestLibrary.TestFramework.LogError("001.1", "The ExpectResult is not the ActualResult");
             retVal = false;
         }
         if (ValEnumer1.MoveNext())
         {
             TestLibrary.TestFramework.LogError("001.2", "The method MoveNext should return false but it did not");
         }
         ValEnumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
        public void Dictionary_thread_test()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory;
            Dictionary<int, int> testDictionary = new Dictionary<int, int>(path);
            try
            {
                _error = false;

                System.Collections.Generic.List<Thread> tList = new System.Collections.Generic.List<Thread>(100);
                for (int i = 0; i < 20; i++)
                {
                    Thread t = new Thread(DoWriteTest3);
                    tList.Add(t);
                    t.Start(testDictionary);
                }

                for (int i = 0; i < 20; i++)
                {
                    Thread t = new Thread(DoReadTest3);
                    tList.Add(t);
                    t.Start(testDictionary);
                }

                foreach (Thread t in tList)
                {
                    t.Join();
                }
                Assert.IsFalse(_error);
            }
            finally
            {
                testDictionary.Dispose();
            }
        }
 public void LoadExistingDict()
 {
     try
     {
         var dict = new Dictionary<int, int>(_path, 20, true, "test1");
         Assert.AreEqual(2, dict.Count);
         Assert.AreEqual(0, dict[0]);
         Assert.AreEqual(1, dict[1]);
         dict.Dispose();
     }
     catch (AssertionException e)
     {
         //assertfailed
         _errorMessage = e.Message;
         _error = true;
     }
 }
 public void CreateDict()
 {
     try
     {
         var dict = new Dictionary<int, int>(_path, 20, true, "test1");
         dict[0] = 0;
         dict[1] = 1;
         Assert.AreEqual(2, dict.Count);
         Assert.AreEqual(0, dict[0]);
         Assert.AreEqual(1, dict[1]);
         dict.Dispose();
     }
     catch (AssertionException e)
     {
         //Assertion failed..
         _errorMessage = e.Message;
         _error = true;
     }
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the Dispose method in Dictionary KeyCollection Enumerator 1");
     try
     {
         Dictionary<string, string> dic = new Dictionary<string, string>();
         dic.Add("1", "test1");
         dic.Add("2", "test2");
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer1 = new Dictionary<string, string>.KeyCollection.Enumerator();
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer2 = new Dictionary<string,string>.KeyCollection(dic).GetEnumerator();
         keyEnumer2.Dispose();
         keyEnumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("001", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the property Current in Dictionary KeyCollection Enumerator 1");
     try
     {
         Dictionary<string, string>.KeyCollection.Enumerator keyEnumer = new Dictionary<string, string>.KeyCollection.Enumerator();
         if (keyEnumer.Current != null)
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult");
             retVal = false;
         }
         keyEnumer.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the Dispose method in Dictionary Enumerator 2");
     try
     {
         myClass TKey = new myClass();
         myClass TValue = new myClass();
         Dictionary<myClass, myClass> dic = new Dictionary<myClass, myClass>();
         dic.Add(TKey,TValue );
         Dictionary<myClass, myClass>.Enumerator enumer1 = new Dictionary<myClass, myClass>.Enumerator();
         Dictionary<myClass, myClass>.Enumerator enumer2 = dic.GetEnumerator();
         enumer2.Dispose();
         enumer1.Dispose();
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
        public void When_adding_more_items_to_an_existing_file_validate_the_content2()
        {
            var dict = new Dictionary<string, int>(_path, 20, true, "test1");
            dict["new0"] = 0;
            dict["new1"] = 1;

            foreach (var kvp in dict)
            {
                if( kvp.Key != "new0" && kvp.Key != "new1")
                    Assert.Fail("Error in reading keys");
            }

            dict.Dispose();
            dict = new Dictionary<string, int>(_path, 20, true, "test1");
            Assert.AreEqual(2, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            dict["test0"] = 2;

            foreach (var kvp in dict)
            {
                if (kvp.Key != "new0" && kvp.Key != "new1" && kvp.Key != "test0")
                    Assert.Fail("Error in reading keys");
            }

            Assert.AreEqual(3, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            Assert.AreEqual(2, dict["test0"]);

            dict.Dispose();
            dict = new Dictionary<string, int>(_path, 20, true, "test1");
            Assert.AreEqual(3, dict.Count);
            Assert.AreEqual(0, dict["new0"]);
            Assert.AreEqual(1, dict["new1"]);
            Assert.AreEqual(2, dict["test0"]);
        }