Skip to content

Commit 7565965

Browse files
committed
Updated tests (#128)
1 parent 4ffffb5 commit 7565965

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

samples/MusicStore/MusicStore.Web/Models/SampleData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ private static void CreateAdminUser(IServiceProvider serviceProvider)
9595
// await roleManager.CreateAsync(new IdentityRole(adminRole));
9696
//}
9797

98-
var user = userManager.FindByNameAsync(configuration[defaultAdminUserName]).GetAwaiter().GetResult();
98+
var user = userManager.FindByNameAsync(configuration[defaultAdminUserName]).ConfigureAwait(false).GetAwaiter().GetResult();
9999
if (user == null)
100100
{
101101
user = new ApplicationUser { UserName = configuration[defaultAdminUserName] };
102-
userManager.CreateAsync(user, configuration[defaultAdminPassword]).GetAwaiter().GetResult();
102+
userManager.CreateAsync(user, configuration[defaultAdminPassword]).ConfigureAwait(false).GetAwaiter().GetResult();
103103
//await userManager.AddToRoleAsync(user, adminRole);
104-
userManager.AddClaimAsync(user, new Claim("ManageStore", "Allowed")).GetAwaiter().GetResult();
104+
userManager.AddClaimAsync(user, new Claim("ManageStore", "Allowed")).ConfigureAwait(false).GetAwaiter().GetResult();
105105
}
106106

107107
#if TESTING
@@ -111,10 +111,10 @@ private static void CreateAdminUser(IServiceProvider serviceProvider)
111111
for (int i = 0; i < 100; ++i)
112112
{
113113
var email = string.Format("User{0:D3}@example.com", i);
114-
var normalUser = userManager.FindByEmailAsync(email).GetAwaiter().GetResult();
114+
var normalUser = userManager.FindByEmailAsync(email).ConfigureAwait(false).GetAwaiter().GetResult();
115115
if (normalUser == null)
116116
{
117-
userManager.CreateAsync(new ApplicationUser { UserName = email, Email = email }, "Password~!1").GetAwaiter().GetResult();
117+
userManager.CreateAsync(new ApplicationUser { UserName = email, Email = email }, "Password~!1").ConfigureAwait(false).GetAwaiter().GetResult();
118118
}
119119
}
120120
}

test/MyTested.AspNetCore.Mvc.Caching.Test/ServicesTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public void MockedMemoryCacheShouldBeDifferentForEveryCallAsynchronously()
188188

189189
MyMvc.IsUsingDefaultConfiguration();
190190
})
191+
.ConfigureAwait(false)
191192
.GetAwaiter()
192193
.GetResult();
193194
}

test/MyTested.AspNetCore.Mvc.Core.Test/ServicesTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ public void IHttpContextAccessorShouldWorkCorrectlyAsynchronously()
690690
Assert.NotSame(fourthContextAsync, fifthContextAsync);
691691
Assert.NotSame(thirdContextAsync, fifthContextAsync);
692692
})
693+
.ConfigureAwait(false)
693694
.GetAwaiter()
694695
.GetResult();
695696

@@ -855,6 +856,7 @@ public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
855856
Assert.NotSame(fourthContextAsync, fifthContextAsync);
856857
Assert.NotSame(thirdContextAsync, fifthContextAsync);
857858
})
859+
.ConfigureAwait(false)
858860
.GetAwaiter()
859861
.GetResult();
860862

test/MyTested.AspNetCore.Mvc.Licensing.Test/MyTestedMvcLicensingTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void WithNoLicenseExceptionShouldBeThrown()
3434

3535
await Assert.ThrowsAsync<InvalidLicenseException>(async () => await Task.WhenAll(tasks));
3636
})
37+
.ConfigureAwait(false)
3738
.GetAwaiter()
3839
.GetResult();
3940
}
@@ -72,6 +73,7 @@ public void WithLicenseNoExceptionShouldBeThrown()
7273

7374
await Task.WhenAll(tasks);
7475
})
76+
.ConfigureAwait(false)
7577
.GetAwaiter()
7678
.GetResult();
7779

@@ -109,6 +111,7 @@ public void WithMultipleLicensesNoExceptionShouldBeThrown()
109111

110112
await Task.WhenAll(tasks);
111113
})
114+
.ConfigureAwait(false)
112115
.GetAwaiter()
113116
.GetResult();
114117

test/MyTested.AspNetCore.Mvc.Licensing.Test/TestCounterTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void IncrementAndValidateShouldThrowExceptionWithNoLicense()
3737
caughtException = ex;
3838
}
3939
})
40+
.ConfigureAwait(false)
4041
.GetAwaiter()
4142
.GetResult();
4243

@@ -75,6 +76,7 @@ public void IncrementAndValidateShouldThrowExceptionWithInvalidLicense()
7576
caughtException = ex;
7677
}
7778
})
79+
.ConfigureAwait(false)
7880
.GetAwaiter()
7981
.GetResult();
8082

@@ -113,6 +115,7 @@ public void IncrementAndValidateShouldNotThrowExceptionWithValidLicense()
113115
caughtException = ex;
114116
}
115117
})
118+
.ConfigureAwait(false)
116119
.GetAwaiter()
117120
.GetResult();
118121

0 commit comments

Comments
 (0)