From 60bf5a3f86f05f359b1028c88c7ff0d1536c1e82 Mon Sep 17 00:00:00 2001 From: janskoruba Date: Mon, 20 Dec 2021 12:54:17 +0100 Subject: [PATCH] Fix Admin tests to latest version of FluentAssertions --- .../ConfigurationControllerTests.cs | 26 ++-- .../Controllers/IdentityControllerTests.cs | 18 +-- .../Mappers/ApiResourceMappers.cs | 24 ++-- .../Mappers/ClientMappers.cs | 44 +++--- .../Mappers/IdentityResourceMappers.cs | 8 +- .../Mappers/KeyMappers.cs | 2 +- .../Mappers/LogMappers.cs | 4 +- .../Mappers/PersistedGrantMappers.cs | 2 +- .../Mocks/ClientDtoMock.cs | 2 + .../ApiResourceRepositoryTests.cs | 52 +++---- .../Repositories/ApiScopeRepositoryTests.cs | 14 +- .../Repositories/ClientRepositoryTests.cs | 136 +++++++++--------- .../IdentityResourceRepositoryTests.cs | 54 +++---- .../PersistedGrantRepositoryTests.cs | 2 +- .../Services/ApiResourceServiceTests.cs | 30 ++-- .../Services/ApiScopeServiceTests.cs | 10 +- .../Services/ClientServiceTests.cs | 102 ++++++------- .../Services/IdentityResourceServiceTests.cs | 22 +-- .../Services/IdentityServiceTests.cs | 42 +++--- .../Services/PersistedGrantServiceTests.cs | 2 +- ...ende.IdentityServer.Admin.UnitTests.csproj | 4 +- 21 files changed, 301 insertions(+), 299 deletions(-) diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs index d1812c8f5..526718566 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/ConfigurationControllerTests.cs @@ -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) @@ -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) @@ -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)); } @@ -205,7 +205,7 @@ public async Task GetClientClaim() var viewModel = Assert.IsType(viewResult.ViewData.Model); viewModel.ClientClaims.Count.Should().Be(1); - viewModel.ClientClaims[0].ShouldBeEquivalentTo(clientClaimAdded); + clientClaimAdded.Should().BeEquivalentTo(viewModel.ClientClaims[0]); } [Fact] @@ -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)); @@ -295,7 +295,7 @@ public async Task GetClientSecret() var viewModel = Assert.IsType(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] @@ -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)); } @@ -380,7 +380,7 @@ public async Task GetClientProperty() var viewModel = Assert.IsType(viewResult.ViewData.Model); viewModel.ClientProperties.Count.Should().Be(1); - viewModel.ClientProperties[0].ShouldBeEquivalentTo(clientPropertyAdded); + clientPropertyAdded.Should().BeEquivalentTo(viewModel.ClientProperties[0]); } [Fact] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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] diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/IdentityControllerTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/IdentityControllerTests.cs index 383b7d09a..4c3a8adc2 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/IdentityControllerTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Controllers/IdentityControllerTests.cs @@ -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] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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) @@ -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)); } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ApiResourceMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ApiResourceMappers.cs index 4d63e6463..6051d03eb 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ApiResourceMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ApiResourceMappers.cs @@ -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) @@ -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] @@ -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) @@ -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] @@ -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); } @@ -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); } @@ -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)); @@ -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)); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ClientMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ClientMappers.cs index ba5e514ae..56e3cb178 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ClientMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/ClientMappers.cs @@ -24,7 +24,7 @@ public void CanMapClientToModel() //Asert clientDto.Should().NotBeNull(); - client.ShouldBeEquivalentTo(clientDto, options => + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.AllowedCorsOrigins) .Excluding(o => o.RedirectUris) .Excluding(o => o.PostLogoutRedirectUris) @@ -35,14 +35,14 @@ public void CanMapClientToModel() .Excluding(o => o.IdentityProviderRestrictions)); //Assert collection - client.AllowedCorsOrigins.Select(x => x.Origin).ShouldBeEquivalentTo(clientDto.AllowedCorsOrigins); - client.RedirectUris.Select(x => x.RedirectUri).ShouldBeEquivalentTo(clientDto.RedirectUris); - client.PostLogoutRedirectUris.Select(x => x.PostLogoutRedirectUri).ShouldBeEquivalentTo(clientDto.PostLogoutRedirectUris); - client.AllowedGrantTypes.Select(x => x.GrantType).ShouldBeEquivalentTo(clientDto.AllowedGrantTypes); - client.AllowedScopes.Select(x => x.Scope).ShouldBeEquivalentTo(clientDto.AllowedScopes); - client.IdentityProviderRestrictions.Select(x => x.Provider).ShouldBeEquivalentTo(clientDto.IdentityProviderRestrictions); + clientDto.AllowedCorsOrigins.Should().BeEquivalentTo(client.AllowedCorsOrigins.Select(x => x.Origin)); + clientDto.RedirectUris.Should().BeEquivalentTo(client.RedirectUris.Select(x => x.RedirectUri)); + clientDto.PostLogoutRedirectUris.Should().BeEquivalentTo(client.PostLogoutRedirectUris.Select(x => x.PostLogoutRedirectUri)); + clientDto.AllowedGrantTypes.Should().BeEquivalentTo(client.AllowedGrantTypes.Select(x => x.GrantType)); + clientDto.AllowedScopes.Should().BeEquivalentTo(client.AllowedScopes.Select(x => x.Scope)); + clientDto.IdentityProviderRestrictions.Should().BeEquivalentTo(client.IdentityProviderRestrictions.Select(x => x.Provider)); var allowedAlgList = AllowedSigningAlgorithmsConverter.Converter.Convert(client.AllowedIdentityTokenSigningAlgorithms, null); - allowedAlgList.ShouldBeEquivalentTo(clientDto.AllowedIdentityTokenSigningAlgorithms); + clientDto.AllowedIdentityTokenSigningAlgorithms.Should().BeEquivalentTo(allowedAlgList); } [Fact] @@ -56,7 +56,7 @@ public void CanMapClientDtoToEntity() client.Should().NotBeNull(); - client.ShouldBeEquivalentTo(clientDto, options => + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.AllowedCorsOrigins) .Excluding(o => o.RedirectUris) .Excluding(o => o.PostLogoutRedirectUris) @@ -67,14 +67,14 @@ public void CanMapClientDtoToEntity() .Excluding(o => o.IdentityProviderRestrictions)); //Assert collection - client.AllowedCorsOrigins.Select(x => x.Origin).ShouldBeEquivalentTo(clientDto.AllowedCorsOrigins); - client.RedirectUris.Select(x => x.RedirectUri).ShouldBeEquivalentTo(clientDto.RedirectUris); - client.PostLogoutRedirectUris.Select(x => x.PostLogoutRedirectUri).ShouldBeEquivalentTo(clientDto.PostLogoutRedirectUris); - client.AllowedGrantTypes.Select(x => x.GrantType).ShouldBeEquivalentTo(clientDto.AllowedGrantTypes); - client.AllowedScopes.Select(x => x.Scope).ShouldBeEquivalentTo(clientDto.AllowedScopes); - client.IdentityProviderRestrictions.Select(x => x.Provider).ShouldBeEquivalentTo(clientDto.IdentityProviderRestrictions); + clientDto.AllowedCorsOrigins.Should().BeEquivalentTo(client.AllowedCorsOrigins.Select(x => x.Origin)); + clientDto.RedirectUris.Should().BeEquivalentTo(client.RedirectUris.Select(x => x.RedirectUri)); + clientDto.PostLogoutRedirectUris.Should().BeEquivalentTo(client.PostLogoutRedirectUris.Select(x => x.PostLogoutRedirectUri)); + clientDto.AllowedGrantTypes.Should().BeEquivalentTo(client.AllowedGrantTypes.Select(x => x.GrantType)); + clientDto.AllowedScopes.Should().BeEquivalentTo(client.AllowedScopes.Select(x => x.Scope)); + clientDto.IdentityProviderRestrictions.Should().BeEquivalentTo(client.IdentityProviderRestrictions.Select(x => x.Provider)); var allowedAlgList = AllowedSigningAlgorithmsConverter.Converter.Convert(client.AllowedIdentityTokenSigningAlgorithms, null); - allowedAlgList.ShouldBeEquivalentTo(clientDto.AllowedIdentityTokenSigningAlgorithms); + clientDto.AllowedIdentityTokenSigningAlgorithms.Should().BeEquivalentTo(allowedAlgList); } [Fact] @@ -87,7 +87,7 @@ public void CanMapClientClaimToModel() //Assert clientClaimsDto.Should().NotBeNull(); - clientClaim.ShouldBeEquivalentTo(clientClaimsDto, options => + clientClaimsDto.Should().BeEquivalentTo(clientClaim, options => options.Excluding(o => o.Id) .Excluding(o => o.Client)); } @@ -102,7 +102,7 @@ public void CanMapClientClaimToEntity() //Assert clientClaim.Should().NotBeNull(); - clientClaim.ShouldBeEquivalentTo(clientClaimDto, options => + clientClaimDto.Should().BeEquivalentTo(clientClaim, options => options.Excluding(o => o.Id) .Excluding(o => o.Client)); } @@ -117,7 +117,7 @@ public void CanMapClientSecretToModel() //Assert clientSecretsDto.Should().NotBeNull(); - clientSecret.ShouldBeEquivalentTo(clientSecretsDto, options => + clientSecretsDto.Should().BeEquivalentTo(clientSecret, options => options.Excluding(o => o.Id) .Excluding(o => o.Created) .Excluding(o => o.Client)); @@ -133,7 +133,7 @@ public void CanMapClientSecretToEntity() //Assert clientSecret.Should().NotBeNull(); - clientSecret.ShouldBeEquivalentTo(clientSecretsDto, options => + clientSecretsDto.Should().BeEquivalentTo(clientSecret, options => options.Excluding(o => o.Id) .Excluding(o => o.Created) .Excluding(o => o.Client)); @@ -149,7 +149,7 @@ public void CanMapClientPropertyToModel() //Assert clientPropertiesDto.Should().NotBeNull(); - clientProperty.ShouldBeEquivalentTo(clientPropertiesDto, options => + clientPropertiesDto.Should().BeEquivalentTo(clientProperty, options => options.Excluding(o => o.Id) .Excluding(o => o.Client)); } @@ -164,7 +164,7 @@ public void CanMapClientPropertyToEntity() //Assert clientProperty.Should().NotBeNull(); - clientProperty.ShouldBeEquivalentTo(clientPropertiesDto, options => + clientPropertiesDto.Should().BeEquivalentTo(clientProperty, options => options.Excluding(o => o.Id) .Excluding(o => o.Client)); } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/IdentityResourceMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/IdentityResourceMappers.cs index 4a3c12a23..c06fc3a11 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/IdentityResourceMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/IdentityResourceMappers.cs @@ -23,7 +23,7 @@ public void CanMapIdentityResourceToModel() //Assert identityResourceDto.Should().NotBeNull(); - identityResource.ShouldBeEquivalentTo(identityResourceDto, options => + identityResourceDto.Should().BeEquivalentTo(identityResource, options => options.Excluding(o => o.UserClaims) .Excluding(o => o.Properties) .Excluding(o => o.Created) @@ -31,7 +31,7 @@ public void CanMapIdentityResourceToModel() .Excluding(o => o.NonEditable)); //Assert collection - identityResource.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(identityResourceDto.UserClaims); + identityResourceDto.UserClaims.Should().BeEquivalentTo(identityResource.UserClaims.Select(x => x.Type)); } [Fact] @@ -45,7 +45,7 @@ public void CanMapIdentityResourceDtoToEntity() identityResource.Should().NotBeNull(); - identityResource.ShouldBeEquivalentTo(identityResourceDto, options => + identityResourceDto.Should().BeEquivalentTo(identityResource, options => options.Excluding(o => o.UserClaims) .Excluding(o => o.Properties) .Excluding(o => o.Created) @@ -53,7 +53,7 @@ public void CanMapIdentityResourceDtoToEntity() .Excluding(o => o.NonEditable)); //Assert collection - identityResource.UserClaims.Select(x => x.Type).ShouldBeEquivalentTo(identityResourceDto.UserClaims); + identityResourceDto.UserClaims.Should().BeEquivalentTo(identityResource.UserClaims.Select(x => x.Type)); } } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/KeyMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/KeyMappers.cs index 4e172b573..a7581f7ae 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/KeyMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/KeyMappers.cs @@ -15,7 +15,7 @@ public void CanMapKeyToKeyDto() var keyDto = key.ToModel(); - key.ShouldBeEquivalentTo(keyDto); + keyDto.Should().BeEquivalentTo(key); } } } \ No newline at end of file diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/LogMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/LogMappers.cs index 67f4220c6..fb5ef28d7 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/LogMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/LogMappers.cs @@ -22,7 +22,7 @@ public void CanMapIdentityResourceToModel() //Asert logDto.Should().NotBeNull(); - log.ShouldBeEquivalentTo(logDto, options => + logDto.Should().BeEquivalentTo(log, options => options.Excluding(o => o.PropertiesXml)); } @@ -37,7 +37,7 @@ public void CanMapIdentityResourceDtoToEntity() log.Should().NotBeNull(); - log.ShouldBeEquivalentTo(logDto, options => + logDto.Should().BeEquivalentTo(log, options => options.Excluding(o => o.PropertiesXml)); } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/PersistedGrantMappers.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/PersistedGrantMappers.cs index 6ec48133f..9ae2332af 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/PersistedGrantMappers.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mappers/PersistedGrantMappers.cs @@ -25,7 +25,7 @@ public void CanMapPersistedGrantToModel() //Asert persistedGrantDto.Should().NotBeNull(); - persistedGrant.ShouldBeEquivalentTo(persistedGrantDto); + persistedGrantDto.Should().BeEquivalentTo(persistedGrant); } } } \ No newline at end of file diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mocks/ClientDtoMock.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mocks/ClientDtoMock.cs index 2ab9b5ae4..1a7dc2f05 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mocks/ClientDtoMock.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Mocks/ClientDtoMock.cs @@ -166,6 +166,8 @@ public static Faker ClientCloneFaker(int id, bool cloneClientCla var clientCloneDto = new Faker() .StrictMode(false) .RuleFor(o => o.Id, id) + .RuleFor(o => o.ClientId, Guid.NewGuid().ToString()) + .RuleFor(o => o.ClientName, Guid.NewGuid().ToString()) .RuleFor(o => o.CloneClientClaims, cloneClientClaims) .RuleFor(o => o.CloneClientCorsOrigins, cloneClientCorsOrigins) .RuleFor(o => o.CloneClientGrantTypes, cloneClientGrantTypes) diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiResourceRepositoryTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiResourceRepositoryTests.cs index 09b54b7a6..9859105e9 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiResourceRepositoryTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiResourceRepositoryTests.cs @@ -58,7 +58,7 @@ public async Task AddApiResourceAsync() var newApiResource = await context.ApiResources.Where(x => x.Id == apiResource.Id).SingleAsync(); //Assert new api resource - newApiResource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); + apiResource.Should().BeEquivalentTo(newApiResource, options => options.Excluding(o => o.Id)); } } @@ -79,13 +79,13 @@ public async Task GetApiResourceAsync() var newApiResource = await apiResourceRepository.GetApiResourceAsync(apiResource.Id); //Assert new api resource - newApiResource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id).Excluding(o => o.Secrets) + apiResource.Should().BeEquivalentTo(newApiResource, options => options.Excluding(o => o.Id).Excluding(o => o.Secrets) .Excluding(o => o.Scopes) .Excluding(o => o.UserClaims)); - newApiResource.UserClaims.ShouldBeEquivalentTo(apiResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("ApiResource"))); + apiResource.UserClaims.Should().BeEquivalentTo(newApiResource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("ApiResource"))); } } @@ -106,7 +106,7 @@ public async Task DeleteApiResourceAsync() var newApiResource = await context.ApiResources.Where(x => x.Id == apiResource.Id).SingleAsync(); //Assert new api resource - newApiResource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); + apiResource.Should().BeEquivalentTo(newApiResource, options => options.Excluding(o => o.Id)); //Delete api resource await apiResourceRepository.DeleteApiResourceAsync(newApiResource); @@ -136,7 +136,7 @@ public async Task UpdateApiResourceAsync() var newApiResource = await context.ApiResources.Where(x => x.Id == apiResource.Id).SingleOrDefaultAsync(); //Assert new api resource - newApiResource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); + apiResource.Should().BeEquivalentTo(newApiResource, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(newApiResource).State = EntityState.Detached; @@ -151,7 +151,7 @@ public async Task UpdateApiResourceAsync() var updatedApiResourceEntity = await context.ApiResources.Where(x => x.Id == updatedApiResource.Id).SingleAsync(); //Assert updated api resource - updatedApiResource.ShouldBeEquivalentTo(updatedApiResourceEntity); + updatedApiResourceEntity.Should().BeEquivalentTo(updatedApiResource); } } @@ -178,7 +178,7 @@ public async Task AddApiSecretAsync() var newApiSecret = await context.ApiSecrets.Where(x => x.Id == apiSecret.Id).SingleAsync(); //Assert new api secret - newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id)); + apiSecret.Should().BeEquivalentTo(newApiSecret, options => options.Excluding(o => o.Id)); } } @@ -205,7 +205,7 @@ public async Task DeleteApiSecretAsync() var newApiSecret = await context.ApiSecrets.Where(x => x.Id == apiSecret.Id).SingleOrDefaultAsync(); //Assert new api resource - newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id)); + apiSecret.Should().BeEquivalentTo(newApiSecret, options => options.Excluding(o => o.Id)); //Try delete it await apiResourceRepository.DeleteApiSecretAsync(newApiSecret); @@ -241,7 +241,7 @@ public async Task GetApiSecretAsync() var newApiSecret = await apiResourceRepository.GetApiSecretAsync(apiSecret.Id); //Assert new api secret - newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id) + apiSecret.Should().BeEquivalentTo(newApiSecret, options => options.Excluding(o => o.Id) .Excluding(o => o.ApiResource.Secrets) .Excluding(o => o.ApiResource.UserClaims) .Excluding(o => o.ApiResource.Scopes)); @@ -265,14 +265,14 @@ public async Task AddApiResourcePropertyAsync() var resource = await apiResourceRepository.GetApiResourceAsync(apiResource.Id); //Assert new api resource - resource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id) + apiResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id) .Excluding(o => o.Secrets) .Excluding(o => o.Scopes) .Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(apiResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("ApiResource"))); + apiResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("ApiResource"))); //Generate random new api resource property var apiResourceProperty = ApiResourceMock.GenerateRandomApiResourceProperty(0); @@ -284,7 +284,7 @@ public async Task AddApiResourcePropertyAsync() var resourceProperty = await context.ApiResourceProperties.Where(x => x.Id == apiResourceProperty.Id) .SingleOrDefaultAsync(); - resourceProperty.ShouldBeEquivalentTo(apiResourceProperty, + apiResourceProperty.Should().BeEquivalentTo(resourceProperty, options => options.Excluding(o => o.Id).Excluding(x => x.ApiResource)); } } @@ -306,14 +306,14 @@ public async Task DeleteApiResourcePropertyAsync() var resource = await apiResourceRepository.GetApiResourceAsync(apiResource.Id); //Assert new api resource - resource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id) + apiResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id) .Excluding(o => o.Secrets) .Excluding(o => o.Scopes) .Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(apiResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("ApiResource"))); + apiResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("ApiResource"))); //Generate random new api resource property var apiResourceProperty = ApiResourceMock.GenerateRandomApiResourceProperty(0); @@ -326,7 +326,7 @@ public async Task DeleteApiResourcePropertyAsync() .SingleOrDefaultAsync(); //Assert - property.ShouldBeEquivalentTo(apiResourceProperty, + apiResourceProperty.Should().BeEquivalentTo(property, options => options.Excluding(o => o.Id).Excluding(x => x.ApiResource)); //Try delete it @@ -358,14 +358,14 @@ public async Task GetApiResourcePropertyAsync() var resource = await apiResourceRepository.GetApiResourceAsync(apiResource.Id); //Assert new api resource - resource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id) + apiResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id) .Excluding(o => o.Secrets) .Excluding(o => o.Scopes) .Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(apiResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("ApiResource"))); + apiResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("ApiResource"))); //Generate random new api resource property var apiResourceProperty = ApiResourceMock.GenerateRandomApiResourceProperty(0); @@ -376,7 +376,7 @@ public async Task GetApiResourcePropertyAsync() //Get new api resource property var resourceProperty = await apiResourceRepository.GetApiResourcePropertyAsync(apiResourceProperty.Id); - resourceProperty.ShouldBeEquivalentTo(apiResourceProperty, + apiResourceProperty.Should().BeEquivalentTo(resourceProperty, options => options.Excluding(o => o.Id).Excluding(x => x.ApiResource)); } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiScopeRepositoryTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiScopeRepositoryTests.cs index ca0154734..01903a7fd 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiScopeRepositoryTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ApiScopeRepositoryTests.cs @@ -55,7 +55,7 @@ public async Task AddApiScopeAsync() var newApiScopes = await context.ApiScopes.Where(x => x.Id == apiScope.Id).SingleAsync(); //Assert new api scope - newApiScopes.ShouldBeEquivalentTo(apiScope, options => options.Excluding(o => o.Id)); + apiScope.Should().BeEquivalentTo(newApiScopes, options => options.Excluding(o => o.Id)); } } @@ -85,7 +85,7 @@ public async Task UpdateApiScopeAsync() var updatedApiScopeEntity = await context.ApiScopes.Where(x => x.Id == updatedApiScope.Id).SingleAsync(); //Assert updated api scope - updatedApiScope.ShouldBeEquivalentTo(updatedApiScopeEntity); + updatedApiScopeEntity.Should().BeEquivalentTo(updatedApiScope); } } @@ -106,7 +106,7 @@ public async Task DeleteApiScopeAsync() var newApiScopes = await context.ApiScopes.Where(x => x.Id == apiScope.Id).SingleOrDefaultAsync(); //Assert new api resource - newApiScopes.ShouldBeEquivalentTo(apiScope, options => options.Excluding(o => o.Id)); + apiScope.Should().BeEquivalentTo(newApiScopes, options => options.Excluding(o => o.Id)); //Try delete it await apiResourceRepository.DeleteApiScopeAsync(newApiScopes); @@ -136,12 +136,12 @@ public async Task GetApiScopeAsync() var newApiScopes = await apiResourceRepository.GetApiScopeAsync(apiScope.Id); //Assert new api resource - newApiScopes.ShouldBeEquivalentTo(apiScope, options => options.Excluding(o => o.Id) + apiScope.Should().BeEquivalentTo(newApiScopes, options => options.Excluding(o => o.Id) .Excluding(o => o.UserClaims)); - newApiScopes.UserClaims.ShouldBeEquivalentTo(apiScope.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Scope"))); + apiScope.UserClaims.Should().BeEquivalentTo(newApiScopes.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Scope"))); } } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ClientRepositoryTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ClientRepositoryTests.cs index d3d54054c..b97f41b76 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ClientRepositoryTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/ClientRepositoryTests.cs @@ -79,7 +79,7 @@ public async Task AddClientAsync() var clientEntity = await context.Clients.Where(x => x.Id == client.Id).SingleAsync(); //Assert new client - clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id)); + client.Should().BeEquivalentTo(clientEntity, options => options.Excluding(o => o.Id)); } } @@ -112,7 +112,7 @@ public async Task AddClientClaimAsync() var newClientClaim = await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync(); - newClientClaim.ShouldBeEquivalentTo(clientClaim, + clientClaim.Should().BeEquivalentTo(newClientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -146,7 +146,7 @@ public async Task AddClientPropertyAsync() var newClientProperty = await context.ClientProperties.Where(x => x.Id == clientProperty.Id) .SingleOrDefaultAsync(); - newClientProperty.ShouldBeEquivalentTo(clientProperty, + clientProperty.Should().BeEquivalentTo(newClientProperty, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -179,7 +179,7 @@ public async Task AddClientSecretAsync() //Get new client secret var newSecret = await context.ClientSecrets.Where(x => x.Id == clientSecret.Id).SingleOrDefaultAsync(); - newSecret.ShouldBeEquivalentTo(clientSecret, + clientSecret.Should().BeEquivalentTo(newSecret, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -439,7 +439,7 @@ public async Task DeleteClientClaimAsync() await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync(); //Assert - newClientClaim.ShouldBeEquivalentTo(clientClaim, + clientClaim.Should().BeEquivalentTo(newClientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); //Try delete it @@ -484,7 +484,7 @@ public async Task DeleteClientPropertyAsync() .SingleOrDefaultAsync(); //Assert - newClientProperties.ShouldBeEquivalentTo(clientProperty, + clientProperty.Should().BeEquivalentTo(newClientProperties, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); //Try delete it @@ -528,7 +528,7 @@ public async Task DeleteClientSecretAsync() var newSecret = await context.ClientSecrets.Where(x => x.Id == clientSecret.Id).SingleOrDefaultAsync(); //Assert - newSecret.ShouldBeEquivalentTo(clientSecret, + clientSecret.Should().BeEquivalentTo(newSecret, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); //Try delete it @@ -592,7 +592,7 @@ public async Task GetClientClaimAsync() //Get new client claim var newClientClaim = await clientRepository.GetClientClaimAsync(clientClaim.Id); - newClientClaim.ShouldBeEquivalentTo(clientClaim, + clientClaim.Should().BeEquivalentTo(newClientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -625,7 +625,7 @@ public async Task GetClientPropertyAsync() //Get new client Property var newClientProperty = await clientRepository.GetClientPropertyAsync(clientProperty.Id); - newClientProperty.ShouldBeEquivalentTo(clientProperty, + clientProperty.Should().BeEquivalentTo(newClientProperty, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -653,7 +653,7 @@ public async Task GetClientsAsync() clients.Data.Count.Should().Be(randomClients.Count); //Assert that clients are same - clients.Data.ShouldBeEquivalentTo(randomClients); + randomClients.Should().BeEquivalentTo(clients.Data); } } @@ -685,7 +685,7 @@ public async Task GetClientSecretAsync() //Get new client secret var newSecret = await clientRepository.GetClientSecretAsync(clientSecret.Id); - newSecret.ShouldBeEquivalentTo(clientSecret, + clientSecret.Should().BeEquivalentTo(newSecret, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } } @@ -707,7 +707,7 @@ public async Task RemoveClientAsync() var clientEntity = await context.Clients.Where(x => x.Id == client.Id).SingleAsync(); //Assert new client - clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id)); + client.Should().BeEquivalentTo(clientEntity, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(clientEntity).State = EntityState.Detached; @@ -741,7 +741,7 @@ public async Task UpdateClientAsync() var clientEntity = await context.Clients.Where(x => x.Id == client.Id).SingleAsync(); //Assert new client - clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id)); + client.Should().BeEquivalentTo(clientEntity, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(clientEntity).State = EntityState.Detached; @@ -757,7 +757,7 @@ public async Task UpdateClientAsync() await context.Clients.Where(x => x.Id == updatedClient.Id).SingleAsync(); //Assert updated client - updatedClientEntity.ShouldBeEquivalentTo(updatedClient); + updatedClient.Should().BeEquivalentTo(updatedClientEntity); } } @@ -828,7 +828,7 @@ public async Task GetScopesApiResourceAsync() private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare, bool cloneClientCorsOrigins = true, bool cloneClientGrantTypes = true, bool cloneClientIdPRestrictions = true, bool cloneClientPostLogoutRedirectUris = true, bool cloneClientScopes = true, bool cloneClientRedirectUris = true, bool cloneClientClaims = true, bool cloneClientProperties = true) { //Assert cloned client - cloneClientEntity.ShouldBeEquivalentTo(clientToCompare, + clientToCompare.Should().BeEquivalentTo(cloneClientEntity, options => options.Excluding(o => o.Id) .Excluding(o => o.ClientSecrets) .Excluding(o => o.ClientId) @@ -851,9 +851,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare //New client relations have new id's and client relations therefore is required ignore them if (cloneClientGrantTypes) { - cloneClientEntity.AllowedGrantTypes.ShouldBeEquivalentTo(clientToCompare.AllowedGrantTypes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedGrantTypes.Should().BeEquivalentTo(cloneClientEntity.AllowedGrantTypes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -862,9 +862,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientCorsOrigins) { - cloneClientEntity.AllowedCorsOrigins.ShouldBeEquivalentTo(clientToCompare.AllowedCorsOrigins, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedCorsOrigins.Should().BeEquivalentTo(cloneClientEntity.AllowedCorsOrigins, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -873,9 +873,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientRedirectUris) { - cloneClientEntity.RedirectUris.ShouldBeEquivalentTo(clientToCompare.RedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.RedirectUris.Should().BeEquivalentTo(cloneClientEntity.RedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -884,9 +884,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientPostLogoutRedirectUris) { - cloneClientEntity.PostLogoutRedirectUris.ShouldBeEquivalentTo(clientToCompare.PostLogoutRedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.PostLogoutRedirectUris.Should().BeEquivalentTo(cloneClientEntity.PostLogoutRedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -895,9 +895,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientScopes) { - cloneClientEntity.AllowedScopes.ShouldBeEquivalentTo(clientToCompare.AllowedScopes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedScopes.Should().BeEquivalentTo(cloneClientEntity.AllowedScopes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -906,9 +906,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientClaims) { - cloneClientEntity.Claims.ShouldBeEquivalentTo(clientToCompare.Claims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Claims.Should().BeEquivalentTo(cloneClientEntity.Claims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -917,9 +917,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientIdPRestrictions) { - cloneClientEntity.IdentityProviderRestrictions.ShouldBeEquivalentTo(clientToCompare.IdentityProviderRestrictions, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.IdentityProviderRestrictions.Should().BeEquivalentTo(cloneClientEntity.IdentityProviderRestrictions, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -928,9 +928,9 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare if (cloneClientProperties) { - cloneClientEntity.Properties.ShouldBeEquivalentTo(clientToCompare.Properties, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Properties.Should().BeEquivalentTo(cloneClientEntity.Properties, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } else { @@ -942,7 +942,7 @@ private void ClientCloneCompare(Client cloneClientEntity, Client clientToCompare private void ClientAssert(Client client, Client clientToCompare) { - client.ShouldBeEquivalentTo(clientToCompare, + clientToCompare.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id) .Excluding(o => o.ClientSecrets) .Excluding(o => o.ClientId) @@ -961,42 +961,42 @@ private void ClientAssert(Client client, Client clientToCompare) .Excluding(o => o.Properties) ); - client.AllowedGrantTypes.ShouldBeEquivalentTo(clientToCompare.AllowedGrantTypes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedGrantTypes.Should().BeEquivalentTo(client.AllowedGrantTypes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.AllowedCorsOrigins.ShouldBeEquivalentTo(clientToCompare.AllowedCorsOrigins, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedCorsOrigins.Should().BeEquivalentTo(client.AllowedCorsOrigins, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.RedirectUris.ShouldBeEquivalentTo(clientToCompare.RedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.RedirectUris.Should().BeEquivalentTo(client.RedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.PostLogoutRedirectUris.ShouldBeEquivalentTo(clientToCompare.PostLogoutRedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.PostLogoutRedirectUris.Should().BeEquivalentTo(client.PostLogoutRedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.AllowedScopes.ShouldBeEquivalentTo(clientToCompare.AllowedScopes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedScopes.Should().BeEquivalentTo(client.AllowedScopes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.ClientSecrets.ShouldBeEquivalentTo(clientToCompare.ClientSecrets, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.ClientSecrets.Should().BeEquivalentTo(client.ClientSecrets, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.Claims.ShouldBeEquivalentTo(clientToCompare.Claims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Claims.Should().BeEquivalentTo(client.Claims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.IdentityProviderRestrictions.ShouldBeEquivalentTo( - clientToCompare.IdentityProviderRestrictions, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.IdentityProviderRestrictions.Should().BeEquivalentTo( + client.IdentityProviderRestrictions, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - client.Properties.ShouldBeEquivalentTo(clientToCompare.Properties, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Properties.Should().BeEquivalentTo(client.Properties, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } } } \ No newline at end of file diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/IdentityResourceRepositoryTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/IdentityResourceRepositoryTests.cs index a6d4eb9bd..9fbed6058 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/IdentityResourceRepositoryTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/IdentityResourceRepositoryTests.cs @@ -57,7 +57,7 @@ public async Task AddIdentityResourceAsync() var newIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id).SingleAsync(); //Assert new identity resource - newIdentityResource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id)); + identityResource.Should().BeEquivalentTo(newIdentityResource, options => options.Excluding(o => o.Id)); } } @@ -78,11 +78,11 @@ public async Task GetIdentityResourceAsync() var newIdentityResource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource - newIdentityResource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); + identityResource.Should().BeEquivalentTo(newIdentityResource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); - newIdentityResource.UserClaims.ShouldBeEquivalentTo(identityResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("IdentityResource"))); + identityResource.UserClaims.Should().BeEquivalentTo(newIdentityResource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("IdentityResource"))); } } @@ -103,7 +103,7 @@ public async Task DeleteIdentityResourceAsync() var newIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id).SingleAsync(); //Assert new identity resource - newIdentityResource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id)); + identityResource.Should().BeEquivalentTo(newIdentityResource, options => options.Excluding(o => o.Id)); //Delete identity resource await identityResourceRepository.DeleteIdentityResourceAsync(newIdentityResource); @@ -133,7 +133,7 @@ public async Task UpdateIdentityResourceAsync() var newIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id).SingleOrDefaultAsync(); //Assert new identity resource - newIdentityResource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id)); + identityResource.Should().BeEquivalentTo(newIdentityResource, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(newIdentityResource).State = EntityState.Detached; @@ -148,7 +148,7 @@ public async Task UpdateIdentityResourceAsync() var updatedIdentityResourceEntity = await context.IdentityResources.Where(x => x.Id == updatedIdentityResource.Id).SingleAsync(); //Assert updated identity resource - updatedIdentityResource.ShouldBeEquivalentTo(updatedIdentityResourceEntity); + updatedIdentityResourceEntity.Should().BeEquivalentTo(updatedIdentityResource); } } @@ -168,13 +168,13 @@ public async Task AddIdentityResourcePropertyAsync() //Get new identity resource var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id); - //Assert new identity resource - resource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id) + //Assert new identity resource + identityResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id) .Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(identityResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("IdentityResource"))); + identityResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("IdentityResource"))); //Generate random new identity resource property var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0); @@ -186,7 +186,7 @@ public async Task AddIdentityResourcePropertyAsync() var resourceProperty = await context.IdentityResourceProperties.Where(x => x.Id == identityResourceProperty.Id) .SingleOrDefaultAsync(); - resourceProperty.ShouldBeEquivalentTo(identityResourceProperty, + identityResourceProperty.Should().BeEquivalentTo(resourceProperty, options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource)); } } @@ -207,12 +207,12 @@ public async Task DeleteIdentityResourcePropertyAsync() //Get new identity resource var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id); - //Assert new identity resource - resource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); + //Assert new identity resource + identityResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(identityResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("IdentityResource"))); + identityResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("IdentityResource"))); //Generate random new identity resource property var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0); @@ -224,8 +224,8 @@ public async Task DeleteIdentityResourcePropertyAsync() var property = await context.IdentityResourceProperties.Where(x => x.Id == identityResourceProperty.Id) .SingleOrDefaultAsync(); - //Assert - property.ShouldBeEquivalentTo(identityResourceProperty, + //Assert + identityResourceProperty.Should().BeEquivalentTo(property, options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource)); //Try delete it @@ -256,12 +256,12 @@ public async Task GetIdentityResourcePropertyAsync() //Get new identity resource var resource = await identityResourceRepository.GetIdentityResourceAsync(identityResource.Id); - //Assert new identity resource - resource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); + //Assert new identity resource + identityResource.Should().BeEquivalentTo(resource, options => options.Excluding(o => o.Id).Excluding(o => o.UserClaims)); - resource.UserClaims.ShouldBeEquivalentTo(identityResource.UserClaims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("IdentityResource"))); + identityResource.UserClaims.Should().BeEquivalentTo(resource.UserClaims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("IdentityResource"))); //Generate random new identity resource property var identityResourceProperty = IdentityResourceMock.GenerateRandomIdentityResourceProperty(0); @@ -272,7 +272,7 @@ public async Task GetIdentityResourcePropertyAsync() //Get new identity resource property var resourceProperty = await identityResourceRepository.GetIdentityResourcePropertyAsync(identityResourceProperty.Id); - resourceProperty.ShouldBeEquivalentTo(identityResourceProperty, + identityResourceProperty.Should().BeEquivalentTo(resourceProperty, options => options.Excluding(o => o.Id).Excluding(x => x.IdentityResource)); } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/PersistedGrantRepositoryTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/PersistedGrantRepositoryTests.cs index 981862854..2eaa03cf7 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/PersistedGrantRepositoryTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Repositories/PersistedGrantRepositoryTests.cs @@ -67,7 +67,7 @@ public async Task GetPersistedGrantAsync() var persistedGrantAdded = await persistedGrantRepository.GetPersistedGrantAsync(persistedGrantKey); //Assert - persistedGrant.ShouldBeEquivalentTo(persistedGrantAdded, opt => opt.Excluding(x => x.Key)); + persistedGrantAdded.Should().BeEquivalentTo(persistedGrant, opt => opt.Excluding(x => x.Key)); } } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiResourceServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiResourceServiceTests.cs index 70d9e9d8f..56a6c6628 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiResourceServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiResourceServiceTests.cs @@ -105,7 +105,7 @@ public async Task AddApiResourceAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); } } @@ -127,7 +127,7 @@ public async Task GetApiResourceAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); } } @@ -149,7 +149,7 @@ public async Task RemoveApiResourceAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); //Remove api resource await apiResourceService.DeleteApiResourceAsync(newApiResourceDto); @@ -181,7 +181,7 @@ public async Task UpdateApiResourceAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(apiResource).State = EntityState.Detached; @@ -195,7 +195,7 @@ public async Task UpdateApiResourceAsync() var updatedApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert updated api resuorce - updatedApiResource.ShouldBeEquivalentTo(updatedApiResourceDto, options => options.Excluding(o => o.Id)); + updatedApiResourceDto.Should().BeEquivalentTo(updatedApiResource, options => options.Excluding(o => o.Id)); } } @@ -217,7 +217,7 @@ public async Task AddApiSecretAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); //Generate random new api secret var apiSecretsDto = ApiResourceDtoMock.GenerateRandomApiSecret(0, newApiResourceDto.Id); @@ -239,7 +239,7 @@ public async Task AddApiSecretAsync() secretsDto.Value.Should().Be(apiSecretsDto.Value); //Assert - newApiSecret.ShouldBeEquivalentTo(secretsDto, o => o.Excluding(x => x.ApiResourceName).Excluding(x => x.Value)); + secretsDto.Should().BeEquivalentTo(newApiSecret, o => o.Excluding(x => x.ApiResourceName).Excluding(x => x.Value)); } } @@ -261,7 +261,7 @@ public async Task DeleteApiSecretAsync() var newApiResourceDto = await apiResourceService.GetApiResourceAsync(apiResource.Id); //Assert new api resource - apiResourceDto.ShouldBeEquivalentTo(newApiResourceDto, options => options.Excluding(o => o.Id)); + newApiResourceDto.Should().BeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); //Generate random new api secret var apiSecretsDtoMock = ApiResourceDtoMock.GenerateRandomApiSecret(0, newApiResourceDto.Id); @@ -280,7 +280,7 @@ public async Task DeleteApiSecretAsync() var newApiSecret = await apiResourceService.GetApiSecretAsync(apiSecretsDto.ApiSecretId); //Assert - newApiSecret.ShouldBeEquivalentTo(apiSecretsDto, o => o.Excluding(x => x.ApiResourceName).Excluding(x => x.Value)); + apiSecretsDto.Should().BeEquivalentTo(newApiSecret, o => o.Excluding(x => x.ApiResourceName).Excluding(x => x.Value)); apiSecretsDto.Value.Should().Be(apiSecretsDtoMock.Value); @@ -313,7 +313,7 @@ public async Task AddApiResourcePropertyAsync() var apiResourceDto = await apiResourceService.GetApiResourceAsync(resource.Id); //Assert new api resource - apiResource.ShouldBeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); + apiResourceDto.Should().BeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); //Generate random new api resource property var apiResourceProperty = ApiResourceDtoMock.GenerateRandomApiResourceProperty(0, resource.Id); @@ -332,7 +332,7 @@ public async Task AddApiResourcePropertyAsync() var resourcePropertiesDto = await apiResourceService.GetApiResourcePropertyAsync(property.Id); //Assert - resourcePropertiesDto.ShouldBeEquivalentTo(propertyDto, options => + propertyDto.Should().BeEquivalentTo(resourcePropertiesDto, options => options.Excluding(o => o.ApiResourcePropertyId) .Excluding(o => o.ApiResourceName)); } @@ -356,7 +356,7 @@ public async Task GetApiResourcePropertyAsync() var apiResourceDto = await apiResourceService.GetApiResourceAsync(resource.Id); //Assert new api resource - apiResource.ShouldBeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); + apiResourceDto.Should().BeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); //Generate random new api resource property var apiResourceProperty = ApiResourceDtoMock.GenerateRandomApiResourceProperty(0, resource.Id); @@ -375,7 +375,7 @@ public async Task GetApiResourcePropertyAsync() var apiResourcePropertiesDto = await apiResourceService.GetApiResourcePropertyAsync(property.Id); //Assert - apiResourcePropertiesDto.ShouldBeEquivalentTo(propertyDto, options => + propertyDto.Should().BeEquivalentTo(apiResourcePropertiesDto, options => options.Excluding(o => o.ApiResourcePropertyId) .Excluding(o => o.ApiResourceName)); } @@ -399,7 +399,7 @@ public async Task DeleteApiResourcePropertyAsync() var apiResourceDto = await apiResourceService.GetApiResourceAsync(resource.Id); //Assert new api resource - apiResource.ShouldBeEquivalentTo(apiResourceDto, options => options.Excluding(o => o.Id)); + apiResourceDto.Should().BeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); //Generate random new api resource Property var apiResourcePropertiesDto = ApiResourceDtoMock.GenerateRandomApiResourceProperty(0, resource.Id); @@ -418,7 +418,7 @@ public async Task DeleteApiResourcePropertyAsync() var resourcePropertiesDto = await apiResourceService.GetApiResourcePropertyAsync(property.Id); //Assert - resourcePropertiesDto.ShouldBeEquivalentTo(propertiesDto, options => + propertiesDto.Should().BeEquivalentTo(resourcePropertiesDto, options => options.Excluding(o => o.ApiResourcePropertyId) .Excluding(o => o.ApiResourceName)); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiScopeServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiScopeServiceTests.cs index 95090696f..89e7e6e57 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiScopeServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ApiScopeServiceTests.cs @@ -93,7 +93,7 @@ public async Task AddApiScopeAsync() var newApiScope = await apiScopeService.GetApiScopeAsync(apiScopesDto.Id); //Assert - newApiScope.ShouldBeEquivalentTo(apiScopesDto); + apiScopesDto.Should().BeEquivalentTo(newApiScope); } } @@ -121,7 +121,7 @@ public async Task GetApiScopeAsync() var newApiScope = await apiScopeService.GetApiScopeAsync(apiScopesDto.Id); //Assert - newApiScope.ShouldBeEquivalentTo(apiScopesDto); + apiScopesDto.Should().BeEquivalentTo(newApiScope); } } @@ -149,7 +149,7 @@ public async Task UpdateApiScopeAsync() var newApiScope = await apiScopeService.GetApiScopeAsync(apiScopesDto.Id); //Assert - newApiScope.ShouldBeEquivalentTo(apiScopesDto); + apiScopesDto.Should().BeEquivalentTo(newApiScope); //Detached the added item context.Entry(apiScope).State = EntityState.Detached; @@ -162,7 +162,7 @@ public async Task UpdateApiScopeAsync() var updatedApiScopeDto = await apiScopeService.GetApiScopeAsync(apiScopesDto.Id); //Assert updated api scope - updatedApiScope.ShouldBeEquivalentTo(updatedApiScopeDto); + updatedApiScopeDto.Should().BeEquivalentTo(updatedApiScope); } } @@ -190,7 +190,7 @@ public async Task DeleteApiScopeAsync() var newApiScope = await apiScopeService.GetApiScopeAsync(apiScopeDto.Id); //Assert - newApiScope.ShouldBeEquivalentTo(apiScopeDto); + apiScopeDto.Should().BeEquivalentTo(newApiScope); //Delete it await apiScopeService.DeleteApiScopeAsync(newApiScope); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ClientServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ClientServiceTests.cs index c1658d9ef..e0054b257 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ClientServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/ClientServiceTests.cs @@ -87,7 +87,7 @@ public async Task AddClientAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); } } @@ -141,7 +141,7 @@ public async Task CloneClientAsync() .Where(x => x.Id == clientDtoToClone.Id).SingleOrDefaultAsync(); //Assert cloned client - cloneClientEntity.ShouldBeEquivalentTo(clientToCompare, + clientToCompare.Should().BeEquivalentTo(cloneClientEntity, options => options.Excluding(o => o.Id) .Excluding(o => o.ClientSecrets) .Excluding(o => o.ClientId) @@ -162,42 +162,42 @@ public async Task CloneClientAsync() //New client relations have new id's and client relations therefore is required ignore them - cloneClientEntity.AllowedGrantTypes.ShouldBeEquivalentTo(clientToCompare.AllowedGrantTypes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedGrantTypes.Should().BeEquivalentTo(cloneClientEntity.AllowedGrantTypes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.AllowedCorsOrigins.ShouldBeEquivalentTo(clientToCompare.AllowedCorsOrigins, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedCorsOrigins.Should().BeEquivalentTo(cloneClientEntity.AllowedCorsOrigins, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.RedirectUris.ShouldBeEquivalentTo(clientToCompare.RedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.RedirectUris.Should().BeEquivalentTo(cloneClientEntity.RedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.PostLogoutRedirectUris.ShouldBeEquivalentTo(clientToCompare.PostLogoutRedirectUris, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.PostLogoutRedirectUris.Should().BeEquivalentTo(cloneClientEntity.PostLogoutRedirectUris, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.AllowedScopes.ShouldBeEquivalentTo(clientToCompare.AllowedScopes, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.AllowedScopes.Should().BeEquivalentTo(cloneClientEntity.AllowedScopes, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.ClientSecrets.ShouldBeEquivalentTo(clientToCompare.ClientSecrets, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.ClientSecrets.Should().BeEquivalentTo(cloneClientEntity.ClientSecrets, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.Claims.ShouldBeEquivalentTo(clientToCompare.Claims, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Claims.Should().BeEquivalentTo(cloneClientEntity.Claims, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.IdentityProviderRestrictions.ShouldBeEquivalentTo( + clientToCompare.IdentityProviderRestrictions.Should().BeEquivalentTo( clientToCompare.IdentityProviderRestrictions, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); - cloneClientEntity.Properties.ShouldBeEquivalentTo(clientToCompare.Properties, - option => option.Excluding(x => x.SelectedMemberPath.EndsWith("Id")) - .Excluding(x => x.SelectedMemberPath.EndsWith("Client"))); + clientToCompare.Properties.Should().BeEquivalentTo(cloneClientEntity.Properties, + option => option.Excluding(x => x.Path.EndsWith("Id")) + .Excluding(x => x.Path.EndsWith("Client"))); } } @@ -221,7 +221,7 @@ public async Task UpdateClientAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(clientEntity).State = EntityState.Detached; @@ -238,7 +238,7 @@ public async Task UpdateClientAsync() var updatedClientDto = await clientService.GetClientAsync(updatedClientEntity.Id); //Assert updated client - updatedClient.ShouldBeEquivalentTo(updatedClientDto, options => options.Excluding(o => o.Id)); + updatedClientDto.Should().BeEquivalentTo(updatedClient, options => options.Excluding(o => o.Id)); } } @@ -262,7 +262,7 @@ public async Task RemoveClientAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(clientEntity).State = EntityState.Detached; @@ -298,7 +298,7 @@ public async Task GetClientAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); } } @@ -321,7 +321,7 @@ public async Task AddClientClaimAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client Claim var clientClaim = ClientDtoMock.GenerateRandomClientClaim(0, clientEntity.Id); @@ -340,7 +340,7 @@ public async Task AddClientClaimAsync() var clientClaimsDto = await clientService.GetClientClaimAsync(claim.Id); //Assert - clientClaimsDto.ShouldBeEquivalentTo(claimsDto, options => + claimsDto.Should().BeEquivalentTo(clientClaimsDto, options => options.Excluding(o => o.ClientClaimId) .Excluding(o => o.ClientName)); } @@ -365,7 +365,7 @@ public async Task DeleteClientClaimAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client Claim var clientClaim = ClientDtoMock.GenerateRandomClientClaim(0, clientEntity.Id); @@ -384,7 +384,7 @@ public async Task DeleteClientClaimAsync() var clientClaimsDto = await clientService.GetClientClaimAsync(claim.Id); //Assert - clientClaimsDto.ShouldBeEquivalentTo(claimsDto, options => options.Excluding(o => o.ClientClaimId) + claimsDto.Should().BeEquivalentTo(clientClaimsDto, options => options.Excluding(o => o.ClientClaimId) .Excluding(o => o.ClientName)); //Delete client claim @@ -417,7 +417,7 @@ public async Task GetClientClaimAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client Claim var clientClaim = ClientDtoMock.GenerateRandomClientClaim(0, clientEntity.Id); @@ -436,7 +436,7 @@ public async Task GetClientClaimAsync() var clientClaimsDto = await clientService.GetClientClaimAsync(claim.Id); //Assert - clientClaimsDto.ShouldBeEquivalentTo(claimsDto, options => options.Excluding(o => o.ClientClaimId) + claimsDto.Should().BeEquivalentTo(clientClaimsDto, options => options.Excluding(o => o.ClientClaimId) .Excluding(o => o.ClientName)); } } @@ -460,7 +460,7 @@ public async Task AddClientPropertyAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client property var clicentProperty = ClientDtoMock.GenerateRandomClientProperty(0, clientEntity.Id); @@ -479,7 +479,7 @@ public async Task AddClientPropertyAsync() var clientPropertiesDto = await clientService.GetClientPropertyAsync(property.Id); //Assert - clientPropertiesDto.ShouldBeEquivalentTo(propertyDto, options => + propertyDto.Should().BeEquivalentTo(clientPropertiesDto, options => options.Excluding(o => o.ClientPropertyId) .Excluding(o => o.ClientName)); } @@ -504,7 +504,7 @@ public async Task GetClientPropertyAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client property var clicentProperty = ClientDtoMock.GenerateRandomClientProperty(0, clientEntity.Id); @@ -523,7 +523,7 @@ public async Task GetClientPropertyAsync() var clientPropertiesDto = await clientService.GetClientPropertyAsync(property.Id); //Assert - clientPropertiesDto.ShouldBeEquivalentTo(propertyDto, options => options.Excluding(o => o.ClientPropertyId) + propertyDto.Should().BeEquivalentTo(clientPropertiesDto, options => options.Excluding(o => o.ClientPropertyId) .Excluding(o => o.ClientName)); } } @@ -547,7 +547,7 @@ public async Task DeleteClientPropertyAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client Property var clientProperty = ClientDtoMock.GenerateRandomClientProperty(0, clientEntity.Id); @@ -566,7 +566,7 @@ public async Task DeleteClientPropertyAsync() var clientPropertiesDto = await clientService.GetClientPropertyAsync(property.Id); //Assert - clientPropertiesDto.ShouldBeEquivalentTo(propertiesDto, options => options.Excluding(o => o.ClientPropertyId) + propertiesDto.Should().BeEquivalentTo(clientPropertiesDto, options => options.Excluding(o => o.ClientPropertyId) .Excluding(o => o.ClientName)); //Delete client Property @@ -599,7 +599,7 @@ public async Task AddClientSecretAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client secret var clientSecret = ClientDtoMock.GenerateRandomClientSecret(0, clientEntity.Id); @@ -620,7 +620,7 @@ public async Task AddClientSecretAsync() clientSecretsDto.Value.Should().Be(clientSecret.Value); //Assert - secretsDto.ShouldBeEquivalentTo(clientSecretsDto, options => + clientSecretsDto.Should().BeEquivalentTo(secretsDto, options => options.Excluding(o => o.ClientSecretId) .Excluding(o => o.ClientName) .Excluding(o => o.Value)); @@ -646,7 +646,7 @@ public async Task GetClientSecretAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client secret var clientSecret = ClientDtoMock.GenerateRandomClientSecret(0, clientEntity.Id); @@ -667,7 +667,7 @@ public async Task GetClientSecretAsync() clientSecretsDto.Value.Should().Be(clientSecret.Value); //Assert - secretsDto.ShouldBeEquivalentTo(clientSecretsDto, options => options.Excluding(o => o.ClientSecretId) + clientSecretsDto.Should().BeEquivalentTo(secretsDto, options => options.Excluding(o => o.ClientSecretId) .Excluding(o => o.ClientName) .Excluding(o => o.Value)); } @@ -692,7 +692,7 @@ public async Task DeleteClientSecretAsync() var clientDto = await clientService.GetClientAsync(clientEntity.Id); //Assert new client - client.ShouldBeEquivalentTo(clientDto, options => options.Excluding(o => o.Id)); + clientDto.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client secret var clientSecret = ClientDtoMock.GenerateRandomClientSecret(0, clientEntity.Id); @@ -711,7 +711,7 @@ public async Task DeleteClientSecretAsync() var clientSecretsDto = await clientService.GetClientSecretAsync(secret.Id); //Assert - clientSecretsDto.ShouldBeEquivalentTo(secretsDto, options => options.Excluding(o => o.ClientSecretId) + secretsDto.Should().BeEquivalentTo(clientSecretsDto, options => options.Excluding(o => o.ClientSecretId) .Excluding(o => o.ClientName) .Excluding(o => o.Value)); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityResourceServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityResourceServiceTests.cs index 2e4993491..cfd3f885f 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityResourceServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityResourceServiceTests.cs @@ -86,7 +86,7 @@ public async Task AddIdentityResourceAsync() var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource - identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); + newIdentityResourceDto.Should().BeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); } } @@ -108,7 +108,7 @@ public async Task GetIdentityResourceAsync() var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource - identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); + newIdentityResourceDto.Should().BeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); } } @@ -130,7 +130,7 @@ public async Task RemoveIdentityResourceAsync() var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource - identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); + newIdentityResourceDto.Should().BeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); //Remove identity resource await identityResourceService.DeleteIdentityResourceAsync(newIdentityResourceDto); @@ -162,7 +162,7 @@ public async Task UpdateIdentityResourceAsync() var newIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert new identity resource - identityResourceDto.ShouldBeEquivalentTo(newIdentityResourceDto, options => options.Excluding(o => o.Id)); + newIdentityResourceDto.Should().BeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(identityResource).State = EntityState.Detached; @@ -176,7 +176,7 @@ public async Task UpdateIdentityResourceAsync() var updatedIdentityResourceDto = await identityResourceService.GetIdentityResourceAsync(identityResource.Id); //Assert updated identity resuorce - updatedIdentityResource.ShouldBeEquivalentTo(updatedIdentityResourceDto, options => options.Excluding(o => o.Id)); + updatedIdentityResourceDto.Should().BeEquivalentTo(updatedIdentityResource, options => options.Excluding(o => o.Id)); } } @@ -198,7 +198,7 @@ public async Task AddIdentityResourcePropertyAsync() var identityResourceDto = await identityResourceService.GetIdentityResourceAsync(resource.Id); //Assert new identity resource - identityResource.ShouldBeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); + identityResourceDto.Should().BeEquivalentTo(identityResource, options => options.Excluding(o => o.Id)); //Generate random new identity resource property var resourceProperty = IdentityResourceDtoMock.GenerateRandomIdentityResourceProperty(0, resource.Id); @@ -217,7 +217,7 @@ public async Task AddIdentityResourcePropertyAsync() var resourcePropertiesDto = await identityResourceService.GetIdentityResourcePropertyAsync(property.Id); //Assert - resourcePropertiesDto.ShouldBeEquivalentTo(propertyDto, options => + propertyDto.Should().BeEquivalentTo(resourcePropertiesDto, options => options.Excluding(o => o.IdentityResourcePropertyId) .Excluding(o => o.IdentityResourceName)); } @@ -241,7 +241,7 @@ public async Task GetIdentityResourcePropertyAsync() var identityResourceDto = await identityResourceService.GetIdentityResourceAsync(resource.Id); //Assert new identity resource - identityResource.ShouldBeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); + identityResourceDto.Should().BeEquivalentTo(identityResource, options => options.Excluding(o => o.Id)); //Generate random new identity resource property var identityResourceProperty = IdentityResourceDtoMock.GenerateRandomIdentityResourceProperty(0, resource.Id); @@ -260,7 +260,7 @@ public async Task GetIdentityResourcePropertyAsync() var resourcePropertiesDto = await identityResourceService.GetIdentityResourcePropertyAsync(property.Id); //Assert - resourcePropertiesDto.ShouldBeEquivalentTo(propertyDto, options => + propertyDto.Should().BeEquivalentTo(resourcePropertiesDto, options => options.Excluding(o => o.IdentityResourcePropertyId) .Excluding(o => o.IdentityResourceName)); } @@ -284,7 +284,7 @@ public async Task DeleteIdentityResourcePropertyAsync() var identityResourceDto = await identityResourceService.GetIdentityResourceAsync(resource.Id); //Assert new identity resource - resourceDto.ShouldBeEquivalentTo(identityResourceDto, options => options.Excluding(o => o.Id)); + identityResourceDto.Should().BeEquivalentTo(resourceDto, options => options.Excluding(o => o.Id)); //Generate random new identity resource Property var identityResourcePropertiesDto = IdentityResourceDtoMock.GenerateRandomIdentityResourceProperty(0, resource.Id); @@ -303,7 +303,7 @@ public async Task DeleteIdentityResourcePropertyAsync() var resourcePropertiesDto = await identityResourceService.GetIdentityResourcePropertyAsync(property.Id); //Assert - resourcePropertiesDto.ShouldBeEquivalentTo(propertiesDto, options => + propertiesDto.Should().BeEquivalentTo(resourcePropertiesDto, options => options.Excluding(o => o.IdentityResourcePropertyId) .Excluding(o => o.IdentityResourceName)); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityServiceTests.cs index e6e84324e..d73bc3d2b 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/IdentityServiceTests.cs @@ -143,7 +143,7 @@ public async Task AddUserAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); } } @@ -166,7 +166,7 @@ public async Task DeleteUserProviderAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); var userProvider = IdentityMock.GenerateRandomUserProviders(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), newUserDto.Id); @@ -209,7 +209,7 @@ public async Task AddUserRoleAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Generate random new role var roleDto = IdentityDtoMock.GenerateRandomRole(); @@ -223,7 +223,7 @@ public async Task AddUserRoleAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); var userRoleDto = IdentityDtoMock.GenerateRandomUserRole>(roleDto.Id, userDto.Id); @@ -255,7 +255,7 @@ public async Task DeleteUserRoleAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Generate random new role var roleDto = IdentityDtoMock.GenerateRandomRole(); @@ -269,7 +269,7 @@ public async Task DeleteUserRoleAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); var userRoleDto = IdentityDtoMock.GenerateRandomUserRole>(roleDto.Id, userDto.Id); @@ -306,7 +306,7 @@ public async Task AddUserClaimAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Generate random new user claim var userClaimDto = IdentityDtoMock.GenerateRandomUserClaim(0, userDto.Id); @@ -320,7 +320,7 @@ public async Task AddUserClaimAsync() var newUserClaim = await identityService.GetUserClaimAsync(userDto.Id.ToString(), claim.Id); //Assert new user claim - userClaimDto.ShouldBeEquivalentTo(newUserClaim); + newUserClaim.Should().BeEquivalentTo(userClaimDto); } } @@ -343,7 +343,7 @@ public async Task DeleteUserClaimAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Generate random new user claim var userClaimDto = IdentityDtoMock.GenerateRandomUserClaim(0, userDto.Id); @@ -357,7 +357,7 @@ public async Task DeleteUserClaimAsync() var newUserClaim = await identityService.GetUserClaimAsync(userDto.Id.ToString(), claim.Id); //Assert new user claim - userClaimDto.ShouldBeEquivalentTo(newUserClaim); + newUserClaim.Should().BeEquivalentTo(userClaimDto); await identityService.DeleteUserClaimAsync(userClaimDto); @@ -386,7 +386,7 @@ public async Task UpdateUserAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Detached the added item context.Entry(user).State = EntityState.Detached; @@ -400,7 +400,7 @@ public async Task UpdateUserAsync() var updatedUser = await identityService.GetUserAsync(userDtoForUpdate.Id.ToString()); //Assert updated user - userDtoForUpdate.ShouldBeEquivalentTo(updatedUser); + updatedUser.Should().BeEquivalentTo(userDtoForUpdate); } } @@ -423,7 +423,7 @@ public async Task DeleteUserAsync() var newUserDto = await identityService.GetUserAsync(userDto.Id.ToString()); //Assert new user - userDto.ShouldBeEquivalentTo(newUserDto); + newUserDto.Should().BeEquivalentTo(userDto); //Remove user await identityService.DeleteUserAsync(newUserDto.Id.ToString(), newUserDto); @@ -456,7 +456,7 @@ public async Task AddRoleAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); } } @@ -479,7 +479,7 @@ public async Task UpdateRoleAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); //Detached the added item context.Entry(role).State = EntityState.Detached; @@ -493,7 +493,7 @@ public async Task UpdateRoleAsync() var updatedRole = await identityService.GetRoleAsync(roleDtoForUpdate.Id.ToString()); //Assert updated role - roleDtoForUpdate.ShouldBeEquivalentTo(updatedRole); + updatedRole.Should().BeEquivalentTo(roleDtoForUpdate); } } @@ -516,7 +516,7 @@ public async Task DeleteRoleAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); //Remove role await identityService.DeleteRoleAsync(newRoleDto); @@ -549,7 +549,7 @@ public async Task AddRoleClaimAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); //Generate random new role claim var roleClaimDto = IdentityDtoMock.GenerateRandomRoleClaim(0, roleDto.Id); @@ -563,7 +563,7 @@ public async Task AddRoleClaimAsync() var newRoleClaimDto = await identityService.GetRoleClaimAsync(roleDto.Id.ToString(), roleClaimDto.ClaimId); //Assert new role - roleClaimDto.ShouldBeEquivalentTo(newRoleClaimDto, options => options.Excluding(o => o.RoleName)); + newRoleClaimDto.Should().BeEquivalentTo(roleClaimDto, options => options.Excluding(o => o.RoleName)); } } @@ -586,7 +586,7 @@ public async Task RemoveRoleClaimAsync() var newRoleDto = await identityService.GetRoleAsync(roleDto.Id.ToString()); //Assert new role - roleDto.ShouldBeEquivalentTo(newRoleDto); + newRoleDto.Should().BeEquivalentTo(roleDto); //Generate random new role claim var roleClaimDto = IdentityDtoMock.GenerateRandomRoleClaim(0, roleDto.Id); @@ -600,7 +600,7 @@ public async Task RemoveRoleClaimAsync() var newRoleClaimDto = await identityService.GetRoleClaimAsync(roleDto.Id.ToString(), roleClaimDto.ClaimId); //Assert new role - roleClaimDto.ShouldBeEquivalentTo(newRoleClaimDto, options => options.Excluding(o => o.RoleName)); + newRoleClaimDto.Should().BeEquivalentTo(roleClaimDto, options => options.Excluding(o => o.RoleName)); await identityService.DeleteRoleClaimAsync(roleClaimDto); diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/PersistedGrantServiceTests.cs b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/PersistedGrantServiceTests.cs index ce448e708..e6255057e 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/PersistedGrantServiceTests.cs +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Services/PersistedGrantServiceTests.cs @@ -89,7 +89,7 @@ public async Task GetPersistedGrantAsync() var persistedGrantAdded = await persistedGrantService.GetPersistedGrantAsync(persistedGrantKey); //Assert - persistedGrant.ShouldBeEquivalentTo(persistedGrantAdded); + persistedGrantAdded.Should().BeEquivalentTo(persistedGrant); } } } diff --git a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Skoruba.Duende.IdentityServer.Admin.UnitTests.csproj b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Skoruba.Duende.IdentityServer.Admin.UnitTests.csproj index daf5a482b..7fce5cf8e 100644 --- a/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Skoruba.Duende.IdentityServer.Admin.UnitTests.csproj +++ b/tests/Skoruba.Duende.IdentityServer.Admin.UnitTests/Skoruba.Duende.IdentityServer.Admin.UnitTests.csproj @@ -17,8 +17,8 @@ runtime; build; native; contentfiles; analyzers - - + +