completes get images by album implementation and adds verify to makes testing a bit easier

This commit is contained in:
Philipp Häfelfinger 2022-10-21 21:20:21 +02:00
parent ff53bbec16
commit 95facd4019
8 changed files with 354 additions and 23 deletions

View File

@ -0,0 +1,16 @@
[
{
id: 1,
name: UnitTestMain
},
{
id: 3,
name: UnitTestSub2,
id_uppercat: 1
},
{
id: 2,
name: UnitTestSub1,
id_uppercat: 1
}
]

View File

@ -130,21 +130,6 @@ public class AlbumApiTests : ApiTestsBase
CorrectMethodShouldGetCalled("pwg.categories.getList"); CorrectMethodShouldGetCalled("pwg.categories.getList");
response.Should().HaveCount(3); await Verify(response);
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);
});
} }
} }

View File

@ -0,0 +1,272 @@
{
paging: {
per_page: 100,
count: 4
},
images: [
{
id: 4,
width: 4452,
height: 2968,
hit: 2,
file: 2017-08-30-20-38-c7d_7682.jpg,
name: 2017-08-30-20-38-c7d 7682,
date_creation: DateTime_1,
date_available: DateTime_2,
page_url: http://localhost:8080/picture.php?/4,
element_url: http://localhost:8080/upload/2022/10/20/20221020220132-2c6d9eab.jpg,
derivatives: {
2small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220132-2c6d9eab-2s.jpg,
width: 240,
height: 160
},
large: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220132-2c6d9eab-la.jpg,
width: 1008,
height: 672
},
medium: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220132-2c6d9eab-me.jpg,
width: 792,
height: 528
},
small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220132-2c6d9eab-sm.jpg,
width: 576,
height: 384
},
square: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220132-2c6d9eab-sq.jpg,
width: 120,
height: 120
},
thumb: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220132-2c6d9eab-th.jpg,
width: 144,
height: 96
},
xlarge: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220132-2c6d9eab-xl.jpg,
width: 1224,
height: 816
},
xsmall: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220132-2c6d9eab-xs.jpg,
width: 432,
height: 288
},
xxlarge: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220132-2c6d9eab-xx.jpg,
width: 1656,
height: 1104
}
},
categories: [
{
id: 7,
url: http://localhost:8080/index.php?/category/7,
page_url: http://localhost:8080/picture.php?/4/category/7
}
]
},
{
id: 3,
width: 3961,
height: 2641,
hit: 4,
file: 2017-05-24-20-35-c7d_6283.jpg,
name: 2017-05-24-20-35-c7d 6283,
date_creation: DateTime_3,
date_available: DateTime_4,
page_url: http://localhost:8080/picture.php?/3,
element_url: http://localhost:8080/upload/2022/10/20/20221020220131-9a567bdb.jpg,
derivatives: {
2small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-2s.jpg,
width: 240,
height: 160
},
large: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-la.jpg,
width: 1008,
height: 672
},
medium: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-me.jpg,
width: 792,
height: 528
},
small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-sm.jpg,
width: 576,
height: 384
},
square: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-sq.jpg,
width: 120,
height: 120
},
thumb: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-th.jpg,
width: 144,
height: 96
},
xlarge: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-xl.jpg,
width: 1224,
height: 816
},
xsmall: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xs.jpg,
width: 432,
height: 288
},
xxlarge: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xx.jpg,
width: 1656,
height: 1104
}
},
categories: [
{
id: 7,
url: http://localhost:8080/index.php?/category/7,
page_url: http://localhost:8080/picture.php?/3/category/7
}
]
},
{
id: 2,
width: 3107,
height: 4660,
hit: 4,
file: 2017-04-21-11-53-C7D_4469.jpg,
name: 2017-04-21-11-53-C7D 4469,
date_creation: DateTime_5,
date_available: DateTime_6,
page_url: http://localhost:8080/picture.php?/2,
element_url: http://localhost:8080/upload/2022/10/20/20221020220130-8e50dbd3.jpg,
derivatives: {
2small: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220130-8e50dbd3-2s.jpg,
width: 160,
height: 240
},
large: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220130-8e50dbd3-la.jpg,
width: 504,
height: 756
},
medium: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220130-8e50dbd3-me.jpg,
width: 396,
height: 594
},
small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220130-8e50dbd3-sm.jpg,
width: 288,
height: 432
},
square: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220130-8e50dbd3-sq.jpg,
width: 120,
height: 120
},
thumb: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220130-8e50dbd3-th.jpg,
width: 96,
height: 144
},
xlarge: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220130-8e50dbd3-xl.jpg,
width: 612,
height: 918
},
xsmall: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220130-8e50dbd3-xs.jpg,
width: 216,
height: 324
},
xxlarge: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220130-8e50dbd3-xx.jpg,
width: 828,
height: 1242
}
},
categories: [
{
id: 7,
url: http://localhost:8080/index.php?/category/7,
page_url: http://localhost:8080/picture.php?/2/category/7
}
]
},
{
id: 1,
width: 5184,
height: 3456,
hit: 2,
file: 2017-01-05-11-25-c7d_2770.jpg,
name: 2017-01-05-11-25-c7d 2770,
date_creation: DateTime_7,
date_available: DateTime_8,
page_url: http://localhost:8080/picture.php?/1,
element_url: http://localhost:8080/upload/2022/10/20/20221020220129-6b8c2a7d.jpg,
derivatives: {
2small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220129-6b8c2a7d-2s.jpg,
width: 240,
height: 160
},
large: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220129-6b8c2a7d-la.jpg,
width: 1008,
height: 672
},
medium: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220129-6b8c2a7d-me.jpg,
width: 792,
height: 528
},
small: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220129-6b8c2a7d-sm.jpg,
width: 576,
height: 384
},
square: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220129-6b8c2a7d-sq.jpg,
width: 120,
height: 120
},
thumb: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220129-6b8c2a7d-th.jpg,
width: 144,
height: 96
},
xlarge: {
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220129-6b8c2a7d-xl.jpg,
width: 1224,
height: 816
},
xsmall: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220129-6b8c2a7d-xs.jpg,
width: 432,
height: 288
},
xxlarge: {
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220129-6b8c2a7d-xx.jpg,
width: 1656,
height: 1104
}
},
categories: [
{
id: 7,
url: http://localhost:8080/index.php?/category/7,
page_url: http://localhost:8080/picture.php?/1/category/7
}
]
}
]
}

View File

@ -27,10 +27,6 @@ public class ImageApiTests : ApiTestsBase
CorrectParamShouldGetSent("per_page", "100"); CorrectParamShouldGetSent("per_page", "100");
CorrectParamShouldGetSent("page", "0"); CorrectParamShouldGetSent("page", "0");
result.Images.Should().HaveCount(4); await Verify(result);
result.Images.First().Id.Should().Be(4);
result.Paging.Page.Should().Be(0);
result.Paging.PageSize.Should().Be(100);
result.Paging.TotalItems.Should().Be(4);
} }
} }

View File

@ -15,6 +15,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" /> <PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" /> <PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Verify.NUnit" Version="17.10.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -25,6 +26,12 @@
<None Update="ImageApi.getImages.json"> <None Update="ImageApi.getImages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="ImageApiTests.GetImages_should_return_expected_images.verified.txt">
<DependentUpon>ImageApiTests.cs</DependentUpon>
</None>
<None Update="AlbumApiTests.GetAll_should_return_all_existing_albums.verified.txt">
<DependentUpon>AlbumApiTests.cs</DependentUpon>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -16,5 +16,30 @@ public class Image
[JsonProperty("hit")] [JsonProperty("hit")]
public int Hit { get; init; } public int Hit { get; init; }
//TODO: add additional fields [JsonProperty("file")]
public string? File { get; init; }
[JsonProperty("name")]
public string? Name { get; init; }
[JsonProperty("comment")]
public string? Comment { get; init; }
[JsonProperty("date_creation")]
public DateTime? DateCreation { get; init; }
[JsonProperty("date_available")]
public DateTime? DateAvailable { get; init; }
[JsonProperty("page_url")]
public string? PageUrl { get; init; }
[JsonProperty("element_url")]
public string? ElementUrl { get; init; }
[JsonProperty("derivatives")]
public IDictionary<string, ImageDerivative>? Derivatives { get; init; }
[JsonProperty("categories")]
public IReadOnlyCollection<ImageAlbum>? Albums { get; init; }
} }

View File

@ -0,0 +1,15 @@
using Newtonsoft.Json;
namespace Piwigo.Client.Contract;
public class ImageAlbum
{
[JsonProperty("id")]
public int Id { get; init; }
[JsonProperty("url")]
public string? Url { get; init; }
[JsonProperty("page_url")]
public string? PageUrl { get; init; }
}

View File

@ -0,0 +1,15 @@
using Newtonsoft.Json;
namespace Piwigo.Client.Contract;
public class ImageDerivative
{
[JsonProperty("url")]
public string? Url { get; init; }
[JsonProperty("width")]
public int? Width { get; init; }
[JsonProperty("height")]
public int? Height { get; init; }
}