mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 18:47:55 +08:00
转移.net core 3.1,为.NET 5做准备
This commit is contained in:
48
OpenAuth.App/Test/TestFlow.cs
Normal file
48
OpenAuth.App/Test/TestFlow.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Net.Http;
|
||||
using Infrastructure.Cache;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.SSO;
|
||||
|
||||
namespace OpenAuth.App.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestFlow :TestBase
|
||||
{
|
||||
//测试流程需要模拟登录用户
|
||||
public override ServiceCollection GetService()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
var cachemock = new Mock<ICacheContext>();
|
||||
cachemock.Setup(x => x.Get<UserAuthSession>("tokentest")).Returns(new UserAuthSession { Account = "test3" });
|
||||
services.AddScoped(x => cachemock.Object);
|
||||
|
||||
//模拟服务端httpContext
|
||||
var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
|
||||
httpContextAccessorMock.Setup(x => x.HttpContext.Request.Query[Define.TOKEN_NAME]).Returns("tokentest");
|
||||
services.AddScoped(x => httpContextAccessorMock.Object);
|
||||
|
||||
//模拟httpclientfactory
|
||||
var mockHttpFac = new Mock<IHttpClientFactory>();
|
||||
services.AddScoped(x => mockHttpFac.Object);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Verificate()
|
||||
{
|
||||
var app = _autofacServiceProvider.GetService<FlowInstanceApp>();
|
||||
app.Verification(new VerificationReq
|
||||
{
|
||||
FlowInstanceId = "76c72db4-d6c8-4734-856e-b6ffee08314a",
|
||||
VerificationFinally = "1"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user