adds check for tests to validate parameters and method sent to piwigo
This commit is contained in:
parent
f3ff670ef0
commit
f862a9794f
@ -1,4 +1,5 @@
|
|||||||
using Flurl.Http.Configuration;
|
using Flurl.Http.Configuration;
|
||||||
|
using Flurl.Http.Content;
|
||||||
using Flurl.Http.Testing;
|
using Flurl.Http.Testing;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -37,10 +38,9 @@ public class ApiTestsBase
|
|||||||
HttpTest?.Dispose();
|
HttpTest?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void SetOkResult()
|
internal void SetOkResult()
|
||||||
{
|
{
|
||||||
SetJsonResult(@"{stat: ""ok""}");
|
SetJsonResult(@"{stat: ""ok"", result: null}");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetJsonResult(string json)
|
internal void SetJsonResult(string json)
|
||||||
@ -48,6 +48,18 @@ public class ApiTestsBase
|
|||||||
HttpTest?.RespondWith(json);
|
HttpTest?.RespondWith(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CorrectMethodShouldGetCalled(string methodName)
|
||||||
|
{
|
||||||
|
CorrectParamShouldGetSent("method", methodName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CorrectParamShouldGetSent(string paramName, string methodName)
|
||||||
|
{
|
||||||
|
HttpTest?.ShouldHaveMadeACall().With(c =>
|
||||||
|
c.HttpRequestMessage.Content.As<CapturedMultipartContent>().Parts.OfType<CapturedStringContent>().Select(p => new { p.Headers.ContentDisposition?.Name, p.Content })
|
||||||
|
.Where(s => s.Name?.Equals(paramName) ?? false).Any(s => s.Content.Equals(methodName, StringComparison.OrdinalIgnoreCase)));
|
||||||
|
}
|
||||||
|
|
||||||
internal void SetJsonResult<T>(PiwigoResponse<T> serverResponse)
|
internal void SetJsonResult<T>(PiwigoResponse<T> serverResponse)
|
||||||
{
|
{
|
||||||
var settings = new JsonSerializerSettings
|
var settings = new JsonSerializerSettings
|
||||||
|
Loading…
Reference in New Issue
Block a user