public void TestDeserialize()
 {
     BinarySerializableDictionary<string, string> dict = new BinarySerializableDictionary<string, string>();
     string filePath = ConfigurationManager.AppSettings["DataStoreFilePath"];
     dict = BinarySerializableDictionary<string, string>.Deserialize(filePath + @"\testdeserializedict.bin");
     Assert.AreEqual("yes", dict["hi"]);
 }
        public void TestDeserialize()
        {
            BinarySerializableDictionary <string, string> dict = new BinarySerializableDictionary <string, string>();
            string filePath = ConfigurationManager.AppSettings["DataStoreFilePath"];

            dict = BinarySerializableDictionary <string, string> .Deserialize(filePath + @"\testdeserializedict.bin");

            Assert.AreEqual("yes", dict["hi"]);
        }
 public void TestSerialize()
 {
     string filePath = ConfigurationManager.AppSettings["DataStoreFilePath"];
     if (File.Exists(filePath + @"\testserializedict.bin"))
     {
         File.Delete(filePath + @"\tesetserializedict.bin");
     }
     BinarySerializableDictionary<string, string> dict = new BinarySerializableDictionary<string, string>();
     dict.TryAdd("hi", "yes");
     BinarySerializableDictionary<string, string>.Serialize(dict, filePath + @"\testserializedict.bin");
     if(File.Exists(filePath + @"\testserializedict.bin"))
     {
         Assert.True(true);
     }
 }
        public void TestSerialize()
        {
            string filePath = ConfigurationManager.AppSettings["DataStoreFilePath"];

            if (File.Exists(filePath + @"\testserializedict.bin"))
            {
                File.Delete(filePath + @"\tesetserializedict.bin");
            }
            BinarySerializableDictionary <string, string> dict = new BinarySerializableDictionary <string, string>();

            dict.TryAdd("hi", "yes");
            BinarySerializableDictionary <string, string> .Serialize(dict, filePath + @"\testserializedict.bin");

            if (File.Exists(filePath + @"\testserializedict.bin"))
            {
                Assert.True(true);
            }
        }
예제 #5
0
 /// <summary>
 /// A method that takes the name of a file on disk,
 /// and deserialises that into the KeyValueStore
 /// member variable.
 /// </summary>
 /// <param name="name">The name of the dictionary.</param>
 /// <returns>
 /// A queryresult on whether the operation succeeded or not.
 /// </returns>
 public QueryResult LoadStore(string name)
 {
     string filePath = ConfigurationManager.AppSettings["DataStoreFilePath"] + name;
     try
     {
         KeyValueStore = BinarySerializableDictionary<string, string>.Deserialize(filePath);
         return new QueryResult("Success", null, null);
     }
     catch (Exception e)
     {
         return new QueryResult("Failed", e, null);
     }
 }
예제 #6
0
 /// <summary>
 /// A constructor that initialises the KeyValueStore member variable with
 ///a default capacity.
 /// </summary>
 public DataService()
 {
     KeyValueStore = new BinarySerializableDictionary<string, string>();
 }