Implemented category feature
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using LiteCharms.Features.MidrandBooks.Categories;
|
||||
using LiteCharms.Features.MidrandBooks.Tests.Common;
|
||||
|
||||
namespace LiteCharms.Features.MidrandBooks.Tests;
|
||||
|
||||
public class CategoryServiceFeatureTests(Fixture fixture) : IClassFixture<Fixture>
|
||||
{
|
||||
private readonly CategoryService categoryService = fixture.Services.GetRequiredService<CategoryService>();
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task UpdateCategoryStatusAsync_ShouldReturn_ResultWithSuccess()
|
||||
{
|
||||
var result = await categoryService.UpdateCategoryStatusAsync(3, false, false, fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task GetCategoryAsync_ShouldReturn_ResultWithCategory()
|
||||
{
|
||||
var result = await categoryService.GetCategoryAsync(3, fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.NotNull(result.Value);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task GetCategoriesAsync_ShouldReturn_All_ResultWithCategoryList()
|
||||
{
|
||||
var result = await categoryService.GetCategoriesAsync(isMain: null,fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.NotEmpty(result.Value);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task GetCategoriesAsync_ShouldReturn_MainCategory_ResultWithCategoryList()
|
||||
{
|
||||
var result = await categoryService.GetCategoriesAsync(true, fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.NotEmpty(result.Value);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task GetCategoriesAsync_ShouldReturn_SubMainCategory_ResultWithCategoryList()
|
||||
{
|
||||
var result = await categoryService.GetCategoriesAsync(false, fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.NotEmpty(result.Value);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task CreateCategoriesAsync_ShouldReturn_ResultWithSuccess()
|
||||
{
|
||||
var result = await categoryService.CreateCategoriesAsync(fixture.CancellationToken, "Test", "Test 1", "Test 2");
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
}
|
||||
|
||||
[IntegrationFact]
|
||||
public async Task CreateCategoryAsync_ShouldReturn_ResultWithCategoryId()
|
||||
{
|
||||
var result = await categoryService.CreateCategoryAsync("Test", false, fixture.CancellationToken);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.True(result.Value > 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user