Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 7fbb0e5

Browse files
committed
fix(Tests) fix tests
1 parent a79e13a commit 7fbb0e5

6 files changed

Lines changed: 10 additions & 11 deletions

File tree

ReversoAPI.Web.Tests/Clients/SpellingClientTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using ReversoAPI.Web.GrammarCheckFeature.Application.Services;
1212
using ReversoAPI.Web.Shared.Infrastructure.Http;
1313
using ReversoAPI.Web.Shared.Infrastructure.Http.Interfaces;
14+
using System.Net;
1415

1516
namespace ReversoAPI.Web.Tests.Clients
1617
{
@@ -22,15 +23,15 @@ public class SpellingClientTests
2223
public SpellingClientTests()
2324
{
2425
_apiConnector = new Mock<IAPIConnector>();
25-
_client = new SpellingService(_apiConnector.Object);
26+
_client = new SpellingService(_apiConnector.Object, null);
2627
}
2728

2829
[Theory]
2930
[MemberData(nameof(SpellingDataForTest))]
3031
public async Task GetAsync_Success(string text, Language language, Locale locale, Stream json, SpellingData expectedResult)
3132
{
3233
// Arrange
33-
var response = new HttpResponse() { Content = json };
34+
var response = new HttpResponse("text/html", json, HttpStatusCode.OK);
3435
_apiConnector
3536
.Setup(c => c.PostAsync(It.IsAny<Uri>(), It.IsAny<SpellingRequest>(), It.IsAny<CancellationToken>()))
3637
.ReturnsAsync(response);

ReversoAPI.Web.Tests/Clients/TranslationClientTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using FluentAssertions;
44
using System;
55
using System.IO;
6+
using System.Net;
67
using System.Threading;
78
using System.Threading.Tasks;
89
using System.Collections.Generic;
@@ -22,15 +23,15 @@ public class TranslationClientTests
2223
public TranslationClientTests()
2324
{
2425
_apiConnector = new Mock<IAPIConnector>();
25-
_client = new TranslationService(_apiConnector.Object);
26+
_client = new TranslationService(_apiConnector.Object, null);
2627
}
2728

2829
[Theory]
2930
[MemberData(nameof(SpellingDataForTest))]
3031
public async Task GetFromOneWordAsync_Success(string text, Language source, Language target, Stream json, TranslationData expectedResult)
3132
{
3233
// Arrange
33-
var response = new HttpResponse() { Content = json };
34+
var response = new HttpResponse("text/html", json, HttpStatusCode.OK);
3435
_apiConnector
3536
.Setup(c => c.PostAsync(It.IsAny<Uri>(), It.IsAny<TranslationRequest>(), It.IsAny<CancellationToken>()))
3637
.ReturnsAsync(response);

ReversoAPI.Web.Tests/Parsers/ConjugationResponseParserTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ConjugationResponseParserTest
1414
public void Invoke_Test(ConjugationData expectedResult, Stream html)
1515
{
1616
// Arrange
17-
var parser = new ConjugationParserService();
17+
var parser = new ConjugationParseService(null);
1818

1919
// Act
2020
var result = parser.Invoke(html);

ReversoAPI.Web.Tests/Parsers/ContextResponseParserTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ContextResponseParserTest
1414
public void Invoke_Test(ContextData expectedResult, Stream html)
1515
{
1616
// Arrange
17-
var parser = new ContextParserService();
17+
var parser = new ContextParseService(null);
1818

1919
// Act
2020
var result = parser.Invoke(html);

ReversoAPI.Web.Tests/Parsers/SynonymsResponseParserTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SynonymsResponseParserTest
1414
public void Invoke_Test(SynonymsData expectedResult, Stream html)
1515
{
1616
// Arrange
17-
var parser = new SynonymsParserService();
17+
var parser = new SynonymsParseService(null);
1818

1919
// Act
2020
var result = parser.Invoke(html);

ReversoAPI.Web/Shared/Infrastructure/Http/APIConnector.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,11 @@ public async Task<HttpResponse> PostAsync(Uri uri, object payload, CancellationT
4949
if (uri == null) throw new ArgumentNullException(nameof(uri));
5050
if (payload == null) throw new ArgumentNullException(nameof(payload));
5151

52-
var json = JsonConvert.SerializeObject(payload);
53-
var data = new StringContent(json, Encoding.UTF8, "application/json");
54-
5552
var response = await Policy
5653
.Handle<HttpRequestException>()
5754
.OrResult<HttpResponse>(r => _httpStatusCodesWorthRetrying.Contains(r.StatusCode))
5855
.WaitAndRetryAsync(RetryAttemptCount, attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)))
59-
.ExecuteAsync(() => _httpClient.PostAsync(uri, data, cancellationToken))
56+
.ExecuteAsync(() => _httpClient.PostAsync(uri, payload, cancellationToken))
6057
.ConfigureAwait(false);
6158

6259
return response;

0 commit comments

Comments
 (0)