Skip to content

Commit

Permalink
Fix Admin tests to latest version of FluentAssertions
Browse files Browse the repository at this point in the history
  • Loading branch information
skoruba committed Dec 20, 2021
1 parent 935b6e7 commit 60bf5a3
Show file tree
Hide file tree
Showing 21 changed files with 301 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task AddClient()
var client = await dbContext.Clients.Where(x => x.ClientId == clientDto.ClientId).SingleOrDefaultAsync();
var adddedClient = await clientService.GetClientAsync(client.Id);

clientDto.ShouldBeEquivalentTo(adddedClient, opts => opts.Excluding(x => x.Id)
adddedClient.Should().BeEquivalentTo(clientDto, opts => opts.Excluding(x => x.Id)
.Excluding(x => x.AccessTokenTypes)
.Excluding(x => x.ProtocolTypes)
.Excluding(x => x.RefreshTokenExpirations)
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task UpdateClient()
var client = await dbContext.Clients.Where(x => x.ClientId == clientDto.ClientId).SingleOrDefaultAsync();
var adddedClient = await clientService.GetClientAsync(client.Id);

clientDto.ShouldBeEquivalentTo(adddedClient, opts => opts.Excluding(x => x.Id)
adddedClient.Should().BeEquivalentTo(clientDto, opts => opts.Excluding(x => x.Id)
.Excluding(x => x.AccessTokenTypes)
.Excluding(x => x.ProtocolTypes)
.Excluding(x => x.RefreshTokenExpirations)
Expand Down Expand Up @@ -174,7 +174,7 @@ public async Task AddClientClaim()
var clientClaimAdded = await dbContext.ClientClaims.Where(x => x.Client.Id == clientId).SingleOrDefaultAsync();
var adddedClientClaim = await clientService.GetClientClaimAsync(clientClaimAdded.Id);

clientClaim.ShouldBeEquivalentTo(adddedClientClaim, opts => opts.Excluding(x => x.ClientClaimId)
adddedClientClaim.Should().BeEquivalentTo(clientClaim, opts => opts.Excluding(x => x.ClientClaimId)
.Excluding(x => x.ClientClaims)
.Excluding(x => x.ClientName));
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public async Task GetClientClaim()

var viewModel = Assert.IsType<ClientClaimsDto>(viewResult.ViewData.Model);
viewModel.ClientClaims.Count.Should().Be(1);
viewModel.ClientClaims[0].ShouldBeEquivalentTo(clientClaimAdded);
clientClaimAdded.Should().BeEquivalentTo(viewModel.ClientClaims[0]);
}

[Fact]
Expand Down Expand Up @@ -261,7 +261,7 @@ public async Task AddClientSecret()

clientSecret.Value.Should().Be(clientSecretAdded.Value);

clientSecret.ShouldBeEquivalentTo(newClientSecret, opts => opts.Excluding(x => x.ClientSecretId)
newClientSecret.Should().BeEquivalentTo(clientSecret, opts => opts.Excluding(x => x.ClientSecretId)
.Excluding(x => x.ClientSecrets)
.Excluding(x => x.ClientName)
.Excluding(x => x.Value));
Expand Down Expand Up @@ -295,7 +295,7 @@ public async Task GetClientSecret()

var viewModel = Assert.IsType<ClientSecretsDto>(viewResult.ViewData.Model);
viewModel.ClientSecrets.Count.Should().Be(1);
viewModel.ClientSecrets[0].ShouldBeEquivalentTo(clientSecretAdded, opts => opts.Excluding(x => x.Value));
clientSecretAdded.Should().BeEquivalentTo(viewModel.ClientSecrets[0], opts => opts.Excluding(x => x.Value));
}

[Fact]
Expand Down Expand Up @@ -349,7 +349,7 @@ public async Task AddClientProperty()
var clientPropertyAdded = await dbContext.ClientProperties.Where(x => x.Client.Id == clientId).SingleOrDefaultAsync();
var newClientProperty = await clientService.GetClientPropertyAsync(clientPropertyAdded.Id);

clientProperty.ShouldBeEquivalentTo(newClientProperty, opts => opts.Excluding(x => x.ClientPropertyId)
newClientProperty.Should().BeEquivalentTo(clientProperty, opts => opts.Excluding(x => x.ClientPropertyId)
.Excluding(x => x.ClientProperties)
.Excluding(x => x.ClientName));
}
Expand Down Expand Up @@ -380,7 +380,7 @@ public async Task GetClientProperty()

var viewModel = Assert.IsType<ClientPropertiesDto>(viewResult.ViewData.Model);
viewModel.ClientProperties.Count.Should().Be(1);
viewModel.ClientProperties[0].ShouldBeEquivalentTo(clientPropertyAdded);
clientPropertyAdded.Should().BeEquivalentTo(viewModel.ClientProperties[0]);
}

[Fact]
Expand Down Expand Up @@ -454,7 +454,7 @@ public async Task AddIdentityResource()
var identityResource = await dbContext.IdentityResources.Where(x => x.Name == identityResourceDto.Name).SingleOrDefaultAsync();
var addedIdentityResource = await identityResourceService.GetIdentityResourceAsync(identityResource.Id);

identityResourceDto.ShouldBeEquivalentTo(addedIdentityResource, opts => opts.Excluding(x => x.Id));
addedIdentityResource.Should().BeEquivalentTo(identityResourceDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -506,7 +506,7 @@ public async Task AddApiResource()
var apiResource = await dbContext.ApiResources.Where(x => x.Name == apiResourceDto.Name).SingleOrDefaultAsync();
var addedApiResource = await apiResourceService.GetApiResourceAsync(apiResource.Id);

apiResourceDto.ShouldBeEquivalentTo(addedApiResource, opts => opts.Excluding(x => x.Id));
addedApiResource.Should().BeEquivalentTo(apiResourceDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -557,7 +557,7 @@ public async Task AddApiScope()
var apiScope = await dbContext.ApiScopes.Where(x => x.Name == apiScopeDto.Name).SingleOrDefaultAsync();
var addedApiScope = await apiScopeService.GetApiScopeAsync(apiScope.Id);

apiScopeDto.ShouldBeEquivalentTo(addedApiScope, opts => opts.Excluding(x => x.Id));
addedApiScope.Should().BeEquivalentTo(apiScopeDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -619,7 +619,7 @@ public async Task UpdateApiScope()
var apiScope = await dbContext.ApiScopes.Where(x => x.Id == apiScopeAdded.Id).SingleOrDefaultAsync();
var addedApiScope = await apiScopeService.GetApiScopeAsync(apiScope.Id);

updatedApiScopeDto.ShouldBeEquivalentTo(addedApiScope, opts => opts.Excluding(x => x.Id));
addedApiScope.Should().BeEquivalentTo(updatedApiScopeDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -710,7 +710,7 @@ public async Task AddApiSecret()

apiSecretsDto.Value.Should().Be(apiSecret.Value);

apiSecretsDto.ShouldBeEquivalentTo(addedApiScope, opts => opts.Excluding(x => x.ApiResourceId).Excluding(x => x.ApiResourceName).Excluding(x => x.ApiSecretId).Excluding(x => x.Value));
addedApiScope.Should().BeEquivalentTo(apiSecretsDto, opts => opts.Excluding(x => x.ApiResourceId).Excluding(x => x.ApiResourceName).Excluding(x => x.ApiSecretId).Excluding(x => x.Value));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public async Task AddUser()

var addedUser = await identityService.GetUserAsync(userDto.Id);

userDto.ShouldBeEquivalentTo(addedUser, opts => opts.Excluding(x => x.Id));
addedUser.Should().BeEquivalentTo(userDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -149,7 +149,7 @@ public async Task UpdateUser()

var updatedUser = await identityService.GetUserAsync(updatedUserDto.Id.ToString());

updatedUserDto.ShouldBeEquivalentTo(updatedUser, opts => opts.Excluding(x => x.Id));
updatedUser.Should().BeEquivalentTo(updatedUserDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -182,7 +182,7 @@ public async Task GetUser()
userDto.Id = userId;
var addedUser = await identityService.GetUserAsync(userDto.Id.ToString());

viewModel.ShouldBeEquivalentTo(addedUser);
addedUser.Should().BeEquivalentTo(viewModel);
}

[Fact]
Expand All @@ -207,7 +207,7 @@ public async Task AddRole()

var addedRole = await identityService.GetRoleAsync(roleDto.Id.ToString());

roleDto.ShouldBeEquivalentTo(addedRole, opts => opts.Excluding(x => x.Id));
addedRole.Should().BeEquivalentTo(roleDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -235,7 +235,7 @@ public async Task GetRole()
roleDto.Id = roleId;
var addedRole = await identityService.GetRoleAsync(roleDto.Id.ToString());

viewModel.ShouldBeEquivalentTo(addedRole);
addedRole.Should().BeEquivalentTo(viewModel);
}

[Fact]
Expand Down Expand Up @@ -290,7 +290,7 @@ public async Task UpdateRole()

var updatedRole = await identityService.GetRoleAsync(updatedRoleDto.Id.ToString());

updatedRoleDto.ShouldBeEquivalentTo(updatedRole, opts => opts.Excluding(x => x.Id));
updatedRole.Should().BeEquivalentTo(updatedRoleDto, opts => opts.Excluding(x => x.Id));
}

[Fact]
Expand Down Expand Up @@ -320,7 +320,7 @@ public async Task AddUserClaim()

var addedUserClaim = await identityService.GetUserClaimAsync(user.Id.ToString(), userClaim.Id);

userClaimsDto.ShouldBeEquivalentTo(addedUserClaim, opts => opts.Excluding(x => x.ClaimId));
addedUserClaim.Should().BeEquivalentTo(userClaimsDto, opts => opts.Excluding(x => x.ClaimId));
}

[Fact]
Expand Down Expand Up @@ -354,7 +354,7 @@ public async Task AddUserRole()

var userRole = await dbContext.UserRoles.Where(x => x.RoleId == roleDto.Id && x.UserId == userDto.Id).SingleOrDefaultAsync();

userRoleDto.ShouldBeEquivalentTo(userRole, opts => opts.Excluding(x => x.Roles)
userRole.Should().BeEquivalentTo(userRoleDto, opts => opts.Excluding(x => x.Roles)
.Excluding(x => x.RolesList)
.Excluding(x => x.PageSize)
.Excluding(x => x.TotalCount)
Expand Down Expand Up @@ -457,7 +457,7 @@ public async Task AddRoleClaim()

var addedRoleClaim = await identityService.GetRoleClaimAsync(role.Id.ToString(), roleClaim.Id);

roleClaimsDto.ShouldBeEquivalentTo(addedRoleClaim, opts => opts.Excluding(x => x.ClaimId)
addedRoleClaim.Should().BeEquivalentTo(roleClaimsDto, opts => opts.Excluding(x => x.ClaimId)
.Excluding(x => x.RoleName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void CanMapApiResourceToModel()
//Assert
apiResourceDto.Should().NotBeNull();

apiResource.ShouldBeEquivalentTo(apiResourceDto, options =>
apiResourceDto.Should().BeEquivalentTo(apiResource, options =>
options.Excluding(o => o.Secrets)
.Excluding(o => o.Scopes)
.Excluding(o => o.Properties)
Expand All @@ -36,10 +36,10 @@ public void CanMapApiResourceToModel()
.Excluding(o => o.UserClaims));

//Assert collection
apiResource.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(apiResourceDto.UserClaims);
apiResourceDto.UserClaims.Should().BeEquivalentTo(apiResource.UserClaims.Select(x => x.Type));

var allowedAlgList = AllowedSigningAlgorithmsConverter.Converter.Convert(apiResource.AllowedAccessTokenSigningAlgorithms, null);
allowedAlgList.ShouldBeEquivalentTo(apiResourceDto.AllowedAccessTokenSigningAlgorithms);
apiResourceDto.AllowedAccessTokenSigningAlgorithms.Should().BeEquivalentTo(allowedAlgList);
}

[Fact]
Expand All @@ -53,7 +53,7 @@ public void CanMapApiResourceDtoToEntity()

apiResource.Should().NotBeNull();

apiResource.ShouldBeEquivalentTo(apiResourceDto, options =>
apiResourceDto.Should().BeEquivalentTo(apiResource, options =>
options.Excluding(o => o.Secrets)
.Excluding(o => o.Scopes)
.Excluding(o => o.Properties)
Expand All @@ -65,9 +65,9 @@ public void CanMapApiResourceDtoToEntity()
.Excluding(o => o.UserClaims));

//Assert collection
apiResource.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(apiResourceDto.UserClaims);
apiResourceDto.UserClaims.Should().BeEquivalentTo(apiResource.UserClaims.Select(x => x.Type));
var allowedAlgList = AllowedSigningAlgorithmsConverter.Converter.Convert(apiResource.AllowedAccessTokenSigningAlgorithms, null);
allowedAlgList.ShouldBeEquivalentTo(apiResourceDto.AllowedAccessTokenSigningAlgorithms);
apiResourceDto.AllowedAccessTokenSigningAlgorithms.Should().BeEquivalentTo(allowedAlgList);
}

[Fact]
Expand All @@ -81,13 +81,13 @@ public void CanMapApiScopeToModel()

apiScope.Should().NotBeNull();

apiScope.ShouldBeEquivalentTo(apiScopeDto, options =>
apiScopeDto.Should().BeEquivalentTo(apiScope, options =>
options.Excluding(o => o.UserClaims)
.Excluding(o => o.ApiScopeProperties)
.Excluding(o => o.UserClaimsItems));

//Assert collection
apiScopeDto.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(apiScope.UserClaims);
apiScope.UserClaims.Should().BeEquivalentTo(apiScopeDto.UserClaims.Select(x => x.Type));
apiScope.Id.Should().Be(apiScopeDto.Id);
}

Expand All @@ -102,13 +102,13 @@ public void CanMapApiScopeDtoToEntity()

apiScope.Should().NotBeNull();

apiScope.ShouldBeEquivalentTo(apiScopeDto, options =>
apiScopeDto.Should().BeEquivalentTo(apiScope, options =>
options.Excluding(o => o.UserClaims)
.Excluding(o => o.Properties)
.Excluding(o => o.Id));

//Assert collection
apiScope.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(apiScopeDto.UserClaims);
apiScopeDto.UserClaims.Should().BeEquivalentTo(apiScope.UserClaims.Select(x => x.Type));
apiScope.Id.Should().Be(apiScopeDto.Id);
}

Expand All @@ -124,7 +124,7 @@ public void CanMapApiSecretToModel()
//Assert
apiSecretsDto.Should().NotBeNull();

apiSecret.ShouldBeEquivalentTo(apiSecretsDto, options =>
apiSecretsDto.Should().BeEquivalentTo(apiSecret, options =>
options.Excluding(o => o.ApiResource)
.Excluding(o => o.Created)
.Excluding(o => o.Id));
Expand All @@ -143,7 +143,7 @@ public void CanMapApiSecretDtoToEntity()

apiSecret.Should().NotBeNull();

apiSecret.ShouldBeEquivalentTo(apiSecretsDto, options =>
apiSecretsDto.Should().BeEquivalentTo(apiSecret, options =>
options.Excluding(o => o.ApiResource)
.Excluding(o => o.Created)
.Excluding(o => o.Id));
Expand Down
Loading

0 comments on commit 60bf5a3

Please sign in to comment.