Example #1
0
        public void GetSpecialRoots()
        {
            var provider = new LinuxStorageProvider(new FeatureCollectionBuilder().Build <IStorageProvider>(), new DummyLogger(), null, new FileSystemStorageOptions {
                RootPath = "/tmp"
            });
            var roots = provider.GetRoots().ToArray();

            Assert.Single(roots, root => root is LinuxStorageRoot linuxRoot && "/tmp/" == linuxRoot.RootPath && "file:///tmp" == linuxRoot.Uri.ToString());
        }
Example #2
0
        public void GetRoots()
        {
            var features = new FeatureCollectionBuilder().Build <IStorageProvider>();
            var provider = new LinuxStorageProvider(features, new DummyLogger(), null, null);

            Assert.Equal(features.Keys, provider.Features.Keys);
            var roots = provider.GetRoots().ToArray();

            Assert.Single(roots, root => root is LinuxStorageRoot linuxRoot && "/" == linuxRoot.RootPath && "file:///" == linuxRoot.Uri.ToString());
        }
Example #3
0
 public LinuxStorageRoot(LinuxStorageProvider storageProvider, string rootPath)
     : base(storageProvider)
 {
     RootPath = rootPath ?? throw new ArgumentNullException(nameof(rootPath));
     if (!RootPath.EndsWith("/"))
     {
         RootPath += "/";
     }
     Uri = new Uri($"file://{(RootPath == "/" ? RootPath : RootPath.TrimEnd('/'))}");
 }
Example #4
0
        public void GetContainer()
        {
            var provider = new LinuxStorageProvider(new FeatureCollectionBuilder().Build <IStorageProvider>(), new DummyLogger(), null, new FileSystemStorageOptions {
                RootPath = "/tmp"
            });
            var roots = provider.GetRoots().ToArray();

            Assert.Single(roots, root => root is LinuxStorageRoot linuxRoot && "/tmp/" == linuxRoot.RootPath && "file:///tmp" == linuxRoot.Uri.ToString());
            var ts = DateTimeOffset.Now.UtcTicks.ToString();

            try
            {
                var level1 = roots[0].CreateFolder(ts);
                var level2 = level1.CreateFolder("xxx");
                Assert.Equal(level1.Uri, level2.GetContainer().Uri);
                Assert.Equal(roots[0].Uri, level1.GetContainer().Uri);
            }
            finally
            {
                System.IO.Directory.Delete($"/tmp/{ts}", true);
            }
        }