mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-15 14:59:33 +00:00
0fe9f9957c
* Setup OAuth2 support * Setup tests project * Setup OAuth2 unit tests in CI pipeline * Setup authorizeattribute tests * Test * Setup tests for AuthorizeAttribute * Setup OAuth2 support Unit Tests coverage * Add OAuth2 project to release
34 lines
1003 B
C#
34 lines
1003 B
C#
using System;
|
|
using System.Net.Http;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MTSC.OAuth2.Tests.Models
|
|
{
|
|
public sealed class HttpClientMock : HttpClient
|
|
{
|
|
public Func<HttpRequestMessage, Task<HttpResponseMessage>> SendingAsync { get;set; }
|
|
public Func<HttpRequestMessage, HttpResponseMessage> Sending { get; set; }
|
|
|
|
public override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
{
|
|
if (this.SendingAsync is not null)
|
|
{
|
|
return await this.SendingAsync(request);
|
|
}
|
|
|
|
return new HttpResponseMessage();
|
|
}
|
|
|
|
public override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
{
|
|
if (this.Sending is not null)
|
|
{
|
|
return this.Sending(request);
|
|
}
|
|
|
|
return new HttpResponseMessage();
|
|
}
|
|
}
|
|
}
|