public void Test_PersistentStorage_ShouldWorkProperlyWithRealFile()
 {
     string tempDirPath = Path.GetTempPath();
     string filename = String.Format(@"ps_{0:yyyy-MM-ddTHH-mm-ss}.xml", DateTime.Now);
     filename = Path.Combine(tempDirPath, filename);
     var storage = new XmlFileBasedPersistentStorage(new XmlFileBasedPersistentStorageSettings { FullFileName = filename, UseBOM = true });
     decimal num = 234.234M;
     storage.Set("key1", num);
     decimal numRead = (decimal)storage.Get("key1");
     Assert.AreEqual(num, numRead);
 }
        public void Test_PersistentStorage_ShouldReadWriteChequeNumFromFile()
        {
            string tempFileName = Path.GetTempFileName();
            using (var fs = File.Create(tempFileName))
            {
                using (var embeddedResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PavelNazarov.Common.Tests.IO.PersistentStorage.PersistentStorage_terminal_flexsoft_2013-10-29.xml"))
                {
                    embeddedResourceStream.CopyTo(fs);
                }
            }

            var storage = new XmlFileBasedPersistentStorage(new XmlFileBasedPersistentStorageSettings { FullFileName = tempFileName });
            object initialChequeNumBoxed = storage.Get("chequeNum");
            Assert.IsNotNull(initialChequeNumBoxed);
            Assert.IsInstanceOfType(initialChequeNumBoxed, typeof(int));
            int initialChequeNum = (int)initialChequeNumBoxed;

            int newChequeNum = initialChequeNum + 1;
            storage.Set("chequeNum", newChequeNum);

            Assert.AreEqual(newChequeNum, storage.Get("chequeNum"));
        }