public void Setup() { TestRoot = Path.Combine(GetFolderPath(SpecialFolder.MyDocuments), "Personal Cloud"); Directory.CreateDirectory(TestRoot); TestRoot = Path.Combine(TestRoot, "Test Container"); if (Directory.Exists(TestRoot)) { Assert.Inconclusive("Previous test session may have failed. Please ensure \"" + Path.GetDirectoryName(TestRoot) + "\" is empty before starting a new session."); return; } Directory.CreateDirectory(TestRoot); Server = new HttpProvider(10240, new VirtualFileSystem(TestRoot)); Server.Start(); Client = new TopFolderClient($"http://localhost:10240", new byte[32], ""); }
public void Setup() { var logdir = TestRoot = Path.Combine(GetFolderPath(SpecialFolder.MyDocuments), "Personal Cloud"); Directory.CreateDirectory(TestRoot); TestRoot = Path.Combine(TestRoot, "Test Container"); if (Directory.Exists(TestRoot)) { Assert.Inconclusive("Previous test session may have failed. Please ensure \"" + Path.GetDirectoryName(TestRoot) + "\" is empty before starting a new session."); return; } Directory.CreateDirectory(TestRoot); Directory.CreateDirectory(logdir); Loggers = LoggerFactory.Create(builder => builder.//SetMinimumLevel(LogLevel.Trace). AddConsole(x => { x.TimestampFormat = "G"; })); #pragma warning disable CA2000 // Dispose objects before losing scope var pfs = new Zio.FileSystems.PhysicalFileSystem(); #pragma warning restore CA2000 // Dispose objects before losing scope pfs.CreateDirectory(pfs.ConvertPathFromInternal(TestRoot)); var fs = new Zio.FileSystems.SubFileSystem(pfs, pfs.ConvertPathFromInternal(TestRoot), true); Server = new HttpProvider(10240, fs); Server.Start(); var c = new TopFolderClient($"http://localhost:10240", new byte[32], ""); var dic = new Dictionary <string, IFileSystem>(); dic["Files"] = c; Client = new FileSystemContainer(dic, Loggers.CreateLogger("FileContainerWebApiTest")); }
public void Setup() { TestRoot = Path.Combine(GetFolderPath(SpecialFolder.MyDocuments), "Personal Cloud"); Directory.CreateDirectory(TestRoot); TestRoot = Path.Combine(TestRoot, "Test Container"); if (Directory.Exists(TestRoot)) { Assert.Inconclusive("Previous test session may have failed. Please ensure \"" + Path.GetDirectoryName(TestRoot) + "\" is empty before starting a new session."); return; } Directory.CreateDirectory(TestRoot); var logsDir = Path.Combine(TestRoot, "Logs"); Directory.CreateDirectory(logsDir); Loggers = LoggerFactory.Create(builder => builder.//SetMinimumLevel(LogLevel.Trace). AddConsole(x => { x.TimestampFormat = "G"; })); var dic = new Dictionary <string, IFileSystem>(); dic["Files"] = new VirtualFileSystem(TestRoot); var RootFs = new FileSystemContainer(dic, Loggers.CreateLogger("FileContainerWebApiTest")); Server = new HttpProvider(10240, RootFs); Server.Start(); Client = new TopFolderClient($"http://localhost:10240", new byte[32], ""); }
public async Task LargeFileTest() { long filesize = 10L * 1024 * 1024 * 1024; var testRoot = "I:\\Personal Cloud Test\\"; int parts = 128; var partsize = filesize / parts; if (((filesize / parts) % 256) != 0) { #pragma warning disable CA1303 // Do not pass literals as localized parameters Assert.Fail("filesize/parts must be a multiple of 256"); //otherwise you have to rewrite TestStream #pragma warning restore CA1303 // Do not pass literals as localized parameters } Directory.CreateDirectory(testRoot); #pragma warning disable CA2000 // Dispose objects before losing scope var fs = new PhysicalFileSystem(); #pragma warning restore CA2000 // Dispose objects before losing scope var subfs = new SubFileSystem(fs, fs.ConvertPathFromInternal(testRoot), true); using var server = new HttpProvider(100, subfs); server.Start(); using var client = new TopFolderClient($"http://localhost:100", new byte[32], ""); //if(false) { try { await client.DeleteAsync("test.txt").ConfigureAwait(false); } #pragma warning disable CA1031 // Do not catch general exception types catch { } using var teststrm = new TestStream(filesize); await client.WriteFileAsync("test.txt", teststrm).ConfigureAwait(false); await TestRead("test.txt", filesize, parts, client).ConfigureAwait(false); await Task.Delay(1000).ConfigureAwait(false); try { await client.DeleteAsync("test.txt").ConfigureAwait(false); } catch { } } //if (false) { try { await client.DeleteAsync("test1.txt").ConfigureAwait(false); } catch { } var origpart = parts; if ((filesize % parts) != 0) { parts++; } { using var teststrm = new TestStream(partsize); await client.WriteFileAsync("test1.txt", teststrm).ConfigureAwait(false); } for (int i = 1; i < origpart; i++) { using var teststrm = new TestStream(partsize); await client.WritePartialFileAsync("test1.txt", partsize *i, partsize, teststrm).ConfigureAwait(false); } if (origpart < parts) { partsize = filesize % origpart; using var teststrm = new TestStream(partsize); await client.WritePartialFileAsync("test1.txt", partsize *origpart, partsize, teststrm).ConfigureAwait(false); } await TestRead("test1.txt", filesize, parts, client).ConfigureAwait(false); await Task.Delay(1000).ConfigureAwait(false); try { await client.DeleteAsync("test1.txt").ConfigureAwait(false); } catch #pragma warning restore CA1031 // Do not catch general exception types { } } }