void RemoveExistingCache()
 {
     using (var storage = IsolatedStorageFile.GetMachineStoreForAssembly())
     {
         storage.Remove();
     }
 }
        public CassetteApplicationTests()
        {
            RemoveExistingCache();

            storage          = IsolatedStorageFile.GetMachineStoreForAssembly();
            routes           = new RouteCollection();
            httpContext      = new Mock <HttpContextBase>();
            httpContextItems = new Dictionary <string, object>();
            httpContext.Setup(c => c.Items).Returns(httpContextItems);
        }
示例#3
0
        void RemoveExistingCache()
        {
            using (var storage = IsolatedStorageFile.GetMachineStoreForAssembly())
            {
#if NET35
                if (storage.GetFileNames("casette.xml").Length > 0)
                {
                    storage.DeleteFile("cassette.xml");
                }
#else
                if (storage.FileExists("cassette.xml"))
                {
                    storage.DeleteFile("cassette.xml");
                }
#endif
            }
        }
示例#4
0
        public void IsolatedStorageFileSystem_AccessesIsolatedStorage()
        {
            using (var store = IsolatedStorageFile.GetMachineStoreForAssembly())
            {
                using (var writer = new StreamWriter(store.OpenFile("test.txt", FileMode.Create, FileAccess.Write)))
                {
                    writer.Write("test");
                    writer.Flush();
                }

                var directory = new IsolatedStorageDirectory(store);
                var file      = directory.GetFile("test.txt");
                file.Exists.ShouldBeTrue();
                using (var reader = new StreamReader(file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    reader.ReadToEnd().ShouldEqual("test");
                }

                file.Delete();
                store.FileExists("test.txt").ShouldBeFalse();
            }
        }