mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Refactors the test fixtures and their consumers to compose other fixtures instead of instantiating models inline
This commit is contained in:
1 parent
0abda472c6
commit
3aadd6de84
157 files changed
+1312
-597
No files matched your search
+20
-7
@@ -23,21 +23,34 @@ internal class OpenLibrarySettingsDtoFixture
|
||||
/// <param name="searchResultLimit">Optional. The maximum number of search results.</param>
|
||||
/// <param name="workEditionLimit">Optional. The maximum number of editions fetched per work.</param>
|
||||
/// <param name="minimumRequestInterval">Optional. The minimum interval between consecutive requests.</param>
|
||||
/// <param name="includeUserAgent">Whether the user agent should be included, or left at its default value.</param>
|
||||
/// <param name="includeSearchResultLimit">Whether the search result limit should be included, or left at its default value.</param>
|
||||
/// <param name="includeWorkEditionLimit">Whether the work edition limit should be included, or left at its default value.</param>
|
||||
/// <param name="includeMinimumRequestInterval">Whether the minimum request interval should be included, or left at its default value.</param>
|
||||
/// <returns>The created <see cref="OpenLibrarySettingsDto"/>.</returns>
|
||||
public OpenLibrarySettingsDto Create(
|
||||
string? userAgent = null,
|
||||
string? contactEmail = null,
|
||||
int? searchResultLimit = null,
|
||||
int? workEditionLimit = null,
|
||||
TimeSpan? minimumRequestInterval = null)
|
||||
TimeSpan? minimumRequestInterval = null,
|
||||
bool includeUserAgent = true,
|
||||
bool includeSearchResultLimit = true,
|
||||
bool includeWorkEditionLimit = true,
|
||||
bool includeMinimumRequestInterval = true)
|
||||
{
|
||||
return new OpenLibrarySettingsDto
|
||||
OpenLibrarySettingsDto settings = new()
|
||||
{
|
||||
UserAgent = userAgent ?? _faker.Internet.UserAgent(),
|
||||
ContactEmail = contactEmail,
|
||||
SearchResultLimit = searchResultLimit ?? _faker.Random.Number(1, 50),
|
||||
WorkEditionLimit = workEditionLimit ?? _faker.Random.Number(1, 200),
|
||||
MinimumRequestInterval = minimumRequestInterval ?? TimeSpan.FromMilliseconds(_faker.Random.Number(100, 2000))
|
||||
ContactEmail = contactEmail
|
||||
};
|
||||
if (includeUserAgent)
|
||||
settings.UserAgent = userAgent ?? _faker.Internet.UserAgent();
|
||||
if (includeSearchResultLimit)
|
||||
settings.SearchResultLimit = searchResultLimit ?? _faker.Random.Number(1, 50);
|
||||
if (includeWorkEditionLimit)
|
||||
settings.WorkEditionLimit = workEditionLimit ?? _faker.Random.Number(1, 200);
|
||||
if (includeMinimumRequestInterval)
|
||||
settings.MinimumRequestInterval = minimumRequestInterval ?? TimeSpan.FromMilliseconds(_faker.Random.Number(100, 2000));
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user