public class AddArticleToFavoritesTests
: IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;
private readonly Mock<ICurrentAccountService> _mock;
public AddArticleToFavoritesTests(WebApplicationFactory<Program> factory)
{
_factory = factory;
_mock = new Mock<ICurrentAccountService>();
}
[Fact]
public async Task AddArticleToFavoritesShouldReturnSucces()
{
_mock.Setup(x => x.GetCurrentAccountIdAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(1);
var client = _factory.CreateClient();
var requestBody = new { articleId = 1138 };
var content = new StringContent(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
var response = await client.PostAsync("/api/Articles/AddToFavorites", content);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
public class AddArticleToFavoritesTests
: IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;
private readonly Mock<ICurrentAccountService> _mock;
public AddArticleToFavoritesTests(WebApplicationFactory<Program> factory)
{
_factory = factory;
_mock = new Mock<ICurrentAccountService>();
}
[Fact]
public async Task AddArticleToFavoritesShouldReturnSucces()
{
_mock.Setup(x => x.GetCurrentAccountIdAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(1);
var client = _factory.CreateClient();
var requestBody = new { articleId = 1138 };
var content = new StringContent(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
var response = await client.PostAsync("/api/Articles/AddToFavorites", content);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}