fix(BaseHttpClientService): Null-Kontrolle zum Pfad hinzugefügt
This commit is contained in:
parent
4bb242a4cc
commit
dd7f1c1ea0
@ -48,10 +48,10 @@ namespace DigitalData.Core.Client
|
||||
uriBuilder.Scheme = scheme;
|
||||
if (port is int portInt)
|
||||
uriBuilder.Port = portInt;
|
||||
uriBuilder.Path = UriCombine(Path, path.Trim(URI_TRIM_CHARS));
|
||||
uriBuilder.Path = UriCombine(Path, path?.Trim(URI_TRIM_CHARS) ?? string.Empty);
|
||||
|
||||
// Add query parameters if provided
|
||||
if (queryParams?.Count > 0)
|
||||
if (queryParams?.Any() ?? false)
|
||||
{
|
||||
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
foreach (var param in queryParams)
|
||||
|
||||
@ -37,16 +37,23 @@ namespace DigitalData.Core.Tests.Client
|
||||
{
|
||||
var queryParams = new Dictionary<string, string>
|
||||
{
|
||||
{ "userId", "1" }
|
||||
{ "id", "1" }
|
||||
};
|
||||
|
||||
// Act
|
||||
var expectedUserId = (int)await _service.FetchAsync(queryParams: queryParams, sendWithCookie: false, saveCookie: false)
|
||||
.ThenAsync(res => res.Json())
|
||||
.ThenAsync(todo => todo.userId);
|
||||
|
||||
// Assert
|
||||
Assert.That(expectedUserId, Is.EqualTo(1), "The userId of the fetched JSON object should be 1.");
|
||||
var dyn_id = await _service.FetchAsync(queryParams: queryParams, sendWithCookie: false, saveCookie: false)
|
||||
.ThenAsync(res => res.JsonList())
|
||||
.ThenAsync(todo => todo.FirstOrDefault()?.userId);
|
||||
|
||||
try
|
||||
{
|
||||
Assert.That((int)dyn_id, Is.EqualTo(1), "The userId of the fetched JSON object should be 1.");
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
// Handle the case where the cast is not possible
|
||||
Assert.Fail("The id could not be cast to an integer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user