Skip to content

Commit 9536a72

Browse files
Lanz86jasontaylordev
authored andcommitted
fix Testing.cs
1 parent 6bbbd27 commit 9536a72

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/Web/Web.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<!--#endif-->
6565

6666
<!-- Auto-generated Open API specification and Angular TypeScript clients -->
67-
<!--<PropertyGroup>
67+
<PropertyGroup>
6868
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
6969
</PropertyGroup>
7070

@@ -76,7 +76,7 @@
7676

7777
<Message Text="$(NSwagOutput)" Condition="'$(NSwagExitCode)' == '0'" Importance="low" />
7878
<Error Text="$(NSwagOutput)" Condition="'$(NSwagExitCode)' != '0'" />
79-
</Target>-->
79+
</Target>
8080

8181
<!--#if (!UseApiOnly)-->
8282
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">

tests/Application.FunctionalTests/CustomWebApplicationFactory.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
3434
{
3535
services
3636
.RemoveAll<IUser>()
37-
.AddTransient(provider => Mock.Of<IUser>(s => s.Id == GetUserId()));
38-
#if (!UseAspire || UseSqlite)
37+
.AddTransient(provider =>
38+
{
39+
var mock = new Mock<IUser>();
40+
mock.SetupGet(x => x.Roles).Returns(GetRoles());
41+
mock.SetupGet(x => x.Id).Returns(GetUserId());
42+
return mock.Object;
43+
});
3944
services
4045
.RemoveAll<DbContextOptions<ApplicationDbContext>>()
4146
.AddDbContext<ApplicationDbContext>((sp, options) =>

tests/Application.FunctionalTests/Testing.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class Testing
1515
private static CustomWebApplicationFactory _factory = null!;
1616
private static IServiceScopeFactory _scopeFactory = null!;
1717
private static string? _userId;
18-
18+
private static List<string>? _roles;
1919
[OneTimeSetUp]
2020
public async Task RunBeforeAnyTests()
2121
{
@@ -48,6 +48,11 @@ public static async Task SendAsync(IBaseRequest request)
4848
{
4949
return _userId;
5050
}
51+
52+
public static List<string>? GetRoles()
53+
{
54+
return _roles;
55+
}
5156

5257
public static async Task<string> RunAsDefaultUserAsync()
5358
{
@@ -84,7 +89,7 @@ public static async Task<string> RunAsUserAsync(string userName, string password
8489
if (result.Succeeded)
8590
{
8691
_userId = user.Id;
87-
92+
_roles = roles.ToList();
8893
return _userId;
8994
}
9095

0 commit comments

Comments
 (0)