Skip to content

Commit

Permalink
Fixed failing tests for refit upgrade to v8
Browse files Browse the repository at this point in the history
  • Loading branch information
pingu2k4 committed Nov 6, 2024
1 parent 8761f5e commit 5c8bb01
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 17 additions & 17 deletions tests/PinguApps.Appwrite.Client.Tests/Utils/ResponseUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ResponseUtilsTests
public void GetApiResponse_Success_ReturnsContent()
{
var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -30,8 +30,8 @@ public async Task GetApiResponse_Failure_ReturnsError()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, response, new RefitSettings());

var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -46,8 +46,8 @@ public async Task GetApiResponse_FailureButNullErrorContent_ThrowsException()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, new HttpResponseMessage(HttpStatusCode.InternalServerError), new RefitSettings());

var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -56,8 +56,8 @@ public async Task GetApiResponse_FailureButNullErrorContent_ThrowsException()
public void GetApiResponse_FailureButNullError_ThrowsException()
{
var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns((ApiException)null!);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns((ApiException)null!);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -66,8 +66,8 @@ public void GetApiResponse_FailureButNullError_ThrowsException()
public void GenericGetApiResponse_Success_ReturnsContent()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.SetupGet(r => r.Content).Returns("Success");
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);
mockApiResponse.Setup(x => x.Content).Returns("Success");

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -79,8 +79,8 @@ public void GenericGetApiResponse_Success_ReturnsContent()
public void GenericGetApiResponse_SuccessButNullContent_ReturnsInternalError()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.SetupGet(r => r.Content).Returns((string?)null);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);
mockApiResponse.Setup(r => r.Content).Returns((string?)null);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -98,8 +98,8 @@ public async Task GenericGetApiResponse_Failure_ReturnsError()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, response, new RefitSettings());

var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -114,8 +114,8 @@ public async Task GenericGetApiResponse_FailureButNullErrorContent_ThrowsExcepti
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, new HttpResponseMessage(HttpStatusCode.InternalServerError), new RefitSettings());

var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -124,8 +124,8 @@ public async Task GenericGetApiResponse_FailureButNullErrorContent_ThrowsExcepti
public void GenericGetApiResponse_FailureButNullError_ThrowsException()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns((ApiException)null!);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns((ApiException)null!);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand Down
34 changes: 17 additions & 17 deletions tests/PinguApps.Appwrite.Server.Tests/Utils/ResponseUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ResponseUtilsTests
public void GetApiResponse_Success_ReturnsContent()
{
var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -30,8 +30,8 @@ public async Task GetApiResponse_Failure_ReturnsError()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, response, new RefitSettings());

var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -46,8 +46,8 @@ public async Task GetApiResponse_FailureButNullErrorContent_ThrowsException()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, new HttpResponseMessage(HttpStatusCode.InternalServerError), new RefitSettings());

var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -56,8 +56,8 @@ public async Task GetApiResponse_FailureButNullErrorContent_ThrowsException()
public void GetApiResponse_FailureButNullError_ThrowsException()
{
var mockApiResponse = new Mock<IApiResponse>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns((ApiException)null!);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns((ApiException)null!);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -66,8 +66,8 @@ public void GetApiResponse_FailureButNullError_ThrowsException()
public void GenericGetApiResponse_Success_ReturnsContent()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.SetupGet(r => r.Content).Returns("Success");
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);
mockApiResponse.Setup(r => r.Content).Returns("Success");

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -79,8 +79,8 @@ public void GenericGetApiResponse_Success_ReturnsContent()
public void GenericGetApiResponse_SuccessButNullContent_ReturnsInternalError()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(true);
mockApiResponse.SetupGet(r => r.Content).Returns((string?)null);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(true);
mockApiResponse.Setup(r => r.Content).Returns((string?)null);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -98,8 +98,8 @@ public async Task GenericGetApiResponse_Failure_ReturnsError()
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, response, new RefitSettings());

var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

var result = mockApiResponse.Object.GetApiResponse();

Expand All @@ -114,8 +114,8 @@ public async Task GenericGetApiResponse_FailureButNullErrorContent_ThrowsExcepti
var exception = await ApiException.Create(new HttpRequestMessage(), HttpMethod.Get, new HttpResponseMessage(HttpStatusCode.InternalServerError), new RefitSettings());

var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns(exception);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns(exception);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand All @@ -124,8 +124,8 @@ public async Task GenericGetApiResponse_FailureButNullErrorContent_ThrowsExcepti
public void GenericGetApiResponse_FailureButNullError_ThrowsException()
{
var mockApiResponse = new Mock<IApiResponse<string>>();
mockApiResponse.SetupGet(r => r.IsSuccessStatusCode).Returns(false);
mockApiResponse.SetupGet(x => x.Error).Returns((ApiException)null!);
mockApiResponse.As<IApiResponse>().Setup(x => x.IsSuccessStatusCode).Returns(false);
mockApiResponse.As<IApiResponse>().Setup(x => x.Error).Returns((ApiException)null!);

Assert.Throws<Exception>(() => mockApiResponse.Object.GetApiResponse());
}
Expand Down

0 comments on commit 5c8bb01

Please sign in to comment.