diff --git a/src/MongoFramework.AspNetCore.Identity/MongoIdentityClaims.cs b/src/MongoFramework.AspNetCore.Identity/MongoIdentityClaims.cs index f0a9319..eee253a 100644 --- a/src/MongoFramework.AspNetCore.Identity/MongoIdentityClaims.cs +++ b/src/MongoFramework.AspNetCore.Identity/MongoIdentityClaims.cs @@ -21,12 +21,12 @@ public class MongoIdentityUserClaim where TKey : IEquatable /// /// Gets or sets the claim type for this claim. /// - public virtual string? ClaimType { get; set; } + public virtual string ClaimType { get; set; } /// /// Gets or sets the claim value for this claim. /// - public virtual string? ClaimValue { get; set; } + public virtual string ClaimValue { get; set; } /// /// Converts the entity into a Claim instance. @@ -63,12 +63,12 @@ public class MongoIdentityRoleClaim where TKey : IEquatable /// /// Gets or sets the claim type for this claim. /// - public virtual string? ClaimType { get; set; } + public virtual string ClaimType { get; set; } /// /// Gets or sets the claim value for this claim. /// - public virtual string? ClaimValue { get; set; } + public virtual string ClaimValue { get; set; } /// /// Constructs a new claim with the type and value. @@ -83,7 +83,7 @@ public virtual Claim ToClaim() /// Initializes by copying ClaimType and ClaimValue from the other claim. /// /// The claim to initialize from. - public virtual void InitializeFromClaim(Claim? other) + public virtual void InitializeFromClaim(Claim other) { ClaimType = other?.Type; ClaimValue = other?.Value; diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj index f2f705c..eb18771 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj @@ -16,7 +16,7 @@ - + all diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoFrameworkServiceCollectionExtensionsTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoFrameworkServiceCollectionExtensionsTests.cs index c5f5cf4..49018e2 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoFrameworkServiceCollectionExtensionsTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoFrameworkServiceCollectionExtensionsTests.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoFramework.AspNetCore.Identity.Tests @@ -32,9 +32,9 @@ public void RegistersContextWithNoParameters() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService()) { - db.ShouldBeOfType(); - db.Connection.ShouldNotBeNull(); - db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.ShouldBe("identity-test"); + db.Should().BeOfType(); + db.Connection.Should().NotBeNull(); + db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.Should().Be("identity-test"); } } @@ -54,9 +54,9 @@ public void RegistersConnectionWithValidConnectionString() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService()) { - db.ShouldBeOfType(); - db.Connection.ShouldNotBeNull(); - db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.ShouldBe("identity-test"); + db.Should().BeOfType(); + db.Connection.Should().NotBeNull(); + db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.Should().Be("identity-test"); } } @@ -76,7 +76,7 @@ public void RegistersConnectionWithListener() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService()) { - db.Connection.DiagnosticListener.ShouldBeOfType(); + db.Connection.DiagnosticListener.Should().BeOfType(); } } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityBuilderExtensionsTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityBuilderExtensionsTests.cs index d50c2ed..0c39454 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityBuilderExtensionsTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityBuilderExtensionsTests.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoFramework.AspNetCore.Identity.Tests @@ -36,8 +36,8 @@ public void RegistersFullyTypedUserStoreWithMongoIdentityContext() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService>()) { - db.GetType().GenericTypeArguments.Length.ShouldBe(9); - db.ShouldBeOfType, IdentityUserRole, IdentityUserLogin, IdentityUserToken, IdentityRoleClaim>>(); + db.GetType().GenericTypeArguments.Length.Should().Be(9); + db.Should().BeOfType, IdentityUserRole, IdentityUserLogin, IdentityUserToken, IdentityRoleClaim>>(); } } @@ -64,8 +64,8 @@ public void RegistersFullyTypedUserOnlyStoreWithMongoIdentityContext() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService>()) { - db.GetType().GenericTypeArguments.Length.ShouldBe(6); - db.ShouldBeOfType, IdentityUserLogin, IdentityUserToken>>(); + db.GetType().GenericTypeArguments.Length.Should().Be(6); + db.Should().BeOfType, IdentityUserLogin, IdentityUserToken>>(); } } @@ -94,8 +94,8 @@ public void RegistersLimitedTypedUserStoreWithMongoContext() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService>()) { - db.GetType().GenericTypeArguments.Length.ShouldBe(4); - db.ShouldBeOfType>(); + db.GetType().GenericTypeArguments.Length.Should().Be(4); + db.Should().BeOfType>(); } } @@ -122,8 +122,8 @@ public void RegistersLimitedTypedUserOnlyStoreWithMongoContext() using (var scoped = provider.GetRequiredService().CreateScope()) using (var db = scoped.ServiceProvider.GetRequiredService>()) { - db.GetType().GenericTypeArguments.Length.ShouldBe(3); - db.ShouldBeOfType>(); + db.GetType().GenericTypeArguments.Length.Should().Be(3); + db.Should().BeOfType>(); } } @@ -141,12 +141,13 @@ public void ExtensionThrowsExceptionWithoutMongoIdentityRole() services.AddTransient(); - Should.Throw(() => + Action action = () => { services .AddIdentity() .AddMongoFrameworkStores(); - }); + }; + action.Should().Throw(); } [Fact] @@ -162,12 +163,13 @@ public void ExtensionThrowsExceptionWithoutMongoIdentityUser() services.AddTransient(); - Should.Throw(() => + Action action = () => { services .AddIdentity() .AddMongoFrameworkStores(); - }); + }; + action.Should().Throw(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs index 62bcec8..c13be97 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using MongoDB.Bson; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests @@ -49,8 +49,8 @@ public void ContextWithRolesLoadsRoles() var store = new MongoRoleStore(context); - store.Context.ShouldBeOfType(); - store.Roles.Count().ShouldBe(3); + store.Context.Should().BeOfType(); + store.Roles.Count().Should().Be(3); } [Fact] @@ -60,8 +60,8 @@ public void ContextWithUsersLoadsUsers() var store = new MongoUserOnlyStore(context); - store.Context.ShouldBeOfType(); - store.Users.Count().ShouldBe(1); + store.Context.Should().BeOfType(); + store.Users.Count().Should().Be(1); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityRoleTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityRoleTests.cs index 29cb387..5dee2a8 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityRoleTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityRoleTests.cs @@ -1,7 +1,7 @@ -using System; +using System; using System.Collections.Generic; using Microsoft.AspNetCore.Identity; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests @@ -13,8 +13,8 @@ public void ConstructorCreatesEmptyLists() { var role = new MongoIdentityRole(); - role.Claims.ShouldNotBeNull(); - role.Claims.Count.ShouldBe(0); + role.Claims.Should().NotBeNull(); + role.Claims.Count.Should().Be(0); } [Fact] @@ -22,18 +22,19 @@ public void ConstructorSucceedsWithValidUserName() { var role = new MongoIdentityRole("role-name"); - role.Name.ShouldBe("role-name"); - role.NormalizedName.ShouldBe("ROLE-NAME"); - role.ToString().ShouldBe("role-name"); + role.Name.Should().Be("role-name"); + role.NormalizedName.Should().Be("ROLE-NAME"); + role.ToString().Should().Be("role-name"); } [Fact] public void ConstructorThrowsExceptionWithNullUserName() { - Should.Throw(() => + Action action = () => { _ = new MongoIdentityRole(null); - }); + }; + action.Should().Throw(); } [Fact] @@ -41,7 +42,7 @@ public void KeyTypeIsUsedInCollectionsWithInteger() { var role = new MongoIdentityRole(); - role.Claims.ShouldBeOfType>>(); + role.Claims.Should().BeOfType>>(); } [Fact] @@ -49,7 +50,7 @@ public void KeyTypeIsUsedInCollectionsWithGuid() { var role = new MongoIdentityRole(); - role.Claims.ShouldBeOfType>>(); + role.Claims.Should().BeOfType>>(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityUserTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityUserTests.cs index a0050ee..c5b73b5 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityUserTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityUserTests.cs @@ -1,7 +1,7 @@ -using System; +using System; using System.Collections.Generic; using Microsoft.AspNetCore.Identity; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests @@ -13,15 +13,15 @@ public void ConstructorCreatesEmptyLists() { var user = new MongoIdentityUser(); - user.Claims.ShouldNotBeNull(); - user.Roles.ShouldNotBeNull(); - user.Tokens.ShouldNotBeNull(); - user.Logins.ShouldNotBeNull(); + user.Claims.Should().NotBeNull(); + user.Roles.Should().NotBeNull(); + user.Tokens.Should().NotBeNull(); + user.Logins.Should().NotBeNull(); - user.Claims.Count.ShouldBe(0); - user.Roles.Count.ShouldBe(0); - user.Tokens.Count.ShouldBe(0); - user.Logins.Count.ShouldBe(0); + user.Claims.Count.Should().Be(0); + user.Roles.Count.Should().Be(0); + user.Tokens.Count.Should().Be(0); + user.Logins.Count.Should().Be(0); } [Fact] @@ -29,17 +29,18 @@ public void ConstructorSucceedsWithValidUserName() { var user = new MongoIdentityUser("username"); - user.UserName.ShouldBe("username"); - user.NormalizedUserName.ShouldBe("USERNAME"); + user.UserName.Should().Be("username"); + user.NormalizedUserName.Should().Be("USERNAME"); } [Fact] public void ConstructorThrowsExceptionWithNullUserName() { - Should.Throw(() => + Action action = () => { _ = new MongoIdentityUser(null); - }); + }; + action.Should().Throw(); } [Fact] @@ -47,9 +48,9 @@ public void KeyTypeIsUsedInCollectionsWithInteger() { var user = new MongoIdentityUser(); - user.Claims.ShouldBeOfType>>(); - user.Tokens.ShouldBeOfType>>(); - user.Logins.ShouldBeOfType>>(); + user.Claims.Should().BeOfType>>(); + user.Tokens.Should().BeOfType>>(); + user.Logins.Should().BeOfType>>(); } [Fact] @@ -57,9 +58,9 @@ public void KeyTypeIsUsedInCollectionsWithGuid() { var user = new MongoIdentityUser(); - user.Claims.ShouldBeOfType>>(); - user.Tokens.ShouldBeOfType>>(); - user.Logins.ShouldBeOfType>>(); + user.Claims.Should().BeOfType>>(); + user.Tokens.Should().BeOfType>>(); + user.Logins.Should().BeOfType>>(); } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs index 728dcc0..e447d5c 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs @@ -1,8 +1,8 @@ -using System; +using System; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests @@ -39,7 +39,7 @@ public void ConstructorUsesMongo() var store = new MongoRoleStore(context); - store.Context.ShouldBeOfType(); + store.Context.Should().BeOfType(); } [Fact] @@ -49,8 +49,8 @@ public void ConvertIdFromStringWithIntReturnsZero() var store = new MongoRoleStore, DbContext, int>(context); - store.ConvertIdFromString(null).ShouldBe(0); - store.ConvertIdFromString("12345").ShouldBe(12345); + store.ConvertIdFromString(null).Should().Be(0); + store.ConvertIdFromString("12345").Should().Be(12345); } [Fact] @@ -60,8 +60,8 @@ public void ConvertIdToStringWithIntReturnsNull() var store = new MongoRoleStore, DbContext, int>(context); - store.ConvertIdToString(0).ShouldBeNull(); - store.ConvertIdToString(12345).ShouldBe("12345"); + store.ConvertIdToString(0).Should().BeNull(); + store.ConvertIdToString(12345).Should().Be("12345"); } [Fact] @@ -73,7 +73,7 @@ public async Task GetNormalizedRoleReturnsCorrect() var role = new MongoIdentityRole { Name = "testrole", NormalizedName = "TESTROLE" }; var name = await store.GetNormalizedRoleNameAsync(role); - name.ShouldBe("TESTROLE"); + name.Should().Be("TESTROLE"); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs index 685704a..c35cb93 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddClaims.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -38,8 +38,8 @@ await store.AddClaimsAsync(user, new Claim("type2", "value2") }); - user.Claims.Count.ShouldBe(2); - user.Claims[0].ClaimType.ShouldBe("type"); + user.Claims.Count.Should().Be(2); + user.Claims[0].ClaimType.Should().Be("type"); } [Fact] @@ -62,8 +62,8 @@ await store.AddClaimsAsync(user, store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Claims.Count.ShouldBe(2); - user.Claims[0].ClaimType.ShouldBe("type"); + user.Claims.Count.Should().Be(2); + user.Claims[0].ClaimType.Should().Be("type"); } [Fact] @@ -71,16 +71,18 @@ public async Task ThrowsExceptionWithNullArguments() { var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync("1000"); + var user = new TestUser(); - await Should.ThrowAsync(async () => + var act = async () => { await store.AddClaimsAsync(null, new[] { new Claim("type", "value") }); - }); - await Should.ThrowAsync(async () => + }; + await act.Should().ThrowAsync(); + var act1 = async () => { await store.AddClaimsAsync(user, null); - }); + }; + await act1.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs index 3fa149e..b9f12de 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/AddLogin.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -35,8 +35,8 @@ public async Task UpdatesUser() await store.AddLoginAsync(user, new UserLoginInfo("provider1", "provider-key", "Login Provider")); - user.Logins.Count.ShouldBe(1); - user.Logins[0].LoginProvider.ShouldBe("provider1"); + user.Logins.Count.Should().Be(1); + user.Logins[0].LoginProvider.Should().Be("provider1"); } [Fact] @@ -53,8 +53,8 @@ public async Task SavesData() store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Logins.Count.ShouldBe(1); - user.Logins[0].LoginProvider.ShouldBe("provider1"); + user.Logins.Count.Should().Be(1); + user.Logins[0].LoginProvider.Should().Be("provider1"); } [Fact] @@ -62,16 +62,18 @@ public async Task ThrowsExceptionWithNullArguments() { var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync("1000"); + var user = new TestUser(); - await Should.ThrowAsync(async () => + var act = async () => { await store.AddLoginAsync(null, new UserLoginInfo("", "", "")); - }); - await Should.ThrowAsync(async () => + }; + await act.Should().ThrowAsync(); + var act1 = async () => { await store.AddLoginAsync(user, null); - }); + }; + await act1.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs index a6086a7..18d5a71 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/CreateUser.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -22,7 +22,7 @@ public async Task ReturnsSuccessWithStringId() var result = await store.CreateAsync(TestUser.First); - result.ShouldBe(IdentityResult.Success); + result.Should().Be(IdentityResult.Success); } [Fact] @@ -33,9 +33,9 @@ public async Task CreatesDataWithStringId() await store.CreateAsync(TestUser.First); - context.TestUsers.Any().ShouldBeTrue(); - context.TestUsers.Count().ShouldBe(1); - context.TestUsers.FirstOrDefault()?.CustomData.ShouldBe("Some Info 1"); + context.TestUsers.Any().Should().BeTrue(); + context.TestUsers.Count().Should().Be(1); + context.TestUsers.FirstOrDefault()?.CustomData.Should().Be("Some Info 1"); } [Fact] @@ -48,8 +48,8 @@ public async Task DoesNotCreatesDataWithAutoSaveOff() await store.CreateAsync(TestUser.First); - context.TestUsers.Any().ShouldBeFalse(); - context.TestUsers.Count().ShouldBe(0); + context.TestUsers.Any().Should().BeFalse(); + context.TestUsers.Count().Should().Be(0); } @@ -61,7 +61,7 @@ public async Task ReturnsSuccessWithIntId() var result = await store.CreateAsync(TestUserInt.First); - result.ShouldBe(IdentityResult.Success); + result.Should().Be(IdentityResult.Success); } [Fact] @@ -72,9 +72,9 @@ public async Task CreatesDataWithIntId() await store.CreateAsync(TestUserInt.First); - context.TestUsersInt.Any().ShouldBeTrue(); - context.TestUsersInt.Count().ShouldBe(1); - context.TestUsersInt.FirstOrDefault()?.CustomData.ShouldBe("Some Info 1"); + context.TestUsersInt.Any().Should().BeTrue(); + context.TestUsersInt.Count().Should().Be(1); + context.TestUsersInt.FirstOrDefault()?.CustomData.Should().Be("Some Info 1"); } [Fact] @@ -83,10 +83,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.CreateAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs index 916a326..a81a96f 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/DeleteUser.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -21,7 +21,7 @@ public async Task DeletesDataWithValidUser() var store = new MongoUserOnlyStore(context); await store.CreateAsync(TestUser.First); - context.TestUsers.Any().ShouldBeTrue(); + context.TestUsers.Any().Should().BeTrue(); context = new TestContext(GetConnection()); store = new MongoUserOnlyStore(context); @@ -29,7 +29,7 @@ public async Task DeletesDataWithValidUser() await store.DeleteAsync(user); - context.TestUsers.Any().ShouldBeFalse(); + context.TestUsers.Any().Should().BeFalse(); } [Fact] @@ -39,7 +39,7 @@ public async Task ReturnsSuccessWithValidUser() var store = new MongoUserOnlyStore(context); await store.CreateAsync(TestUser.First); - context.TestUsers.Any().ShouldBeTrue(); + context.TestUsers.Any().Should().BeTrue(); context = new TestContext(GetConnection()); store = new MongoUserOnlyStore(context); @@ -47,7 +47,7 @@ public async Task ReturnsSuccessWithValidUser() var result = await store.DeleteAsync(user); - result.ShouldBe(IdentityResult.Success); + result.Should().Be(IdentityResult.Success); } [Fact] @@ -56,10 +56,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.DeleteAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs index 943dfd6..58a7fe9 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByEmail.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -33,8 +33,8 @@ public async Task FindsCorrectUserWithValidEmail() var result = await store.FindByEmailAsync("TEST3@TESTING.COM"); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name3"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name3"); } [Fact] @@ -47,8 +47,8 @@ public async Task FindsTrackedEntityWithValidEmail() var result = await store.FindByEmailAsync("TEST2@TESTING.COM"); - result.ShouldBeSameAs(tracked); - result.CustomData.ShouldBe("updated"); + result.Should().BeSameAs(tracked); + result.CustomData.Should().Be("updated"); } [Fact] @@ -59,7 +59,7 @@ public async Task ReturnsNullWithInvalidEmail() var result = await store.FindByEmailAsync("none"); - result.ShouldBeNull(); + result.Should().BeNull(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs index 372308e..d6cf956 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindById.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -38,8 +38,8 @@ public async Task FindsCorrectUserWithValidStringId() var result = await store.FindByIdAsync(TestIds.UserId2); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name2"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name2"); } [Fact] @@ -50,7 +50,7 @@ public async Task ReturnsNullWithInvalidStringId() var result = await store.FindByIdAsync("none"); - result.ShouldBeNull(); + result.Should().BeNull(); } [Fact] @@ -61,8 +61,8 @@ public async Task FindsCorrectUserWithValidIntId() var result = await store.FindByIdAsync("2000"); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name2"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name2"); } [Fact] @@ -73,7 +73,7 @@ public async Task ReturnsNullWithInvalidIntId() var result = await store.FindByIdAsync("1234"); - result.ShouldBeNull(); + result.Should().BeNull(); } [Fact] @@ -82,10 +82,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.FindByIdAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs index 279059e..1182b7b 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByLogin.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -54,8 +54,8 @@ public async Task GetsCorrectUserFromLogin() var user = await store.FindByLoginAsync("provider3", "provider-key"); - user.ShouldNotBeNull(); - user.Id.ShouldBe(TestIds.UserId2); + user.Should().NotBeNull(); + user.Id.Should().Be(TestIds.UserId2); } [Fact] @@ -64,11 +64,11 @@ public async Task GetsLoginWithUserIdAndProvider() var context = new TestContext(GetConnection()); var store = new TestStore(context); - var login = await store.ExposeFindUserLoginAsync(TestIds.UserId1, "provider2", "provider-key").ConfigureAwait(false); + var login = await store.ExposeFindUserLoginAsync(TestIds.UserId1, "provider2", "provider-key"); - login.ShouldNotBeNull(); - login.UserId.ShouldBe(TestIds.UserId1); - login.LoginProvider.ShouldBe("provider2"); + login.Should().NotBeNull(); + login.UserId.Should().Be(TestIds.UserId1); + login.LoginProvider.Should().Be("provider2"); } [Fact] @@ -79,7 +79,7 @@ public async Task ReturnsNullFromNonExisting() var user = await store.FindByLoginAsync("provider5", "provider-key"); - user.ShouldBeNull(); + user.Should().BeNull(); } [Fact] @@ -90,7 +90,7 @@ public async Task ReturnsNullFromNull() var user = await store.FindByLoginAsync(null, "provider-key"); - user.ShouldBeNull(); + user.Should().BeNull(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs index 4b20556..6a85638 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/FindByName.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -33,8 +33,8 @@ public async Task FindsCorrectUserWithValidUserName() var result = await store.FindByNameAsync("USER NAME2"); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name2"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name2"); } @@ -48,8 +48,8 @@ public async Task FindsTrackedEntityWithValidUserName() var result = await store.FindByNameAsync("USER NAME2"); - result.ShouldBeSameAs(tracked); - result.CustomData.ShouldBe("updated"); + result.Should().BeSameAs(tracked); + result.CustomData.Should().Be("updated"); } @@ -61,7 +61,7 @@ public async Task ReturnsNullWithInvalidUserName() var result = await store.FindByNameAsync("none"); - result.ShouldBeNull(); + result.Should().BeNull(); } [Fact] @@ -70,10 +70,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.FindByNameAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs index 4189d11..1c8d99a 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetClaims.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -42,8 +42,8 @@ public async Task RetrievesClaimsFromUser() var claims = await store.GetClaimsAsync(user); - claims.Count.ShouldBe(2); - claims[0].Type.ShouldBe("type"); + claims.Count.Should().Be(2); + claims[0].Type.Should().Be("type"); } [Fact] @@ -52,10 +52,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.GetClaimsAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs index 4c699e8..d82d55c 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetLogins.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -38,8 +38,8 @@ public async Task RetrieveLoginsFromUser() var logins = await store.GetLoginsAsync(user); - logins.Count.ShouldBe(2); - logins[0].LoginProvider.ShouldBe("provider1"); + logins.Count.Should().Be(2); + logins[0].LoginProvider.Should().Be("provider1"); } [Fact] @@ -48,10 +48,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.GetLoginsAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs index 831bf98..6cc9c9b 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetToken.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -39,8 +39,8 @@ public async Task RetrieveLoginsFromUser() var token1 = await store.GetTokenAsync(user, "provider1", "name1", default); var token2 = await store.GetTokenAsync(user, "provider2", "name2", default); - token1.ShouldBe("token-value1"); - token2.ShouldBe("token-value2"); + token1.Should().Be("token-value1"); + token2.Should().Be("token-value2"); } [Fact] @@ -49,10 +49,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.GetTokenAsync(null, "", "", default); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs index 15483a8..c51dab3 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/GetUsersForClaim.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -60,8 +60,8 @@ public async Task RetrieveUsersForClaim() var users = await store.GetUsersForClaimAsync(new Claim("type", "value")); var users2 = await store.GetUsersForClaimAsync(new Claim("type2", "value2")); - users.Count.ShouldBe(3); - users2.Count.ShouldBe(2); + users.Count.Should().Be(3); + users2.Count.Should().Be(2); } @@ -71,10 +71,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.GetClaimsAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs index ac4909b..a21e0ee 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveClaim.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -44,7 +44,7 @@ public async Task RemoveClaimWithExistingClaim() await store.RemoveClaimsAsync(user, claims); - user.Claims.Count.ShouldBe(0); + user.Claims.Count.Should().Be(0); } [Fact] @@ -59,7 +59,7 @@ await store.RemoveClaimsAsync(user, new[] { new Claim("type2", "value2") }); - user.Claims.Count.ShouldBe(0); + user.Claims.Count.Should().Be(0); } [Fact] @@ -78,7 +78,7 @@ public async Task SavesData() store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Claims.Count.ShouldBe(0); + user.Claims.Count.Should().Be(0); } [Fact] @@ -86,16 +86,18 @@ public async Task ThrowsExceptionWithNullArguments() { var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync("1000"); + var user = new TestUser(); - await Should.ThrowAsync(async () => + var act = async () => { await store.RemoveClaimsAsync(null, new[] { new Claim("type", "value") }); - }); - await Should.ThrowAsync(async () => + }; + await act.Should().ThrowAsync(); + var act1 = async () => { await store.RemoveClaimsAsync(user, null); - }); + }; + await act1.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs index 5e3a219..6d9bf29 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveLogin.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -37,7 +37,7 @@ public async Task RemoveLoginWithExistingLogin() await store.RemoveLoginAsync(user, "provider1", "provider-key"); - user.Logins.Count.ShouldBe(0); + user.Logins.Count.Should().Be(0); } [Fact] @@ -54,7 +54,7 @@ public async Task SavesData() store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Logins.Count.ShouldBe(0); + user.Logins.Count.Should().Be(0); } [Fact] @@ -63,10 +63,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.RemoveLoginAsync(null, "", ""); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs index f026a9e..5b3e873 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/RemoveToken.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -38,7 +38,7 @@ public async Task RemovesToken() await store.RemoveTokenAsync(user, "provider2", "name2", default); - user.Tokens.Count.ShouldBe(1); + user.Tokens.Count.Should().Be(1); } [Fact] @@ -57,7 +57,7 @@ public async Task SavesData() user = await store.FindByIdAsync(TestIds.UserId1); - user.Tokens.Count.ShouldBe(1); + user.Tokens.Count.Should().Be(1); } [Fact] @@ -66,10 +66,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.RemoveTokenAsync(null, "", "", default); - }); + }; + await act.Should().ThrowAsync(); } } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs index 223d80f..66472fc 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/ReplaceClaim.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -45,8 +45,8 @@ public async Task ReplaceUsersClaim() await store.ReplaceClaimAsync(user, claim, new Claim("new-type", "new-value")); - user.Claims[0].ClaimType.ShouldBe("new-type"); - user.Claims[0].ClaimValue.ShouldBe("new-value"); + user.Claims[0].ClaimType.Should().Be("new-type"); + user.Claims[0].ClaimValue.Should().Be("new-value"); } [Fact] @@ -67,8 +67,8 @@ public async Task SavesData() store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Claims.Count.ShouldBe(2); - user.Claims[0].ClaimType.ShouldBe("new-type"); + user.Claims.Count.Should().Be(2); + user.Claims[0].ClaimType.Should().Be("new-type"); } [Fact] @@ -76,20 +76,23 @@ public async Task ThrowsExceptionWithNullArguments() { var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - var user = await store.FindByIdAsync("1000"); + var user = new TestUser(); - await Should.ThrowAsync(async () => + var act = async () => { await store.ReplaceClaimAsync(null, new Claim("type", "value"), new Claim("type", "value")); - }); - await Should.ThrowAsync(async () => + }; + await act.Should().ThrowAsync(); + var act1 = async () => { await store.ReplaceClaimAsync(user, null, new Claim("type", "value")); - }); - await Should.ThrowAsync(async () => + }; + await act1.Should().ThrowAsync(); + var act2 = async () => { await store.ReplaceClaimAsync(user, new Claim("type", "value"), null); - }); + }; + await act2.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs index 0dba82e..7195bfa 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/SetToken.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -33,8 +33,8 @@ public async Task UpdatesUserWithValidData() await store.SetTokenAsync(user, "provider", "name", "token-value", default); - user.Tokens.Count.ShouldBe(1); - user.Tokens[0].Value.ShouldBe("token-value"); + user.Tokens.Count.Should().Be(1); + user.Tokens[0].Value.Should().Be("token-value"); } [Fact] @@ -52,8 +52,8 @@ public async Task SavesData() store = new MongoUserOnlyStore(context); user = await store.FindByIdAsync(TestIds.UserId1); - user.Tokens.Count.ShouldBe(1); - user.Tokens[0].Value.ShouldBe("token-value"); + user.Tokens.Count.Should().Be(1); + user.Tokens[0].Value.Should().Be("token-value"); } [Fact] @@ -62,10 +62,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.SetTokenAsync(null, "", "", "", default); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs index e1ce06d..d16d02c 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserOnlyStoreTests/UpdateUser.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -35,7 +35,7 @@ public async Task ReturnsSuccess() user.CustomData = "new-data"; var result = await store.UpdateAsync(user); - result.ShouldBe(IdentityResult.Success); + result.Should().Be(IdentityResult.Success); } [Fact] @@ -49,7 +49,7 @@ public async Task SavesData() user.CustomData = "new-data"; await store.UpdateAsync(user); - context.TestUsers.FirstOrDefault()?.CustomData.ShouldBe("new-data"); + context.TestUsers.FirstOrDefault()?.CustomData.Should().Be("new-data"); } [Fact] @@ -58,10 +58,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserOnlyStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.UpdateAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs index 446d097..90c6288 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByEmail.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserStoreTests @@ -33,8 +33,8 @@ public async Task FindsCorrectUserWithValidEmail() var result = await store.FindByEmailAsync("TEST3@TESTING.COM"); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name3"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name3"); } [Fact] @@ -47,8 +47,8 @@ public async Task FindsTrackedEntityWithValidEmail() var result = await store.FindByEmailAsync("TEST2@TESTING.COM"); - result.ShouldBeSameAs(tracked); - result.CustomData.ShouldBe("updated"); + result.Should().BeSameAs(tracked); + result.CustomData.Should().Be("updated"); } [Fact] @@ -59,7 +59,7 @@ public async Task ReturnsNullWithInvalidEmail() var result = await store.FindByEmailAsync("none"); - result.ShouldBeNull(); + result.Should().BeNull(); } [Fact] @@ -68,10 +68,11 @@ public async Task ThrowsExceptionWithNull() var context = new TestContext(GetConnection()); var store = new MongoUserStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.FindByEmailAsync(null); - }); + }; + await act.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs index 4760c4d..a5b5ad4 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByLogin.cs @@ -1,11 +1,11 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserStoreTests @@ -54,8 +54,8 @@ public async Task GetsCorrectUserFromLogin() var user = await store.FindByLoginAsync("provider3", "provider-key"); - user.ShouldNotBeNull(); - user.Id.ShouldBe(TestIds.UserId2); + user.Should().NotBeNull(); + user.Id.Should().Be(TestIds.UserId2); } [Fact] @@ -64,11 +64,11 @@ public async Task GetsLoginWithUserIdAndProvider() var context = new TestContext(GetConnection()); var store = new TestStore(context); - var login = await store.ExposeFindUserLoginAsync(TestIds.UserId1, "provider2", "provider-key").ConfigureAwait(false); + var login = await store.ExposeFindUserLoginAsync(TestIds.UserId1, "provider2", "provider-key"); - login.ShouldNotBeNull(); - login.UserId.ShouldBe(TestIds.UserId1); - login.LoginProvider.ShouldBe("provider2"); + login.Should().NotBeNull(); + login.UserId.Should().Be(TestIds.UserId1); + login.LoginProvider.Should().Be("provider2"); } [Fact] @@ -79,7 +79,7 @@ public async Task ReturnsNullFromNonExisting() var user = await store.FindByLoginAsync("provider5", "provider-key"); - user.ShouldBeNull(); + user.Should().BeNull(); } [Fact] @@ -90,7 +90,7 @@ public async Task ReturnsNullFromNull() var user = await store.FindByLoginAsync(null, "provider-key"); - user.ShouldBeNull(); + user.Should().BeNull(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs index 6f6a6d6..624ca4c 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindByName.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserStoreTests @@ -33,8 +33,8 @@ public async Task FindsCorrectUserWithValidUserName() var result = await store.FindByNameAsync("USER NAME2"); - result.ShouldNotBeNull(); - result.UserName.ShouldBe("User Name2"); + result.Should().NotBeNull(); + result.UserName.Should().Be("User Name2"); } @@ -48,8 +48,8 @@ public async Task FindsTrackedEntityWithValidUserName() var result = await store.FindByNameAsync("USER NAME2"); - result.ShouldBeSameAs(tracked); - result.CustomData.ShouldBe("updated"); + result.Should().BeSameAs(tracked); + result.CustomData.Should().Be("updated"); } @@ -61,7 +61,7 @@ public async Task ReturnsNullWithInvalidUserName() var result = await store.FindByNameAsync("none"); - result.ShouldBeNull(); + result.Should().BeNull(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs index 1287463..f0ad960 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/FindUserRole.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading; @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserStoreTests @@ -53,9 +53,9 @@ public async Task FindUserRoleWithValidRole() var role = await store.ExposeFindUserRoleAsync(TestIds.UserId1, TestIds.RoleId1); - role.ShouldNotBeNull(); - role.RoleId.ShouldBe(TestIds.RoleId1); - role.UserId.ShouldBe(TestIds.UserId1); } + role.Should().NotBeNull(); + role.RoleId.Should().Be(TestIds.RoleId1); + role.UserId.Should().Be(TestIds.UserId1); } [Fact] public async Task FindUserRoleFailsWithInvalidRole() @@ -65,7 +65,7 @@ public async Task FindUserRoleFailsWithInvalidRole() var role = await store.ExposeFindUserRoleAsync("a1", "none-rid1"); - role.ShouldBeNull(); + role.Should().BeNull(); } [Fact] @@ -76,7 +76,7 @@ public async Task FindUserRoleFailsWithInvaliUser() var role = await store.ExposeFindUserRoleAsync("none-a1", "rid1"); - role.ShouldBeNull(); + role.Should().BeNull(); } [Fact] @@ -85,14 +85,16 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new TestStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.ExposeFindUserRoleAsync(null, "rid1"); - }); - await Should.ThrowAsync(async () => + }; + await act.Should().ThrowAsync(); + var act1 = async () => { await store.ExposeFindUserRoleAsync("a1", null); - }); + }; + await act1.Should().ThrowAsync(); } } diff --git a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs index f7f2ad2..e3a82ce 100644 --- a/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs +++ b/tests/MongoFramework.AspNetCore.Identity.Tests/MongoUserStoreTests/GetRoles.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses; -using Shouldly; +using AwesomeAssertions; using Xunit; namespace MongoEntityFramework.AspNetCore.Identity.Tests.MongoUserOnlyStoreTests @@ -43,8 +43,8 @@ public async Task GetRolesWithUser() var roles = await store.GetRolesAsync(user); - roles.Count.ShouldBe(2); - roles[0].ShouldBe("Role 1"); + roles.Count.Should().Be(2); + roles[0].Should().Be("Role 1"); } [Fact] @@ -53,10 +53,11 @@ public async Task ThrowsExceptionWithNullArguments() var context = new TestContext(GetConnection()); var store = new MongoUserStore(context); - await Should.ThrowAsync(async () => + var act = async () => { await store.GetRolesAsync(null); - }); + }; + await act.Should().ThrowAsync(); } }