public void TestGetExpectObjectNotFound() { var client = new BunClient(ConnectionInfo.apiKey, ConnectionInfo.zone); Stream s = new MemoryStream(); var r = client.GetFile(ConnectionInfo.badZone).Result; Assert.AreEqual(HttpStatusCode.NotFound, r.StatusCode); }
public void TestFileOperations() { var client = new BunClient(ConnectionInfo.apiKey, ConnectionInfo.zone); // Write a file. var progress = new NaiveProgress <ICopyProgress>(x => { ; }); var writeResponse = client.PutFile(testContent, testFile, progress).Result; Assert.AreEqual(HttpStatusCode.Created, writeResponse); // Check for our file in the file listing. var listResponse = client.ListFiles().Result; Assert.AreEqual(HttpStatusCode.OK, listResponse.StatusCode); Assert.IsTrue(listResponse.Files.Where(x => x.ObjectName == testFile).Count() == 1); // Read back the file. using (var readStream = new MemoryStream()) { var readResponse = client.GetFile(testFile, readStream).Result; Assert.AreEqual(HttpStatusCode.OK, readResponse); string fileContent = null; using (var reader = new StreamReader(readStream)) { fileContent = reader.ReadToEnd(); } Assert.AreEqual(testContent, fileContent); } // Test deleting the file. var deleteResult = client.DeleteFile(testFile).Result; Assert.AreEqual(HttpStatusCode.OK, deleteResult); }