2022-10-15 00:07:59 +02:00
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
using Piwigo.Client.Contract;
|
|
|
|
|
|
|
|
namespace Piwigo.Client.Tests;
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
public class CategoryApiTests : ApiTestsBase
|
|
|
|
{
|
|
|
|
private CategoryApi _categoryApi = null!;
|
|
|
|
|
|
|
|
protected override void OnSetUp()
|
|
|
|
{
|
|
|
|
base.OnSetUp();
|
|
|
|
_categoryApi = new CategoryApi(Context, new NullLogger<CategoryApi>());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public async Task GetAllCategories_should_return_all_existing_categories()
|
|
|
|
{
|
|
|
|
await LoginAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var serverResponse = new PiwigoResponse<PiwigoCategoryList>
|
|
|
|
{
|
|
|
|
Result = new PiwigoCategoryList
|
|
|
|
{
|
|
|
|
Categories = new List<PiwigoCategory>
|
|
|
|
{
|
|
|
|
new() { Id = 1, Name = "UnitTestMain" },
|
|
|
|
new() { Id = 3, Name = "UnitTestSub2", IdUpperCat = 1 },
|
|
|
|
new() { Id = 2, Name = "UnitTestSub1", IdUpperCat = 1 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
SetJsonResult(serverResponse);
|
2022-10-16 22:58:38 +02:00
|
|
|
var response = await _categoryApi.GetAllAsync();
|
2022-10-15 00:07:59 +02:00
|
|
|
|
|
|
|
response.Should().HaveCount(3);
|
|
|
|
response.Should().SatisfyRespectively(c =>
|
|
|
|
{
|
|
|
|
c.Id.Should().Be(1);
|
|
|
|
c.Name.Should().Be("UnitTestMain");
|
|
|
|
}, c =>
|
|
|
|
{
|
|
|
|
c.Id.Should().Be(3);
|
|
|
|
c.Name.Should().Be("UnitTestSub2");
|
|
|
|
c.IdUpperCat.Should().Be(1);
|
|
|
|
}, c =>
|
|
|
|
{
|
|
|
|
c.Id.Should().Be(2);
|
|
|
|
c.Name.Should().Be("UnitTestSub1");
|
|
|
|
c.IdUpperCat.Should().Be(1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|