Skip to content

Commit

Permalink
Update Tests/VTEX.SDK.Tests/Products/ProductsApiTests.cs.
Browse files Browse the repository at this point in the history
  • Loading branch information
gitauto-ai[bot] authored Sep 23, 2024
1 parent 2204049 commit 210232d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Tests/VTEX.SDK.Tests/Products/ProductsApiTests.cs
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);
}
}
}

0 comments on commit 210232d

Please sign in to comment.