Пример #1
0
        public void CheckFileTokenStartingWithSlash(string fileName)
        {
            DirectoryFileStore store = new DirectoryFileStore("test", new DirectoryFileStoreConfig
            {
                BasePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
            });

            Assert.Equal("file://test" + fileName, store.CreateFileToken(fileName).Result);
        }
Пример #2
0
        public void CheckCreateAndDeleteFile(string fileName)
        {
            DirectoryFileStore store = new DirectoryFileStore("test", new DirectoryFileStoreConfig
            {
                BasePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
            });

            var token = store.CreateFileToken(fileName).Result;

            using (var stream = store.OpenWrite(token).Result)
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("hello");
                }

            Assert.True(store.Exists(token).Result);
            Assert.Equal("hello",
                         File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                                       fileName)));

            store.Delete(token).Wait();
            Assert.False(store.Exists(token).Result);
        }