From 82099fd130b3940d2614e94f4f2c72f7205f13db Mon Sep 17 00:00:00 2001 From: Paul Huck Date: Mon, 23 Mar 2015 11:27:47 -0700 Subject: [PATCH] Remove DeleteResponse It's IsSuccess property is redundant since the request will throw a FirebaseException if it failed. --- FireSharp.Tests/FirebaseClientTests.cs | 1 - FireSharp.Tests/FiresharpTests.cs | 6 ++---- FireSharp/FireSharp.csproj | 1 - FireSharp/FirebaseClient.cs | 8 ++++---- FireSharp/Interfaces/IFirebaseClient.cs | 4 ++-- FireSharp/Response/DeleteResponse.cs | 26 ------------------------- 6 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 FireSharp/Response/DeleteResponse.cs diff --git a/FireSharp.Tests/FirebaseClientTests.cs b/FireSharp.Tests/FirebaseClientTests.cs index 1ce4ca9..d3dd61d 100644 --- a/FireSharp.Tests/FirebaseClientTests.cs +++ b/FireSharp.Tests/FirebaseClientTests.cs @@ -114,7 +114,6 @@ public async void Delete() var response = await _firebaseClient.DeleteAsync("todos"); Assert.NotNull(response); - Assert.AreEqual(response.Success, true); } [Test] diff --git a/FireSharp.Tests/FiresharpTests.cs b/FireSharp.Tests/FiresharpTests.cs index e78d512..6d6cf11 100644 --- a/FireSharp.Tests/FiresharpTests.cs +++ b/FireSharp.Tests/FiresharpTests.cs @@ -21,8 +21,8 @@ public class FiresharpTests : TestBase [TestFixtureSetUp] public async void TestFixtureSetUp() { - Task task1 = _client.DeleteAsync("todos"); - Task task2 = _client.DeleteAsync("fakepath"); + Task task1 = _client.DeleteAsync("todos"); + Task task2 = _client.DeleteAsync("fakepath"); await Task.WhenAll(task1, task2); } @@ -48,7 +48,6 @@ public async Task DeleteAsync() var response = await _client.DeleteAsync("todos/pushAsync"); Assert.NotNull(response); - Assert.IsTrue(response.Success); } [Test, Category("INTEGRATION"), Category("ASYNC")] @@ -172,7 +171,6 @@ public void Delete() var response = _client.Delete("todos/push"); Assert.NotNull(response); - Assert.IsTrue(response.Success); } [Test, Category("INTEGRATION"), Category("SYNC")] diff --git a/FireSharp/FireSharp.csproj b/FireSharp/FireSharp.csproj index bbd1050..13120c2 100644 --- a/FireSharp/FireSharp.csproj +++ b/FireSharp/FireSharp.csproj @@ -88,7 +88,6 @@ - diff --git a/FireSharp/FirebaseClient.cs b/FireSharp/FirebaseClient.cs index f9a2827..0a14ca7 100644 --- a/FireSharp/FirebaseClient.cs +++ b/FireSharp/FirebaseClient.cs @@ -83,14 +83,14 @@ public PushResponse Push(string path, T data) } } - public DeleteResponse Delete(string path) + public FirebaseResponse Delete(string path) { try { HttpResponseMessage response = _requestManager.Delete(path); string content = response.Content.ReadAsStringAsync().Result; HandleIfErrorResponse(response.StatusCode, content); - return new DeleteResponse(content, response.StatusCode); + return new FirebaseResponse(content, response.StatusCode); } catch (HttpRequestException ex) { @@ -158,14 +158,14 @@ public async Task PushAsync(string path, T data) } } - public async Task DeleteAsync(string path) + public async Task DeleteAsync(string path) { try { HttpResponseMessage response = await _requestManager.DeleteAsync(path); string content = await response.Content.ReadAsStringAsync(); HandleIfErrorResponse(response.StatusCode, content); - return new DeleteResponse(content, response.StatusCode); + return new FirebaseResponse(content, response.StatusCode); } catch (HttpRequestException ex) { diff --git a/FireSharp/Interfaces/IFirebaseClient.cs b/FireSharp/Interfaces/IFirebaseClient.cs index 358d46a..3952056 100644 --- a/FireSharp/Interfaces/IFirebaseClient.cs +++ b/FireSharp/Interfaces/IFirebaseClient.cs @@ -12,12 +12,12 @@ public interface IFirebaseClient Task> OnChangeGetAsync(string path, ValueRootAddedEventHandler added = null); Task SetAsync(string path, T data); Task PushAsync(string path, T data); - Task DeleteAsync(string path); + Task DeleteAsync(string path); Task UpdateAsync(string path, T data); FirebaseResponse Get(string path); SetResponse Set(string path, T data); PushResponse Push(string path, T data); - DeleteResponse Delete(string path); + FirebaseResponse Delete(string path); FirebaseResponse Update(string path, T data); [Obsolete("This method is obsolete use OnAsync instead.")] diff --git a/FireSharp/Response/DeleteResponse.cs b/FireSharp/Response/DeleteResponse.cs deleted file mode 100644 index 5b788a6..0000000 --- a/FireSharp/Response/DeleteResponse.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Net; -using System.Net.Http; - -namespace FireSharp.Response -{ - public class DeleteResponse : FirebaseResponse - { - public DeleteResponse(string body, HttpStatusCode statusCode, HttpResponseMessage httpResponse) - : base(body, statusCode, httpResponse) - { - } - - public DeleteResponse(string body, HttpStatusCode statusCode) - : base(body, statusCode) - { - } - - public bool Success - { - get - { - return StatusCode == HttpStatusCode.OK || StatusCode == HttpStatusCode.NoContent; - } - } - } -} \ No newline at end of file