static void Main() { while (true) { Console.Write("Enter file's size (MB): "); int size; if (!int.TryParse(Console.ReadLine(), out size)) return; using (var client = new RepositoryClientFactory().CreateClient()) { Console.WriteLine("Connecting..."); client.Open(); for (var i = 0; i < 1; i++) { Stream stream = null; using (stream) { string data; using (Perfomance.Trace("Generating data stream...").BindToConsole()) { data = GenerateRandomString(size * 1024 * 1024); stream = WriteString(data); } // Write Guid id; using (Perfomance.Trace("client.Upload").BindToConsole()) { id = client.UploadNew("test", stream); } // Read all var link = new FileLink { Id = id }; Stream download; using (Perfomance.Trace("client.Download").BindToConsole()) { download = client.Download(link.Id); } var readString = ReadString(download); Console.WriteLine(readString == data ? "Pass" : "Fail"); } } } } }
public static void Main(string[] args) { var bufferSizes = Enumerable.Range(0, 16).Select(n => (int)Math.Pow(2, n + 10)); Console.WriteLine("Enter path to text file:"); var path = Console.ReadLine(); string text; using (var reader = File.OpenText(path)) { text = reader.ReadToEnd(); } using (var client = new RepositoryClientFactory().CreateClient()) { var stream = new MemoryStream(Encoding.Default.GetBytes(text)); var id = client.UploadNew("text_upload_test", stream); foreach (var bufferSize in bufferSizes) { var readenText = ReadFile(client, id, bufferSize); if(!text.Equals(readenText)) Console.WriteLine("Failed."); } } }