-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Tests/VTEX.SDK.Tests/Products/ProductsApiTests.cs.
- Loading branch information
1 parent
2204049
commit 210232d
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Moq; | ||
using Moq.Protected; | ||
using System.Threading; | ||
using System.Net; | ||
|
||
namespace VTEX.SDK.Tests.Products | ||
{ | ||
public class ProductsApiTests | ||
{ | ||
[Fact] | ||
public async Task GetProductAsync_ShouldReturnProductData() | ||
{ | ||
var handlerMock = new Mock<HttpMessageHandler>(); | ||
handlerMock.Protected() | ||
.Setup<Task<HttpResponseMessage>>( | ||
"SendAsync", | ||
ItExpr.IsAny<HttpRequestMessage>(), | ||
ItExpr.IsAny<CancellationToken>() | ||
) | ||
.ReturnsAsync(new HttpResponseMessage | ||
{ | ||
StatusCode = HttpStatusCode.OK, | ||
Content = new StringContent("{ 'id': '123', 'name': 'Test Product' }"), | ||
}); | ||
|
||
var httpClient = new HttpClient(handlerMock.Object); | ||
var api = new ProductsApi(httpClient); | ||
var result = await api.GetProductAsync("123"); | ||
Assert.Contains("Test Product", result); | ||
} | ||
} | ||
} |