Esempio n. 1
0
        public void OneTimeSetUp()
        {
            storage           = new TemporaryNativeStorage("fontstore-test");
            fontResourceStore = new NamespacedResourceStore <byte[]>(new DllResourceStore(typeof(Drawable).Assembly.Location), "Resources.Fonts.OpenSans");

            storage.GetFullPath("./", true);
        }
        public void TestRelativePaths()
        {
            var guid = new Guid().ToString();

            using (var storage = new TemporaryNativeStorage(guid))
            {
                var basePath = storage.GetFullPath(string.Empty);

                Assert.IsTrue(basePath.EndsWith(guid));

                Assert.Throws <ArgumentException>(() => storage.GetFullPath("../"));
                Assert.Throws <ArgumentException>(() => storage.GetFullPath(".."));
                Assert.Throws <ArgumentException>(() => storage.GetFullPath("./../"));

                Assert.AreEqual(Path.GetFullPath(Path.Combine(basePath, "sub", "test")) + Path.DirectorySeparatorChar, storage.GetFullPath("sub/test/"));
                Assert.AreEqual(Path.GetFullPath(Path.Combine(basePath, "sub", "test")), storage.GetFullPath("sub/test"));
            }
        }
        public void TestMonitorRenameFile()
        {
            using (var storage = new TemporaryNativeStorage(Guid.NewGuid().ToString()))
                using (var monitor = new MonitoredStorage(storage))
                {
                    int renames = 0;
                    monitor.FileRenamed += (_, __) => renames++;

                    string name = Guid.NewGuid().ToString();
                    storage.GetStream(name, FileAccess.ReadWrite).Dispose();

                    Thread.Sleep(10);

                    string nameReplace = Guid.NewGuid().ToString();
                    var    fi          = new FileInfo(storage.GetFullPath(name));
                    fi.MoveTo(Path.Combine(storage.GetFullPath(string.Empty), nameReplace));

                    Thread.Sleep(10);

                    Assert.IsTrue(monitor.Files.Contains(nameReplace));
                    Assert.IsTrue(renames == 1);
                }
        }
Esempio n. 4
0
 private static string getTempFilename() => temp_storage.GetFullPath(Guid.NewGuid() + ".osz");
Esempio n. 5
0
        public void TestGetEmptySubDirectoryStorage()
        {
            string guid = Guid.NewGuid().ToString();

            using (var storage = new TemporaryNativeStorage(guid))
            {
                Assert.That(storage.GetStorageForDirectory(string.Empty).GetFullPath(string.Empty), Is.EqualTo(storage.GetFullPath(string.Empty)));
            }
        }
        public void TestGetSubDirectoryStorage()
        {
            var guid = new Guid().ToString();

            using (var storage = new TemporaryNativeStorage(guid))
            {
                Assert.That(storage.GetStorageForDirectory("subdir").GetFullPath(string.Empty), Is.EqualTo(Path.Combine(storage.GetFullPath(string.Empty), "subdir")));
            }
        }