新建工程
实现,拿登录接口举例
using System;
using System.Threading.Tasks;
using UIH.RT.Cloud.Identity.Controllers;
using UIH.RT.Cloud.Identity.Controllers.Dto;
using UIH.RT.Cloud.Identity.Models;
using UIH.RT.Cloud.Identity.Models.AccountViewModels;
using UIH.RT.Cloud.Identity.Services;
using Xunit;
using Microsoft.AspNetCore.Mvc;
namespace UIH.RT.Cloud.Identity.Tests
{
public class AccountControllerTest
{
private AccountController _myTest;
private readonly ILoginService<ApplicationUser> _loginService;
public AccountControllerTest(ILoginService<ApplicationUser> loginService, AccountController myTest)
{
_loginService = loginService;
_myTest = myTest;
}
[Fact]
public async Task LogInTest()
{
LoginViewModel model = new LoginViewModel();
model.UserName = "admin";
model.Password = "111111";
model.ReturnUrl = "";
var ret = await _myTest.Login(model);
if (ret == _myTest.Redirect(model.ReturnUrl))
{
Assert.True(true);
}
else
{
Assert.True(false);
}
}
}
}