Skip to content

Commit 2c5ad3c

Browse files
Migrate from Shouldly to AwesomeAssertions v9.2.1
Co-authored-by: JohnCampionJr <1094820+JohnCampionJr@users.noreply.github.com>
1 parent 3d7a8b5 commit 2c5ad3c

30 files changed

Lines changed: 263 additions & 259 deletions

tests/MongoFramework.AspNetCore.Identity.Tests/MongoEntityFramework.AspNetCore.Identity.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
19-
<PackageReference Include="Shouldly" Version="4.3.0" />
19+
<PackageReference Include="AwesomeAssertions" Version="9.2.1" />
2020
<PackageReference Include="xunit" Version="2.9.3" />
2121
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
2222
<PrivateAssets>all</PrivateAssets>

tests/MongoFramework.AspNetCore.Identity.Tests/MongoFrameworkServiceCollectionExtensionsTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using Microsoft.AspNetCore.Identity;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.DependencyInjection;
7-
using Shouldly;
7+
using AwesomeAssertions;
88
using Xunit;
99

1010
namespace MongoFramework.AspNetCore.Identity.Tests
@@ -32,9 +32,9 @@ public void RegistersContextWithNoParameters()
3232
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
3333
using (var db = scoped.ServiceProvider.GetRequiredService<MongoIdentityDbContext>())
3434
{
35-
db.ShouldBeOfType<MongoIdentityDbContext>();
36-
db.Connection.ShouldNotBeNull();
37-
db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.ShouldBe("identity-test");
35+
db.Should().BeOfType<MongoIdentityDbContext>();
36+
db.Connection.Should().NotBeNull();
37+
db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.Should().Be("identity-test");
3838
}
3939

4040
}
@@ -54,9 +54,9 @@ public void RegistersConnectionWithValidConnectionString()
5454
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
5555
using (var db = scoped.ServiceProvider.GetRequiredService<MongoIdentityDbContext>())
5656
{
57-
db.ShouldBeOfType<MongoIdentityDbContext>();
58-
db.Connection.ShouldNotBeNull();
59-
db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.ShouldBe("identity-test");
57+
db.Should().BeOfType<MongoIdentityDbContext>();
58+
db.Connection.Should().NotBeNull();
59+
db.Connection.GetDatabase().DatabaseNamespace.DatabaseName.Should().Be("identity-test");
6060
}
6161
}
6262

@@ -76,7 +76,7 @@ public void RegistersConnectionWithListener()
7676
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
7777
using (var db = scoped.ServiceProvider.GetRequiredService<MongoIdentityDbContext>())
7878
{
79-
db.Connection.DiagnosticListener.ShouldBeOfType<NoOpDiagnosticListener>();
79+
db.Connection.DiagnosticListener.Should().BeOfType<NoOpDiagnosticListener>();
8080
}
8181
}
8282
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityBuilderExtensionsTests.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using Microsoft.AspNetCore.Identity;
55
using Microsoft.Extensions.Configuration;
66
using Microsoft.Extensions.DependencyInjection;
7-
using Shouldly;
7+
using AwesomeAssertions;
88
using Xunit;
99

1010
namespace MongoFramework.AspNetCore.Identity.Tests
@@ -36,8 +36,8 @@ public void RegistersFullyTypedUserStoreWithMongoIdentityContext()
3636
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
3737
using (var db = scoped.ServiceProvider.GetRequiredService<IUserStore<MongoIdentityUser>>())
3838
{
39-
db.GetType().GenericTypeArguments.Length.ShouldBe(9);
40-
db.ShouldBeOfType<MongoUserStore<MongoIdentityUser, MongoIdentityRole, MongoIdentityDbContext, string, IdentityUserClaim<string>, IdentityUserRole<string>, IdentityUserLogin<string>, IdentityUserToken<string>, IdentityRoleClaim<string>>>();
39+
db.GetType().GenericTypeArguments.Length.Should().Be(9);
40+
db.Should().BeOfType<MongoUserStore<MongoIdentityUser, MongoIdentityRole, MongoIdentityDbContext, string, IdentityUserClaim<string>, IdentityUserRole<string>, IdentityUserLogin<string>, IdentityUserToken<string>, IdentityRoleClaim<string>>>();
4141
}
4242

4343
}
@@ -64,8 +64,8 @@ public void RegistersFullyTypedUserOnlyStoreWithMongoIdentityContext()
6464
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
6565
using (var db = scoped.ServiceProvider.GetRequiredService<IUserStore<MongoIdentityUser>>())
6666
{
67-
db.GetType().GenericTypeArguments.Length.ShouldBe(6);
68-
db.ShouldBeOfType<MongoUserOnlyStore<MongoIdentityUser, MongoIdentityDbContext, string, IdentityUserClaim<string>, IdentityUserLogin<string>, IdentityUserToken<string>>>();
67+
db.GetType().GenericTypeArguments.Length.Should().Be(6);
68+
db.Should().BeOfType<MongoUserOnlyStore<MongoIdentityUser, MongoIdentityDbContext, string, IdentityUserClaim<string>, IdentityUserLogin<string>, IdentityUserToken<string>>>();
6969
}
7070

7171
}
@@ -94,8 +94,8 @@ public void RegistersLimitedTypedUserStoreWithMongoContext()
9494
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
9595
using (var db = scoped.ServiceProvider.GetRequiredService<IUserStore<MongoIdentityUser>>())
9696
{
97-
db.GetType().GenericTypeArguments.Length.ShouldBe(4);
98-
db.ShouldBeOfType<MongoUserStore<MongoIdentityUser, MongoIdentityRole, MongoDbContext, string>>();
97+
db.GetType().GenericTypeArguments.Length.Should().Be(4);
98+
db.Should().BeOfType<MongoUserStore<MongoIdentityUser, MongoIdentityRole, MongoDbContext, string>>();
9999
}
100100

101101
}
@@ -122,8 +122,8 @@ public void RegistersLimitedTypedUserOnlyStoreWithMongoContext()
122122
using (var scoped = provider.GetRequiredService<IServiceScopeFactory>().CreateScope())
123123
using (var db = scoped.ServiceProvider.GetRequiredService<IUserStore<MongoIdentityUser>>())
124124
{
125-
db.GetType().GenericTypeArguments.Length.ShouldBe(3);
126-
db.ShouldBeOfType<MongoUserOnlyStore<MongoIdentityUser, MongoDbContext, string>>();
125+
db.GetType().GenericTypeArguments.Length.Should().Be(3);
126+
db.Should().BeOfType<MongoUserOnlyStore<MongoIdentityUser, MongoDbContext, string>>();
127127
}
128128

129129
}
@@ -141,12 +141,13 @@ public void ExtensionThrowsExceptionWithoutMongoIdentityRole()
141141
services.AddTransient<MongoIdentityDbContext, MongoIdentityDbContext>();
142142

143143

144-
Should.Throw<InvalidOperationException>(() =>
144+
Action action = () =>
145145
{
146146
services
147147
.AddIdentity<MongoIdentityUser, IdentityRole>()
148148
.AddMongoFrameworkStores<MongoIdentityDbContext>();
149-
});
149+
};
150+
action.Should().Throw<InvalidOperationException>();
150151
}
151152

152153
[Fact]
@@ -162,12 +163,13 @@ public void ExtensionThrowsExceptionWithoutMongoIdentityUser()
162163
services.AddTransient<MongoIdentityDbContext, MongoIdentityDbContext>();
163164

164165

165-
Should.Throw<InvalidOperationException>(() =>
166+
Action action = () =>
166167
{
167168
services
168169
.AddIdentity<IdentityUser, MongoIdentityRole>()
169170
.AddMongoFrameworkStores<MongoIdentityDbContext>();
170-
});
171+
};
172+
action.Should().Throw<InvalidOperationException>();
171173
}
172174

173175

tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityContextsTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using System.Threading.Tasks;
44
using MongoDB.Bson;
55
using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses;
6-
using Shouldly;
6+
using AwesomeAssertions;
77
using Xunit;
88

99
namespace MongoEntityFramework.AspNetCore.Identity.Tests
@@ -49,8 +49,8 @@ public void ContextWithRolesLoadsRoles()
4949

5050
var store = new MongoRoleStore<MongoIdentityRole, MongoIdentityDbContext>(context);
5151

52-
store.Context.ShouldBeOfType<MongoIdentityDbContext>();
53-
store.Roles.Count().ShouldBe(3);
52+
store.Context.Should().BeOfType<MongoIdentityDbContext>();
53+
store.Roles.Count().Should().Be(3);
5454
}
5555

5656
[Fact]
@@ -60,8 +60,8 @@ public void ContextWithUsersLoadsUsers()
6060

6161
var store = new MongoUserOnlyStore<MongoIdentityUser, MongoIdentityUserContext>(context);
6262

63-
store.Context.ShouldBeOfType<MongoIdentityUserContext>();
64-
store.Users.Count().ShouldBe(1);
63+
store.Context.Should().BeOfType<MongoIdentityUserContext>();
64+
store.Users.Count().Should().Be(1);
6565
}
6666

6767
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityRoleTests.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Microsoft.AspNetCore.Identity;
4-
using Shouldly;
4+
using AwesomeAssertions;
55
using Xunit;
66

77
namespace MongoEntityFramework.AspNetCore.Identity.Tests
@@ -13,43 +13,44 @@ public void ConstructorCreatesEmptyLists()
1313
{
1414
var role = new MongoIdentityRole();
1515

16-
role.Claims.ShouldNotBeNull();
17-
role.Claims.Count.ShouldBe(0);
16+
role.Claims.Should().NotBeNull();
17+
role.Claims.Count.Should().Be(0);
1818
}
1919

2020
[Fact]
2121
public void ConstructorSucceedsWithValidUserName()
2222
{
2323
var role = new MongoIdentityRole("role-name");
2424

25-
role.Name.ShouldBe("role-name");
26-
role.NormalizedName.ShouldBe("ROLE-NAME");
27-
role.ToString().ShouldBe("role-name");
25+
role.Name.Should().Be("role-name");
26+
role.NormalizedName.Should().Be("ROLE-NAME");
27+
role.ToString().Should().Be("role-name");
2828
}
2929

3030
[Fact]
3131
public void ConstructorThrowsExceptionWithNullUserName()
3232
{
33-
Should.Throw<ArgumentNullException>(() =>
33+
Action action = () =>
3434
{
3535
_ = new MongoIdentityRole(null);
36-
});
36+
};
37+
action.Should().Throw<ArgumentNullException>();
3738
}
3839

3940
[Fact]
4041
public void KeyTypeIsUsedInCollectionsWithInteger()
4142
{
4243
var role = new MongoIdentityRole<int>();
4344

44-
role.Claims.ShouldBeOfType<List<IdentityRoleClaim<int>>>();
45+
role.Claims.Should().BeOfType<List<IdentityRoleClaim<int>>>();
4546
}
4647

4748
[Fact]
4849
public void KeyTypeIsUsedInCollectionsWithGuid()
4950
{
5051
var role = new MongoIdentityRole<Guid>();
5152

52-
role.Claims.ShouldBeOfType<List<IdentityRoleClaim<Guid>>>();
53+
role.Claims.Should().BeOfType<List<IdentityRoleClaim<Guid>>>();
5354
}
5455

5556
}

tests/MongoFramework.AspNetCore.Identity.Tests/MongoIdentityUserTests.cs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Microsoft.AspNetCore.Identity;
4-
using Shouldly;
4+
using AwesomeAssertions;
55
using Xunit;
66

77
namespace MongoEntityFramework.AspNetCore.Identity.Tests
@@ -13,53 +13,54 @@ public void ConstructorCreatesEmptyLists()
1313
{
1414
var user = new MongoIdentityUser();
1515

16-
user.Claims.ShouldNotBeNull();
17-
user.Roles.ShouldNotBeNull();
18-
user.Tokens.ShouldNotBeNull();
19-
user.Logins.ShouldNotBeNull();
16+
user.Claims.Should().NotBeNull();
17+
user.Roles.Should().NotBeNull();
18+
user.Tokens.Should().NotBeNull();
19+
user.Logins.Should().NotBeNull();
2020

21-
user.Claims.Count.ShouldBe(0);
22-
user.Roles.Count.ShouldBe(0);
23-
user.Tokens.Count.ShouldBe(0);
24-
user.Logins.Count.ShouldBe(0);
21+
user.Claims.Count.Should().Be(0);
22+
user.Roles.Count.Should().Be(0);
23+
user.Tokens.Count.Should().Be(0);
24+
user.Logins.Count.Should().Be(0);
2525
}
2626

2727
[Fact]
2828
public void ConstructorSucceedsWithValidUserName()
2929
{
3030
var user = new MongoIdentityUser("username");
3131

32-
user.UserName.ShouldBe("username");
33-
user.NormalizedUserName.ShouldBe("USERNAME");
32+
user.UserName.Should().Be("username");
33+
user.NormalizedUserName.Should().Be("USERNAME");
3434
}
3535

3636
[Fact]
3737
public void ConstructorThrowsExceptionWithNullUserName()
3838
{
39-
Should.Throw<ArgumentNullException>(() =>
39+
Action action = () =>
4040
{
4141
_ = new MongoIdentityUser(null);
42-
});
42+
};
43+
action.Should().Throw<ArgumentNullException>();
4344
}
4445

4546
[Fact]
4647
public void KeyTypeIsUsedInCollectionsWithInteger()
4748
{
4849
var user = new MongoIdentityUser<int>();
4950

50-
user.Claims.ShouldBeOfType<List<IdentityUserClaim<int>>>();
51-
user.Tokens.ShouldBeOfType<List<IdentityUserToken<int>>>();
52-
user.Logins.ShouldBeOfType<List<IdentityUserLogin<int>>>();
51+
user.Claims.Should().BeOfType<List<IdentityUserClaim<int>>>();
52+
user.Tokens.Should().BeOfType<List<IdentityUserToken<int>>>();
53+
user.Logins.Should().BeOfType<List<IdentityUserLogin<int>>>();
5354
}
5455

5556
[Fact]
5657
public void KeyTypeIsUsedInCollectionsWithGuid()
5758
{
5859
var user = new MongoIdentityUser<Guid>();
5960

60-
user.Claims.ShouldBeOfType<List<IdentityUserClaim<Guid>>>();
61-
user.Tokens.ShouldBeOfType<List<IdentityUserToken<Guid>>>();
62-
user.Logins.ShouldBeOfType<List<IdentityUserLogin<Guid>>>();
61+
user.Claims.Should().BeOfType<List<IdentityUserClaim<Guid>>>();
62+
user.Tokens.Should().BeOfType<List<IdentityUserToken<Guid>>>();
63+
user.Logins.Should().BeOfType<List<IdentityUserLogin<Guid>>>();
6364
}
6465

6566

tests/MongoFramework.AspNetCore.Identity.Tests/MongoRoleStoreTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
1+
using System;
22
using System.Threading.Tasks;
33
using Microsoft.EntityFrameworkCore;
44
using MongoEntityFramework.AspNetCore.Identity.Tests.TestClasses;
5-
using Shouldly;
5+
using AwesomeAssertions;
66
using Xunit;
77

88
namespace MongoEntityFramework.AspNetCore.Identity.Tests
@@ -39,7 +39,7 @@ public void ConstructorUsesMongo()
3939

4040
var store = new MongoRoleStore<MongoIdentityRole>(context);
4141

42-
store.Context.ShouldBeOfType<TestContext>();
42+
store.Context.Should().BeOfType<TestContext>();
4343
}
4444

4545
[Fact]
@@ -49,8 +49,8 @@ public void ConvertIdFromStringWithIntReturnsZero()
4949

5050
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
5151

52-
store.ConvertIdFromString(null).ShouldBe(0);
53-
store.ConvertIdFromString("12345").ShouldBe(12345);
52+
store.ConvertIdFromString(null).Should().Be(0);
53+
store.ConvertIdFromString("12345").Should().Be(12345);
5454
}
5555

5656
[Fact]
@@ -60,8 +60,8 @@ public void ConvertIdToStringWithIntReturnsNull()
6060

6161
var store = new MongoRoleStore<MongoIdentityRole<int>, DbContext, int>(context);
6262

63-
store.ConvertIdToString(0).ShouldBeNull();
64-
store.ConvertIdToString(12345).ShouldBe("12345");
63+
store.ConvertIdToString(0).Should().BeNull();
64+
store.ConvertIdToString(12345).Should().Be("12345");
6565
}
6666

6767
[Fact]
@@ -73,7 +73,7 @@ public async Task GetNormalizedRoleReturnsCorrect()
7373
var role = new MongoIdentityRole<int> { Name = "testrole", NormalizedName = "TESTROLE" };
7474
var name = await store.GetNormalizedRoleNameAsync(role);
7575

76-
name.ShouldBe("TESTROLE");
76+
name.Should().Be("TESTROLE");
7777
}
7878

7979
}

0 commit comments

Comments
 (0)