Beispiel #1
0
        private Task WriteTestFileToCache(DocularCache cache, String fileName, String storeName)
        {
            using (MemoryStream ms = new MemoryStream())
                using (StreamWriter sw = new StreamWriter(ms))
                {
                    sw.Write(TestSentence);
                    sw.Flush();
                    ms.Position = 0;

                    return(cache.Add(fileName, ms, storeName));
                }
        }
Beispiel #2
0
        public async Task TestCacheStoreAndRetreive()
        {
            DocularCache cache = new DocularCache();

            await this.WriteTestFileToCache(cache, "TestStoreAndRetreive", "Default");

            using (Stream s = await cache.Get("TestStoreAndRetreive", "Default"))
            {
                Assert.IsNotNull(s, "The received file was null, meaning it was deleted while the test ran.");
                using (StreamReader sr = new StreamReader(s))
                {
                    Assert.AreEqual(TestSentence, sr.ReadToEnd(), "The retreived text was not the same!");
                }
            }
        }