public void TestPersistentStorageGetSet() { using (XmlStreamBasedTestStorage storage = new XmlStreamBasedTestStorage()) { storage.Init(); decimal sum = 123123123.123123123123M; storage.Set("Cash", sum); object givenValue = storage.Get("Cash"); Assert.IsInstanceOfType(givenValue, typeof(Decimal)); decimal givenSum = (decimal)givenValue; Assert.AreEqual(sum, givenSum); var muchText = new String(Enumerable.Repeat('s', 4096 * 128).ToArray()); storage.Set("MuchText", muchText); string givenMuchText = (string)storage.Get("MuchText"); Assert.AreEqual(muchText, givenMuchText); decimal givenSumMore = (decimal)storage.Get("Cash"); Assert.AreEqual(givenSum, givenSumMore); decimal newCash = givenSumMore - 1233; storage.Set("Cash", newCash); decimal givenNewCash = (decimal)storage.Get("Cash"); Assert.AreEqual(newCash, givenNewCash); } }
public void Test_PersistentStorage_ShouldReadWriteChequeNum() { string testXml = null; using (var embeddedResourceReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("PavelNazarov.Common.Tests.IO.PersistentStorage.PersistentStorage_terminal_flexsoft_2013-10-29.xml"))) { testXml = embeddedResourceReader.ReadToEnd(); } using (var storage = new XmlStreamBasedTestStorage { TestXml = testXml }) { storage.Init(); 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")); } }