1027 references to ThrowsAsync
Aspire.Dashboard.Tests (8)
Integration\OtlpGrpcServiceTests.cs (7)
64var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest()).ResponseAsync).DefaultTimeout(); 91var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest(), metadata).ResponseAsync).DefaultTimeout(); 228var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest(), metadata).ResponseAsync).DefaultTimeout(); 257var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest()).ResponseAsync).DefaultTimeout(); 282var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest()).ResponseAsync).DefaultTimeout(); 361var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest()).ResponseAsync).DefaultTimeout(); 400var ex = await Assert.ThrowsAsync<RpcException>(() => client.ExportAsync(new ExportLogsServiceRequest()).ResponseAsync).DefaultTimeout();
Model\DashboardClientTests.cs (1)
106await Assert.ThrowsAsync<ObjectDisposedException>(() => client.SubscribeResourcesAsync(CancellationToken.None)).DefaultTimeout();
Aspire.Hosting.Nats.Tests (1)
NatsFunctionalTests.cs (1)
149var exception = await Assert.ThrowsAsync<NatsException>(async () => await natsConnection.ConnectAsync());
Aspire.Hosting.Testing.Tests (9)
PublicApiTests.cs (3)
14var ane = await Assert.ThrowsAsync<ArgumentNullException>(() => DistributedApplicationTestingBuilder.CreateAsync(entryPoint: null!)); 27var ane = await Assert.ThrowsAsync<ArgumentNullException>(action); 40var ane = await Assert.ThrowsAsync<ArgumentNullException>(action);
TestingBuilderTests.cs (4)
68var ioe = await Assert.ThrowsAsync<InvalidOperationException>(() => DistributedApplicationTestingBuilder.CreateAsync(typeof(Microsoft.Extensions.Logging.ConsoleLoggerExtensions))); 258var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => app.StartAsync().WaitAsync(cts.Token)); 262exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await app.DisposeAsync().AsTask().WaitAsync(cts.Token)); 275var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await app.DisposeAsync().AsTask().WaitAsync(cts.Token));
TestingFactoryCrashTests.cs (2)
27var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => factory.StartAsync().WaitAsync(cts.Token)); 38var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => factory.DisposeAsync().AsTask().WaitAsync(cts.Token));
Aspire.Hosting.Tests (14)
DistributedApplicationTests.cs (5)
55var ex = await Assert.ThrowsAsync<DistributedApplicationException>(async () => 96var ex = await Assert.ThrowsAsync<DistributedApplicationException>(async () => 659var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => app.StartAsync()).DefaultTimeout(); 678var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => app.StartAsync()).DefaultTimeout(); 851var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => app.StartAsync()).DefaultTimeout();
HealthCheckTests.cs (3)
29var ex = await Assert.ThrowsAsync<DistributedApplicationException>(async () => 51var ex = await Assert.ThrowsAsync<DistributedApplicationException>(async () => 117var ex = await Assert.ThrowsAsync<OptionsValidationException>(async () =>
ResourceNotificationTests.cs (3)
257await Assert.ThrowsAsync<OperationCanceledException>(async () => 272await Assert.ThrowsAsync<OperationCanceledException>(async () => 289await Assert.ThrowsAsync<OperationCanceledException>(async () =>
WithEnvironmentTests.cs (1)
146var exception = await Assert.ThrowsAsync<DistributedApplicationException>(async () => await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(
WithReferenceTests.cs (2)
137await Assert.ThrowsAsync<DistributedApplicationException>(async () => 170var exception = await Assert.ThrowsAsync<DistributedApplicationException>(async () =>
Binding.ReliableSession.IntegrationTests (2)
NetHttpBindingTests.cs (1)
244await Assert.ThrowsAsync<CommunicationException>(() => resultTask);
WSHttpBindingTests.cs (1)
244await Assert.ThrowsAsync<CommunicationException>(() => resultTask);
Diagnostics.EFCore.FunctionalTests (3)
DatabaseErrorPageMiddlewareTest.cs (2)
80var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => 106var ex = await Assert.ThrowsAsync<DbUpdateException>(async () =>
MigrationsEndPointMiddlewareTest.cs (1)
261var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
IIS.FunctionalTests (4)
Http3Tests.cs (4)
123var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address)); 139var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); 156var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); 170var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
InMemory.FunctionalTests (66)
ChunkedRequestTests.cs (1)
979await Assert.ThrowsAsync<InvalidOperationException>(async () => await request.BodyReader.ReadAsync());
Http2\Http2StreamTests.cs (18)
1148thrownEx = await Assert.ThrowsAsync<IOException>(async () => 1183thrownEx = await Assert.ThrowsAsync<IOException>(async () => 1218thrownEx = await Assert.ThrowsAsync<IOException>(async () => 1254thrownEx = await Assert.ThrowsAsync<IOException>(async () => 1908exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 1993exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 2054exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 3796await Assert.ThrowsAsync<OperationCanceledException>(() => context.Response.WriteAsync("hello,", new CancellationToken(true))); 3833await Assert.ThrowsAsync<OperationCanceledException>(() => writeTask); 4671writeEx = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.WriteAsync("")); 4867var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.CompleteAsync().DefaultTimeout()); 4990var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.WriteAsync("2 Hello World").DefaultTimeout()); 5049var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.WriteAsync("2 Hello World").DefaultTimeout()); 5315var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.CompleteAsync().DefaultTimeout()); 5545await Assert.ThrowsAsync<TaskCanceledException>(async () => await requestBodyTask); 5546await Assert.ThrowsAsync<ConnectionAbortedException>(async () => await context.Request.BodyReader.ReadAsync()); 5713await Assert.ThrowsAsync<TaskCanceledException>(async () => await requestBodyTask); 5714await Assert.ThrowsAsync<ConnectionAbortedException>(async () => await context.Request.BodyReader.ReadAsync());
Http2\Http2WebSocketTests.cs (4)
456var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1] { 0x00 }).AsTask()); 458ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.BodyWriter.WriteAsync(new byte[1] { 0x00 }).AsTask()); 465ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1] { 0x00 }).AsTask()); 467ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.BodyWriter.WriteAsync(new byte[1] { 0x00 }).AsTask());
Http3\Http3StreamTests.cs (12)
1242var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.CompleteAsync().DefaultTimeout()); 1345var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.WriteAsync("2 Hello World").DefaultTimeout()); 1397var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.WriteAsync("2 Hello World").DefaultTimeout()); 1604var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.CompleteAsync().DefaultTimeout()); 1787await Assert.ThrowsAsync<TaskCanceledException>(async () => await requestBodyTask); 1788await Assert.ThrowsAsync<ConnectionAbortedException>(async () => await context.Request.BodyReader.ReadAsync()); 1916await Assert.ThrowsAsync<TaskCanceledException>(async () => await requestBodyTask); 1917await Assert.ThrowsAsync<ConnectionAbortedException>(async () => await context.Request.BodyReader.ReadAsync()); 2078var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => readTrailersTcs.Task).DefaultTimeout(); 2542exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 2614exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 2667exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () =>
HttpsConnectionMiddlewareTests.cs (5)
428await Assert.ThrowsAsync<IOException>(() => 490await Assert.ThrowsAsync<IOException>(() => 642await Assert.ThrowsAsync<PlatformNotSupportedException>(() => context.Connection.GetClientCertificateAsync()); 902var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Connection.GetClientCertificateAsync()); 1086var ioe = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Connection.GetClientCertificateAsync());
HttpsTests.cs (1)
560var ex = await Assert.ThrowsAsync<IOException>(async () =>
KestrelMetricsTests.cs (1)
900await Assert.ThrowsAsync<HttpRequestException>(() => httpClient.SendAsync(httpRequestMessage));
MaxRequestBodySizeTests.cs (10)
36requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>( 76BadHttpRequestException requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 123BadHttpRequestException requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 179requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>( 377requestRejectedEx1 = await Assert.ThrowsAsync<BadHttpRequestException>( 379requestRejectedEx2 = await Assert.ThrowsAsync<BadHttpRequestException>( 425requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 534requestRejectedEx = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 590requestRejectedEx1 = await Assert.ThrowsAsync<BadHttpRequestException>( 592requestRejectedEx2 = await Assert.ThrowsAsync<BadHttpRequestException>(
RequestTests.cs (1)
1965await Assert.ThrowsAsync<InvalidOperationException>(async () => await request.BodyReader.ReadAsync());
ResponseTests.cs (8)
206await Assert.ThrowsAsync<OperationCanceledException>(() => appTcs.Task).DefaultTimeout(); 485readException = await Assert.ThrowsAsync<BadHttpRequestException>( 703var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => responseWriteTcs.Task).DefaultTimeout(); 781var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => responseWriteTcs.Task).DefaultTimeout(); 819var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => responseWriteTcs.Task).DefaultTimeout(); 861var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => responseWriteTcs.Task).DefaultTimeout(); 2493var writeException = await Assert.ThrowsAsync<ObjectDisposedException>(async () => await response.BodyWriter.FlushAsync()); 3846writeEx = await Assert.ThrowsAsync<InvalidOperationException>(() => httpContext.Response.WriteAsync("test"));
UpgradeTests.cs (5)
31var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1], 0, 1)); 34await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.BodyWriter.WriteAsync(new byte[1]).AsTask()); 154var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.DefaultTimeout()); 296var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task).DefaultTimeout(); 347var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(60)));
InProcessWebSite (1)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.WebSockets.cs (1)
101var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => upgradeFeature.UpgradeAsync());
Interop.FunctionalTests (18)
Http3\Http3RequestTests.cs (6)
521var serverEx = await Assert.ThrowsAsync<IOException>(() => serverReadTask).DefaultTimeout(); 571var ex = await Assert.ThrowsAsync<HttpRequestException>(() => sendTask).DefaultTimeout(); 587var serverEx = await Assert.ThrowsAsync<ConnectionAbortedException>(() => serverReadTask).DefaultTimeout(); 627var ex = await Assert.ThrowsAsync<HttpRequestException>(async () => 1046var serverEx = await Assert.ThrowsAsync<IOException>(() => serverReadTask).DefaultTimeout(); 1901await Assert.ThrowsAsync<HttpRequestException>(() => responseTask).DefaultTimeout();
Http3\Http3TlsTests.cs (1)
281var exception = await Assert.ThrowsAsync<NotSupportedException>(() =>
HttpClientHttp2InteropTests.cs (11)
599var exception = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(url)).DefaultTimeout(); 628var exception = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()).DefaultTimeout(); 741var responseEx = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync().DefaultTimeout()); 743await Assert.ThrowsAsync<HttpProtocolException>(() => streamingContent.SendAsync("Hello World").DefaultTimeout()); 800var responseEx = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync().DefaultTimeout()); 802await Assert.ThrowsAsync<HttpProtocolException>(() => streamingContent.SendAsync("Hello World").DefaultTimeout()); 825var ex = await Assert.ThrowsAsync<IOException>(() => readTask).DefaultTimeout(); 872var ex = await Assert.ThrowsAsync<IOException>(() => readTask).DefaultTimeout(); 936await Assert.ThrowsAsync<TaskCanceledException>(() => requestTask).DefaultTimeout(); 1370var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.SendAsync(request).DefaultTimeout()); 1401var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(url)).DefaultTimeout();
Microsoft.AspNetCore.Authentication.Core.Test (10)
AuthenticationServiceTests.cs (10)
23var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.AuthenticateAsync("missing")); 62var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.ChallengeAsync("missing")); 77var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.ForbidAsync("missing")); 91var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("signin", new ClaimsPrincipal(), null)); 124var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("base", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null)); 128ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("signout", new ClaimsPrincipal(new ClaimsIdentity("whatever")), null)); 147var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync("base")); 168var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync()); 170ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever")))); 225var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal(new ClaimsIdentity("whatever"))));
Microsoft.AspNetCore.Authentication.Negotiate.Test (9)
EventTests.cs (2)
88var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => 136var ex = await Assert.ThrowsAsync<Exception>(() =>
NegotiateHandlerTests.cs (6)
29var ex = await Assert.ThrowsAsync<NotSupportedException>(() => SendAsync(server, "/Anonymous1", connection: null)); 94var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => SendAsync(server, "/404", testConnection)); 104var ex = await Assert.ThrowsAsync<TrueException>(() => SendAsync(server, "/404", new TestConnection(), "Negotiate ClientNtlmBlob2")); 322var ex = await Assert.ThrowsAsync<Exception>(() => SendAsync(server, "/404", testConnection, "Negotiate OtherError")); 471return Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 476return Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync());
ServerDeferralTests.cs (1)
28var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await CreateHostAsync(supportsAuth: true, isEnabled: false));
Microsoft.AspNetCore.Authentication.Test (70)
CookieTests.cs (3)
306await Assert.ThrowsAsync<InvalidOperationException>(async () => await SendAsync(server, "http://example.com/testpath")); 319await Assert.ThrowsAsync<InvalidOperationException>(async () => await SendAsync(server, "http://example.com/testpath")); 1277await Assert.ThrowsAsync<InvalidOperationException>(() => context.ChallengeAsync(CookieAuthenticationDefaults.AuthenticationScheme));
DynamicSchemeTests.cs (4)
63await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth/One")); 80await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth/Two")); 87await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth/Two")); 88await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("http://example.com/auth/One"));
GoogleTests.cs (3)
1206await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("Google", new ClaimsPrincipal())); 1210await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync("Google")); 1214await Assert.ThrowsAsync<InvalidOperationException>(() => context.ForbidAsync("Google"));
JwtBearerTests.cs (5)
614var exception = await Assert.ThrowsAsync<Exception>(delegate 686var exception = await Assert.ThrowsAsync<Exception>(delegate 758var exception = await Assert.ThrowsAsync<Exception>(delegate 1222await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); 1226await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme));
JwtBearerTests_Handler.cs (5)
575var exception = await Assert.ThrowsAsync<Exception>(delegate 641var exception = await Assert.ThrowsAsync<Exception>(delegate 707var exception = await Assert.ThrowsAsync<Exception>(delegate 1289await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(JwtBearerDefaults.AuthenticationScheme, new ClaimsPrincipal())); 1293await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync(JwtBearerDefaults.AuthenticationScheme));
MicrosoftAccountTests.cs (3)
398await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("Microsoft", new ClaimsPrincipal())); 402await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync("Microsoft")); 406await Assert.ThrowsAsync<InvalidOperationException>(() => context.ForbidAsync("Microsoft"));
OAuthTests.cs (2)
466var exception = await Assert.ThrowsAsync<AuthenticationFailureException>( 507var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(
OpenIdConnect\OpenIdConnectChallengeTests.cs (4)
470var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(ChallengeEndpoint)); 756var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(ChallengeEndpoint)); 779var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(ChallengeEndpoint)); 964await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(ChallengeEndpoint));
OpenIdConnect\OpenIdConnectConfigurationTests.cs (6)
68await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 97await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 301await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 356await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 416await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 576var exception = await Assert.ThrowsAsync<T>(() => BuildTestServer(options).SendAsync(@"https://example.com"));
OpenIdConnect\OpenIdConnectEventTests.cs (7)
67var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 136var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 245var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 351var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 459var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 569var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 693var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate
OpenIdConnect\OpenIdConnectEventTests_Handler.cs (7)
67var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 136var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 245var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 351var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 459var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 569var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate 693var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(delegate
OpenIdConnect\OpenIdConnectTests.cs (1)
297var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(DefaultHost + TestServerBuilder.Signout));
RemoteAuthenticationTests.cs (3)
69var error = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("https://example.com/challenge")); 82var error = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("https://example.com/challenge")); 97var error = await Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync("https://example.com/challenge"));
SharedAuthenticationTests.cs (8)
67await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync()); 77await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 367await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync()); 377await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 436await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync()); 446await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal())); 510await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync()); 520await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync(new ClaimsPrincipal()));
TwitterTests.cs (5)
295var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => 325await Assert.ThrowsAsync<HttpRequestException>(async () => 549await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignInAsync("Twitter", new ClaimsPrincipal())); 553await Assert.ThrowsAsync<InvalidOperationException>(() => context.SignOutAsync("Twitter")); 557await Assert.ThrowsAsync<InvalidOperationException>(() => context.ForbidAsync("Twitter"));
WsFederation\WsFederationTest.cs (2)
65var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("/")); 146var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(() => httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form));
WsFederation\WsFederationTest_Handler.cs (2)
63var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("/")); 144var exception = await Assert.ThrowsAsync<AuthenticationFailureException>(() => httpClient.PostAsync(httpClient.BaseAddress + "signin-wsfed", form));
Microsoft.AspNetCore.Authorization.Test (2)
DefaultAuthorizationServiceTests.cs (2)
30await Assert.ThrowsAsync<InvalidOperationException>(() => AuthorizationPolicy.CombineAsync(provider, new AuthorizeAttribute[] { 340var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => authorizationService.AuthorizeAsync(new ClaimsPrincipal(), "whatever", "BogusPolicy"));
Microsoft.AspNetCore.Components.Endpoints.Tests (1)
RazorComponentResultTest.cs (1)
251var ex = await Assert.ThrowsAsync<InvalidOperationException>(
Microsoft.AspNetCore.Components.Server.Tests (12)
Circuits\RemoteJSDataStreamTest.cs (7)
114var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 133ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 152ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 172ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 196ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 232var ex = await Assert.ThrowsAsync<TimeoutException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout()); 281var ex = await Assert.ThrowsAsync<TimeoutException>(async () => await remoteJSDataStream.CopyToAsync(mem).DefaultTimeout());
Circuits\ServerAuthenticationStateProviderTest.cs (1)
14await Assert.ThrowsAsync<InvalidOperationException>(() =>
ProtectedBrowserStorageTest.cs (4)
177var ex = await Assert.ThrowsAsync<JsonException>( 193var ex = await Assert.ThrowsAsync<CryptographicException>( 213var ex = await Assert.ThrowsAsync<CryptographicException>( 230var ex = await Assert.ThrowsAsync<CryptographicException>(
Microsoft.AspNetCore.Components.Tests (29)
ComponentBaseTest.cs (4)
412var actual = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => renderer.RenderRootComponentAsync(componentId)); 428var actual = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => renderer.RenderRootComponentAsync(componentId)); 444var actual = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => renderer.RenderRootComponentAsync(componentId)); 460var actual = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => renderer.RenderRootComponentAsync(componentId));
EventCallbackFactoryBinderExtensionsTest.cs (1)
56await Assert.ThrowsAsync<InvalidTimeZoneException>(() =>
EventCallbackTest.cs (2)
160await Assert.ThrowsAsync<ArgumentException>(() => 268await Assert.ThrowsAsync<ArgumentException>(() =>
Lifetime\ComponentStatePersistenceManagerTest.cs (2)
53await Assert.ThrowsAsync<InvalidOperationException>(() => lifetime.RestoreStateAsync(store)); 75await Assert.ThrowsAsync<InvalidOperationException>(() => lifetime.PersistStateAsync(store, renderer));
NavigationManagerTest.cs (2)
784var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => navigationManager.RunNotifyLocationChangingAsync($"{baseUri}/subdir1", null, false)); 806var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => navigationManager.RunNotifyLocationChangingAsync($"{baseUri}/subdir1", null, false));
RendererTest.cs (14)
342await Assert.ThrowsAsync<TimeoutException>(() => renderTask1.WaitAsync(TimeSpan.FromMilliseconds(250))); 1565await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1597await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1633await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1903await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1940await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1981await Assert.ThrowsAsync<InvalidTimeZoneException>(() => task); 1991await Assert.ThrowsAsync<ArgumentException>(() => 2701await Assert.ThrowsAsync<ArgumentException>(() => 2742await Assert.ThrowsAsync<ArgumentException>(() => 2793await Assert.ThrowsAsync<ArgumentException>(() => 2828await Assert.ThrowsAsync<ArgumentException>(() => 3534var ex = await Assert.ThrowsAsync<ArgumentException>(() => 4537var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => renderer.RenderRootComponentAsync(rootComponentId));
Rendering\RendererSynchronizationContextTest.cs (4)
472await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await task); 560await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await task); 654await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await task); 742await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await task);
Microsoft.AspNetCore.Components.Web.Tests (12)
Forms\EditFormTest.cs (2)
42var ex = await Assert.ThrowsAsync<InvalidOperationException>( 56var ex = await Assert.ThrowsAsync<InvalidOperationException>(
Forms\InputBaseTest.cs (1)
33var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => InputRenderer.RenderAndGetComponent(rootComponent));
Forms\InputRadioTest.cs (1)
23var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => RenderAndGetTestInputComponentAsync(rootComponent));
HtmlRendering\HtmlRendererTest.cs (4)
29var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => resultTask); 894var ex = await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => 916var ex = await Assert.ThrowsAsync<InvalidTimeZoneException>(() => 962var ex = await Assert.ThrowsAsync<InvalidTimeZoneException>(() =>
Virtualization\VirtualizeTest.cs (4)
30var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await testRenderer.RenderRootComponentAsync(componentId)); 49var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await testRenderer.RenderRootComponentAsync(componentId)); 68var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await testRenderer.RenderRootComponentAsync(componentId)); 98var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await testRenderer.RenderRootComponentAsync(componentId));
Microsoft.AspNetCore.Components.WebAssembly.Tests (3)
PullFromJSDataStreamTest.cs (3)
72var ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await pullFromJSDataStream.CopyToAsync(mem).DefaultTimeout()); 86var ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await pullFromJSDataStream.CopyToAsync(mem).DefaultTimeout()); 100var ex = await Assert.ThrowsAsync<EndOfStreamException>(async () => await pullFromJSDataStream.CopyToAsync(mem).DefaultTimeout());
Microsoft.AspNetCore.Components.WebView.Test (1)
WebViewManagerTests.cs (1)
108var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await webViewManager.AddRootComponentAsync(typeof(MyComponent), arbitraryComponentSelector, ParameterView.Empty));
Microsoft.AspNetCore.ConcurrencyLimiter.Tests (2)
MiddlewareTests.cs (2)
119await Assert.ThrowsAsync<DivideByZeroException>(() => middleware.Invoke(new DefaultHttpContext())).DefaultTimeout(); 164await Assert.ThrowsAsync<DivideByZeroException>(() => middleware.Invoke(context)).DefaultTimeout();
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (3)
Logging\AcceptanceTests.cs (3)
569var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.GetAsync(requestPath)); 607var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.PutAsync("/error?body=true", content)); 641var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.PutAsync("/error?body=true", content));
Microsoft.AspNetCore.Diagnostics.Tests (1)
ExceptionHandlerTest.cs (1)
1161await Assert.ThrowsAsync<HttpRequestException>(async () => await server.CreateClient().GetAsync("/path"));
Microsoft.AspNetCore.HeaderPropagation.Tests (2)
HeaderPropagationIntegrationTest.cs (2)
90var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => client.GetAsync("http://localhost/")); 164var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync());
Microsoft.AspNetCore.HostFiltering.Tests (1)
HostFilteringMiddlewareTests.cs (1)
34await Assert.ThrowsAsync<InvalidOperationException>(() => host.GetTestServer().SendAsync(_ => { }));
Microsoft.AspNetCore.Hosting.Tests (6)
WebHostBuilderTests.cs (3)
1297var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => 1354var startEx = await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync()); 1379var startEx = await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync());
WebHostTests.cs (3)
27var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => CreateBuilder().Build().StartAsync()); 471await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync()); 691await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync());
Microsoft.AspNetCore.Hosting.WindowsServices.Tests (2)
WebHostServiceTests.cs (2)
29await Assert.ThrowsAsync<TaskCanceledException>( 43await Assert.ThrowsAsync<TaskCanceledException>(
Microsoft.AspNetCore.Http.Abstractions.Tests (9)
MapPathMiddlewareTests.cs (1)
191await Assert.ThrowsAsync<NotImplementedException>(() => app.Invoke(context));
UseExtensionsTests.cs (3)
57throw await Assert.ThrowsAsync<Exception>(() => next()); 61throw await Assert.ThrowsAsync<Exception>(() => next(context)); 73var ex = await Assert.ThrowsAsync<Exception>(() => builder.Build().Invoke(context));
UseMiddlewareTest.cs (5)
126var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => app(new DefaultHttpContext())); 140var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => app(new DefaultHttpContext())); 165var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => app(new DefaultHttpContext())); 227var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => 244var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
Microsoft.AspNetCore.Http.Connections.Tests (5)
HttpConnectionManagerTests.cs (5)
134var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await connection.Transport.Input.ReadAsync()); 325var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await firstTask.DefaultTimeout()); 328exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await secondTask.DefaultTimeout()); 352await Assert.ThrowsAsync<TaskCanceledException>(async () => await firstTask.DefaultTimeout()); 353await Assert.ThrowsAsync<TaskCanceledException>(async () => await secondTask.DefaultTimeout());
Microsoft.AspNetCore.Http.Extensions.Tests (40)
HttpRequestJsonExtensionsTests.cs (5)
42var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync<int>()); 57var ex = await Assert.ThrowsAsync<JsonException>(async () => await context.Request.ReadFromJsonAsync<int>()); 150await Assert.ThrowsAsync<TaskCanceledException>(async () => await readTask); 161var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync<object>()); 205var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Request.ReadFromJsonAsync(typeof(object)));
HttpResponseJsonExtensionsTests.cs (3)
138await Assert.ThrowsAsync<TaskCanceledException>(async () => await writeTask); 207await Assert.ThrowsAsync<ArgumentNullException>(async () => await context.Response.WriteAsJsonAsync(value: null, type: null!)); 219await Assert.ThrowsAsync<ArgumentNullException>(async () => await HttpResponseJsonExtensions.WriteAsJsonAsync(response: null!, value: null, typeof(int?)));
RequestDelegateFactoryTests.cs (3)
761var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => requestDelegate(httpContext)); 1162var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => requestDelegateResult.RequestDelegate(httpContext)); 1758await Assert.ThrowsAsync<InvalidOperationException>(() => requestDelegate(httpContext));
RequestDelegateFactoryTests.FormMapping.cs (5)
58var exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => await requestDelegate(httpContext)); 105var exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => await requestDelegate(httpContext)); 153var exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => await requestDelegate(httpContext)); 171var anotherException = await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await requestDelegate(httpContext)); 280var exception = await Assert.ThrowsAsync<BadHttpRequestException>(async () => await requestDelegate(httpContext));
RequestDelegateGenerator\CompileTimeCreationTests.cs (3)
46var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => endpoint.RequestDelegate(httpContext)); 458var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await endpoint.RequestDelegate(httpContext)); 475_ = await Assert.ThrowsAsync<NullReferenceException>(async () => await endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.BindAsync.cs (3)
103var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 132var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 197var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.cs (2)
283await Assert.ThrowsAsync<InvalidOperationException>(() => endpoint.RequestDelegate(httpContext)); 314await Assert.ThrowsAsync<InvalidOperationException>(() => endpoints[0].RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.Forms.cs (2)
335var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => request); 1004var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBodyOrService.cs (1)
202var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.KeyServices.cs (2)
127var exception = await Assert.ThrowsAsync<InvalidOperationException>( 225var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.Logging.cs (8)
152var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 191var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 269var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 348var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 392var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => request); 441var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => request); 563var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext)); 642var badHttpRequestException = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate(httpContext));
RequestDelegateGenerator\RequestDelegateCreationTests.TryParse.cs (1)
283await Assert.ThrowsAsync<NotImplementedException>(async () => await endpoint.RequestDelegate(httpContext));
SendFileResponseExtensionsTests.cs (2)
15return Assert.ThrowsAsync<FileNotFoundException>(() => response.SendFileAsync("foo")); 69await Assert.ThrowsAsync<OperationCanceledException>(
Microsoft.AspNetCore.Http.Results.Tests (16)
LocalRedirectResultTests.cs (2)
92var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => result.ExecuteAsync(httpContext)); 113var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => result.ExecuteAsync(httpContext));
ResultsOfTTests.Generated.cs (10)
75await Assert.ThrowsAsync<ArgumentNullException>(async () => 94await Assert.ThrowsAsync<InvalidOperationException>(async () => 290await Assert.ThrowsAsync<ArgumentNullException>(async () => 309await Assert.ThrowsAsync<InvalidOperationException>(async () => 574await Assert.ThrowsAsync<ArgumentNullException>(async () => 593await Assert.ThrowsAsync<InvalidOperationException>(async () => 935await Assert.ThrowsAsync<ArgumentNullException>(async () => 954await Assert.ThrowsAsync<InvalidOperationException>(async () => 1381await Assert.ThrowsAsync<ArgumentNullException>(async () => 1400await Assert.ThrowsAsync<InvalidOperationException>(async () =>
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (3)
383var ex = await Assert.ThrowsAsync<NotSupportedException>( 405await Assert.ThrowsAsync<DirectoryNotFoundException>( 418await Assert.ThrowsAsync<FileNotFoundException>(
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (1)
478var ex = await Assert.ThrowsAsync<FileNotFoundException>(() => ExecuteAsync(httpContext, path, "text/plain"));
Microsoft.AspNetCore.Http.Tests (8)
ApplicationBuilderTests.cs (1)
69var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => app.Invoke(httpContext));
Features\FormFeatureTests.cs (6)
41var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 468var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 492var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 516var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 540var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync()); 608var exception = await Assert.ThrowsAsync<InvalidDataException>(() => context.Request.ReadFormAsync());
Internal\ReferenceReadStreamTests.cs (1)
56await Assert.ThrowsAsync<NotSupportedException>(() => stream.WriteAsync(new byte[1], 0, 1));
Microsoft.AspNetCore.HttpsPolicy.Tests (1)
HttpsRedirectionMiddlewareTests.cs (1)
312var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.SendAsync(request));
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (26)
SqlStoreTestBase.cs (1)
318await Assert.ThrowsAsync<InvalidOperationException>(async () => await manager.GetSecurityStampAsync(user));
UserOnlyTest.cs (1)
79await Assert.ThrowsAsync<InvalidOperationException>(async () => await manager.FindByEmailAsync("dupe@dupe.com"));
UserStoreTest.cs (24)
68await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.AddClaimsAsync(null, null)); 69await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.AddLoginAsync(null, null)); 70await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.AddToRoleAsync(null, null)); 71await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.GetClaimsAsync(null)); 72await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.GetLoginsAsync(null)); 73await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.GetRolesAsync(null)); 74await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.IsInRoleAsync(null, null)); 75await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.RemoveClaimsAsync(null, null)); 76await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.RemoveLoginAsync(null, null, null)); 77await Assert.ThrowsAsync<ObjectDisposedException>( 79await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.RemoveClaimsAsync(null, null)); 80await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.ReplaceClaimAsync(null, null, null)); 81await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.FindByLoginAsync(null, null)); 82await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.FindByIdAsync(null)); 83await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.FindByNameAsync(null)); 84await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.CreateAsync(null)); 85await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.UpdateAsync(null)); 86await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.DeleteAsync(null)); 87await Assert.ThrowsAsync<ObjectDisposedException>( 89await Assert.ThrowsAsync<ObjectDisposedException>(async () => await store.GetEmailConfirmedAsync(null)); 90await Assert.ThrowsAsync<ObjectDisposedException>( 92await Assert.ThrowsAsync<ObjectDisposedException>( 194await Assert.ThrowsAsync<InvalidOperationException>(async () => await manager.FindByEmailAsync("dupe@dupe.com")); 204await Assert.ThrowsAsync<InvalidOperationException>(
Microsoft.AspNetCore.Identity.FunctionalTests (1)
MapIdentityApiTests.cs (1)
235await Assert.ThrowsAsync<InvalidOperationException>(()
Microsoft.AspNetCore.Identity.Specification.Tests (4)
UserManagerSpecificationTests.cs (4)
1689var ex = await Assert.ThrowsAsync<NotSupportedException>( 1692ex = await Assert.ThrowsAsync<NotSupportedException>( 1695ex = await Assert.ThrowsAsync<NotSupportedException>( 1698ex = await Assert.ThrowsAsync<NotSupportedException>(
Microsoft.AspNetCore.Identity.Test (86)
RoleManagerTest.cs (6)
138await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.FindByIdAsync(null)); 139await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.FindByNameAsync(null)); 140await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RoleExistsAsync(null)); 141await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.CreateAsync(null)); 142await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.UpdateAsync(null)); 143await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.DeleteAsync(null));
SecurityStampValidatorTest.cs (1)
65var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => SecurityStampValidator.ValidatePrincipalAsync(context));
UserManagerTest.cs (79)
606var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => manager.CreateAsync(user)); 623var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => manager.UpdateAsync(user)); 691await Assert.ThrowsAsync<NotSupportedException>(() => manager.FindByEmailAsync(null)); 692await Assert.ThrowsAsync<NotSupportedException>(() => manager.SetEmailAsync(null, null)); 693await Assert.ThrowsAsync<NotSupportedException>(() => manager.GetEmailAsync(null)); 694await Assert.ThrowsAsync<NotSupportedException>(() => manager.IsEmailConfirmedAsync(null)); 695await Assert.ThrowsAsync<NotSupportedException>(() => manager.ConfirmEmailAsync(null, null)); 703await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.SetPhoneNumberAsync(null, null)); 704await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.SetPhoneNumberAsync(null, null)); 705await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetPhoneNumberAsync(null)); 713await Assert.ThrowsAsync<NotSupportedException>( 715await Assert.ThrowsAsync<NotSupportedException>( 724await Assert.ThrowsAsync<NotSupportedException>(() => manager.CreateAsync(null, null)); 725await Assert.ThrowsAsync<NotSupportedException>(() => manager.ChangePasswordAsync(null, null, null)); 726await Assert.ThrowsAsync<NotSupportedException>(() => manager.AddPasswordAsync(null, null)); 727await Assert.ThrowsAsync<NotSupportedException>(() => manager.RemovePasswordAsync(null)); 728await Assert.ThrowsAsync<NotSupportedException>(() => manager.CheckPasswordAsync(null, null)); 729await Assert.ThrowsAsync<NotSupportedException>(() => manager.HasPasswordAsync(null)); 739await Assert.ThrowsAsync<NotSupportedException>(() => manager.UpdateSecurityStampAsync(null)); 740await Assert.ThrowsAsync<NotSupportedException>(() => manager.GetSecurityStampAsync(null)); 741await Assert.ThrowsAsync<NotSupportedException>( 743await Assert.ThrowsAsync<NotSupportedException>( 752await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.AddLoginAsync(null, null)); 753await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.RemoveLoginAsync(null, null, null)); 754await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetLoginsAsync(null)); 755await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.FindByLoginAsync(null, null)); 763await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.AddClaimAsync(null, null)); 764await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.ReplaceClaimAsync(null, null, null)); 765await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.RemoveClaimAsync(null, null)); 766await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetClaimsAsync(null)); 801await Assert.ThrowsAsync<NotImplementedException>(() => manager.GenerateUserTokenAsync(new PocoUser(), "A", "purpose")); 898await Assert.ThrowsAsync<NotImplementedException>(() => manager.GenerateUserTokenAsync(new PocoUser(), TokenOptions.DefaultProvider, "purpose")); 906await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetTwoFactorEnabledAsync(null)); 908Assert.ThrowsAsync<NotSupportedException>(async () => await manager.SetTwoFactorEnabledAsync(null, true)); 916await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetLockoutEnabledAsync(null)); 917await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.SetLockoutEnabledAsync(null, true)); 918await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.AccessFailedAsync(null)); 919await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.IsLockedOutAsync(null)); 920await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.ResetAccessFailedCountAsync(null)); 921await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetAccessFailedCountAsync(null)); 929await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.AddToRoleAsync(null, "bogus")); 930await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.AddToRolesAsync(null, null)); 931await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.GetRolesAsync(null)); 932await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.RemoveFromRoleAsync(null, "bogus")); 933await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.RemoveFromRolesAsync(null, null)); 934await Assert.ThrowsAsync<NotSupportedException>(async () => await manager.IsInRoleAsync(null, "bogus")); 970var error = await Assert.ThrowsAsync<TException>(code); 1151await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddClaimAsync(null, null)); 1152await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddClaimsAsync(null, null)); 1153await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddLoginAsync(null, null)); 1154await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddPasswordAsync(null, null)); 1155await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddToRoleAsync(null, null)); 1156await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.AddToRolesAsync(null, null)); 1157await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.ChangePasswordAsync(null, null, null)); 1158await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GetClaimsAsync(null)); 1159await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GetLoginsAsync(null)); 1160await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GetRolesAsync(null)); 1161await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.IsInRoleAsync(null, null)); 1162await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemoveClaimAsync(null, null)); 1163await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemoveClaimsAsync(null, null)); 1164await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemoveLoginAsync(null, null, null)); 1165await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemovePasswordAsync(null)); 1166await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemoveFromRoleAsync(null, null)); 1167await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.RemoveFromRolesAsync(null, null)); 1168await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.FindByLoginAsync(null, null)); 1169await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.FindByIdAsync(null)); 1170await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.FindByNameAsync(null)); 1171await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.CreateAsync(null)); 1172await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.CreateAsync(null, null)); 1173await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.UpdateAsync(null)); 1174await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.DeleteAsync(null)); 1175await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.ReplaceClaimAsync(null, null, null)); 1176await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.UpdateSecurityStampAsync(null)); 1177await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GetSecurityStampAsync(null)); 1178await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GeneratePasswordResetTokenAsync(null)); 1179await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.ResetPasswordAsync(null, null, null)); 1180await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.GenerateEmailConfirmationTokenAsync(null)); 1181await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.IsEmailConfirmedAsync(null)); 1182await Assert.ThrowsAsync<ObjectDisposedException>(() => manager.ConfirmEmailAsync(null, null));
Microsoft.AspNetCore.InternalTesting (2)
ExceptionAssertions.cs (2)
56var ex = await Assert.ThrowsAsync<TException>(testCode).ConfigureAwait(false); 120var ex = await Assert.ThrowsAsync<TException>(testCode).ConfigureAwait(false);
Microsoft.AspNetCore.InternalTesting.Tests (6)
TaskExtensionsTest.cs (6)
17await Assert.ThrowsAsync<TimeoutException>(async () => await Task.Delay(30000, cts.Token).TimeoutAfter(TimeSpan.FromMilliseconds(50))); 37await Assert.ThrowsAsync<TimeoutException>(async () => await Task.Delay(30000, cts.Token).DefaultTimeout(TimeSpan.FromMilliseconds(50))); 45await Assert.ThrowsAsync<TimeoutException>(async () => await Task.Delay(30000, cts.Token).DefaultTimeout(50)); 53await Assert.ThrowsAsync<TimeoutException>(async () => await Task.Delay(30000, cts.Token).DefaultTimeout(50)); 72var exception = await Assert.ThrowsAsync<TimeoutException>(() => ExpectedTimeout().TimeoutAfter(TimeSpan.FromMilliseconds(30000))); 85var exception = await Assert.ThrowsAsync<TimeoutException>(() => ExpectedTimeout().TimeoutAfter(TimeSpan.FromMilliseconds(30000)));
Microsoft.AspNetCore.Mvc.Core.Test (39)
Authorization\AuthorizeFilterTest.cs (2)
63var ex = await Assert.ThrowsAsync<InvalidOperationException>( 79var ex = await Assert.ThrowsAsync<InvalidOperationException>(
FileResultHelperTest.cs (1)
130await Assert.ThrowsAsync<InvalidOperationException>(() => result.ExecuteResultAsync(actionContext));
Filters\MiddlewareFilterBuilderTest.cs (3)
100var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => pipeline(httpContext)); 214var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => pipeline(httpContext)); 282var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => pipeline(httpContext));
Filters\MiddlewareFilterTest.cs (2)
158var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await invoker.InvokeAsync()); 207var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await invoker.InvokeAsync());
Formatters\SystemTextJsonOutputFormatterTest.cs (1)
83await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => formatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.GetEncoding("utf-16")));
Infrastructure\ActionMethodExecutorTest.cs (1)
434var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => Execute(actionMethodExecutor, filterContext, withFilter).AsTask());
Infrastructure\AsyncEnumerableReaderTest.cs (2)
183var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => reader(enumerable, default)); 199await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => reader(enumerable, default));
Infrastructure\JsonResultExecutorTestBase.cs (2)
303var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => executor.ExecuteAsync(context, result)); 438await Assert.ThrowsAsync<OperationCanceledException>(() => executor.ExecuteAsync(context, result));
Infrastructure\ObjectResultExecutorTest.cs (2)
318var exception = await Assert.ThrowsAsync<InvalidOperationException>( 350var exception = await Assert.ThrowsAsync<InvalidOperationException>(
Infrastructure\SystemTextJsonResultExecutorTest.cs (1)
33await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => executor.ExecuteAsync(context, result));
LocalRedirectResultTest.cs (2)
99var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => result.ExecuteResultAsync(actionContext)); 121var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => result.ExecuteResultAsync(actionContext));
ModelBinding\Binders\BodyModelBinderTests.cs (2)
458var exception = await Assert.ThrowsAsync<IOException>(() => binder.BindModelAsync(bindingContext)); 526var exception = await Assert.ThrowsAsync<IOException>(
ModelBinding\Binders\ComplexTypeModelBinderTest.cs (1)
1017var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await binder.BindModelAsync(bindingContext));
ModelBinding\FormFileValueProviderFactoryTest.cs (3)
70var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 84var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 98var ex = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => factory.CreateValueProviderAsync(valueProviderContext));
ModelBinding\FormValueProviderFactoryTest.cs (3)
58var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 72var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 86var ex = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => factory.CreateValueProviderAsync(valueProviderContext));
ModelBinding\JQueryFormValueProviderFactoryTest.cs (3)
143var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 157var ex = await Assert.ThrowsAsync<ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext)); 171var ex = await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => factory.CreateValueProviderAsync(valueProviderContext));
Routing\AttributeRoutingTest.cs (4)
43var ex = await Assert.ThrowsAsync<RouteCreationException>(() => route.RouteAsync(routeContext)); 67var ex = await Assert.ThrowsAsync<RouteCreationException>(async () => 101var ex = await Assert.ThrowsAsync<RouteCreationException>(async () => 139var ex = await Assert.ThrowsAsync<RouteCreationException>(async () =>
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (3)
383var ex = await Assert.ThrowsAsync<NotSupportedException>( 405await Assert.ThrowsAsync<DirectoryNotFoundException>( 418await Assert.ThrowsAsync<FileNotFoundException>(
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (1)
478var ex = await Assert.ThrowsAsync<FileNotFoundException>(() => ExecuteAsync(httpContext, path, "text/plain"));
Microsoft.AspNetCore.Mvc.Core.TestCommon (5)
CommonResourceInvokerTest.cs (5)
724var thrown = await Assert.ThrowsAsync<InvalidCastException>(invoker.InvokeAsync); 1438var exception = await Assert.ThrowsAsync<DataMisalignedException>(invoker.InvokeAsync); 1474var exception = await Assert.ThrowsAsync<DataMisalignedException>(invoker.InvokeAsync); 1510var exception = await Assert.ThrowsAsync<DataMisalignedException>(invoker.InvokeAsync); 1693var exception = await Assert.ThrowsAsync<InvalidOperationException>(invoker.InvokeAsync);
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (12)
XmlDataContractSerializerInputFormatterTest.cs (6)
229await Assert.ThrowsAsync<XmlException>(() => formatter.ReadAsync(context)); 357await Assert.ThrowsAsync<XmlException>(() => formatter.ReadAsync(context)); 426await Assert.ThrowsAsync<InputFormatterException>(async () => await formatter.ReadAsync(context)); 442await Assert.ThrowsAsync<InputFormatterException>(async () => await formatter.ReadAsync(context)); 615await Assert.ThrowsAsync<InputFormatterException>(async () => await formatter.ReadAsync(context)); 674await Assert.ThrowsAsync<InputFormatterException>(async () => await formatter.ReadAsync(context));
XmlDataContractSerializerOutputFormatterTest.cs (2)
473await Assert.ThrowsAsync<SerializationException>(async () => await formatter.WriteAsync(outputFormatterContext)); 490await Assert.ThrowsAsync<SerializationException>(async () => await formatter.WriteAsync(outputFormatterContext));
XmlSerializerInputFormatterTest.cs (4)
182await Assert.ThrowsAsync<XmlException>(() => formatter.ReadAsync(context)); 226await Assert.ThrowsAsync<XmlException>(() => formatter.ReadAsync(context)); 438await Assert.ThrowsAsync<InputFormatterException>(() => formatter.ReadAsync(context)); 459await Assert.ThrowsAsync<InputFormatterException>(() => formatter.ReadAsync(context));
Microsoft.AspNetCore.Mvc.FunctionalTests (3)
AntiforgeryMiddlewareTest.cs (1)
134var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.SendAsync(request));
ApplicationModelTest.cs (1)
163var ex = await Assert.ThrowsAsync<InvalidOperationException>(
TagHelpersTest.cs (1)
78var exception = await Assert.ThrowsAsync<HttpRequestException>(async () => await Client.GetAsync("http://localhost/Home/MyHtml"));
Microsoft.AspNetCore.Mvc.IntegrationTests (22)
ActionParametersIntegrationTest.cs (6)
404var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext)); 471var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext)); 495var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext)); 518var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext)); 557var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext)); 590var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => parameterBinder.BindModelAsync(parameter, testContext));
ArrayModelBinderIntegrationTest.cs (1)
399var exception = await Assert.ThrowsAsync<InvalidOperationException>(
CollectionModelBinderIntegrationTest.cs (3)
996var exception = await Assert.ThrowsAsync<InvalidOperationException>( 1082var exception = await Assert.ThrowsAsync<InvalidOperationException>( 1120var exception = await Assert.ThrowsAsync<InvalidOperationException>(
ComplexRecordIntegrationTest.cs (3)
3324var exception = await Assert.ThrowsAsync<InvalidOperationException>( 3394var exception = await Assert.ThrowsAsync<InvalidOperationException>( 3428var exception = await Assert.ThrowsAsync<InvalidOperationException>(
ComplexTypeIntegrationTestBase.cs (3)
3559var exception = await Assert.ThrowsAsync<InvalidOperationException>( 3645var exception = await Assert.ThrowsAsync<InvalidOperationException>( 3697var exception = await Assert.ThrowsAsync<InvalidOperationException>(
DictionaryModelBinderIntegrationTest.cs (1)
1225var exception = await Assert.ThrowsAsync<InvalidOperationException>(
ServicesModelBinderIntegrationTest.cs (1)
179var exception = await Assert.ThrowsAsync<InvalidOperationException>(
TryUpdateModelIntegrationTest.cs (1)
1159var ex = await Assert.ThrowsAsync<NotSupportedException>(() => TryUpdateModelAsync(model, string.Empty, testContext));
ValidationWithRecordIntegrationTests.cs (3)
2326var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => 2365var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => 2406var ex = await Assert.ThrowsAsync<InvalidOperationException>(() =>
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (5)
NewtonsoftJsonOutputFormatterTest.cs (1)
503await Assert.ThrowsAsync<OperationCanceledException>(() => formatter.WriteResponseBodyAsync(outputFormatterContext, Encoding.GetEncoding("utf-8")));
src\Mvc\Mvc.Core\test\Infrastructure\AsyncEnumerableReaderTest.cs (2)
183var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => reader(enumerable, default)); 199await Assert.ThrowsAsync<TimeZoneNotFoundException>(() => reader(enumerable, default));
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (2)
303var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => executor.ExecuteAsync(context, result)); 438await Assert.ThrowsAsync<OperationCanceledException>(() => executor.ExecuteAsync(context, result));
Microsoft.AspNetCore.Mvc.Razor.Test (21)
RazorPageTest.cs (10)
130var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync()); 183var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync()); 262var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync()); 410var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync()); 470var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync()); 578var ex = await Assert.ThrowsAsync<InvalidOperationException>(page.ExecuteAsync); 602var ex = await Assert.ThrowsAsync<InvalidOperationException>(page.ExecuteAsync); 626var ex = await Assert.ThrowsAsync<InvalidOperationException>(page.ExecuteAsync); 645var ex = await Assert.ThrowsAsync<InvalidOperationException>(page.ExecuteAsync); 896var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => page.ExecuteAsync());
RazorViewTest.cs (11)
549var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 592var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 637var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 746var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 945var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1014var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1049var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1232var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1286var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1500var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext)); 1547var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => view.RenderAsync(viewContext));
Microsoft.AspNetCore.Mvc.TagHelpers.Test (23)
AnchorTagHelperTest.cs (4)
524var ex = await Assert.ThrowsAsync<InvalidOperationException>( 564var ex = await Assert.ThrowsAsync<InvalidOperationException>( 602var ex = await Assert.ThrowsAsync<InvalidOperationException>( 640var ex = await Assert.ThrowsAsync<InvalidOperationException>(
CacheTagHelperTest.cs (5)
678await Assert.ThrowsAsync<Exception>(() => cacheTagHelper1.ProcessAsync(tagHelperContext1, tagHelperOutput1)); 751await Assert.ThrowsAsync<Exception>(() => cacheTagHelper.ProcessAsync(tagHelperContext1, tagHelperOutput1)); 763await Assert.ThrowsAsync<Exception>(() => cacheTagHelper.ProcessAsync(tagHelperContext2, tagHelperOutput2)); 878await Assert.ThrowsAsync<DivideByZeroException>(() => task1); 879await Assert.ThrowsAsync<DivideByZeroException>(() => task2);
ComponentTagHelperTest.cs (1)
57var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output));
DistributedCacheTagHelperTest.cs (1)
690await Assert.ThrowsAsync<Exception>(() => cacheTagHelper1.ProcessAsync(tagHelperContext1, tagHelperOutput1));
FormActionTagHelperTest.cs (5)
547var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output)); 587var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output)); 625var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output)); 663var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output)); 701var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output));
FormTagHelperTest.cs (4)
1044var ex = await Assert.ThrowsAsync<InvalidOperationException>( 1080var ex = await Assert.ThrowsAsync<InvalidOperationException>( 1114var ex = await Assert.ThrowsAsync<InvalidOperationException>( 1148var ex = await Assert.ThrowsAsync<InvalidOperationException>(
PartialTagHelperTest.cs (2)
600var exception = await Assert.ThrowsAsync<InvalidOperationException>( 743var exception = await Assert.ThrowsAsync<InvalidOperationException>(
PersistComponentStateTagHelperTest.cs (1)
235await Assert.ThrowsAsync<InvalidOperationException>(() => tagHelper.ProcessAsync(context, output));
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (21)
PartialViewResultTest.cs (4)
54var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => viewResult.ExecuteResultAsync(actionContext)); 92var ex = await Assert.ThrowsAsync<InvalidOperationException>( 130var ex = await Assert.ThrowsAsync<InvalidOperationException>( 170var ex = await Assert.ThrowsAsync<InvalidOperationException>(
Rendering\HtmlHelperPartialExtensionsTest.cs (6)
420var exception = await Assert.ThrowsAsync<InvalidOperationException>( 449var exception = await Assert.ThrowsAsync<InvalidOperationException>( 480var exception = await Assert.ThrowsAsync<InvalidOperationException>( 509var exception = await Assert.ThrowsAsync<InvalidOperationException>( 538var exception = await Assert.ThrowsAsync<InvalidOperationException>( 569var exception = await Assert.ThrowsAsync<InvalidOperationException>(
ViewComponentResultTest.cs (4)
63var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => viewResult.ExecuteResultAsync(actionContext)); 114var exception = await Assert.ThrowsAsync<InvalidOperationException>( 137var exception = await Assert.ThrowsAsync<InvalidOperationException>( 162var exception = await Assert.ThrowsAsync<InvalidOperationException>(
ViewComponents\ViewViewComponentResultTest.cs (2)
413var ex = await Assert.ThrowsAsync<InvalidOperationException>( 442var ex = await Assert.ThrowsAsync<InvalidOperationException>(
ViewExecutorTest.cs (1)
105var exception = await Assert.ThrowsAsync<NotImplementedException>(async () => await viewExecutor.ExecuteAsync(
ViewResultTest.cs (4)
64var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => viewResult.ExecuteResultAsync(actionContext)); 102var ex = await Assert.ThrowsAsync<InvalidOperationException>( 142var ex = await Assert.ThrowsAsync<InvalidOperationException>( 182var ex = await Assert.ThrowsAsync<InvalidOperationException>(
Microsoft.AspNetCore.OpenApi.Tests (1)
Transformers\Implementations\OpenApiSchemaReferenceTransformerTests.cs (1)
418var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => VerifyOpenApiDocument(builder, _ => { }));
Microsoft.AspNetCore.OutputCaching.Tests (1)
OutputCacheTests.cs (1)
961await Assert.ThrowsAsync<SomeException>(
Microsoft.AspNetCore.Razor.Runtime.Test (1)
Runtime\TagHelpers\TagHelperExecutionContextTest.cs (1)
32await Assert.ThrowsAsync<Exception>(async () => await executionContext.SetOutputContentAsync());
Microsoft.AspNetCore.RequestDecompression.Tests (1)
RequestDecompressionMiddlewareTests.cs (1)
123await Assert.ThrowsAsync<InvalidDataException>(async () => await InvokeMiddleware(compressedBytes, new[] { contentEncoding }));
Microsoft.AspNetCore.Rewrite.Tests (1)
IISUrlRewrite\MiddleWareTests.cs (1)
579var ex = await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => server.CreateClient().GetAsync("article/23?p1=123&p2=abc"));
Microsoft.AspNetCore.Routing.FunctionalTests (7)
EndpointRoutingIntegrationTest.cs (4)
152var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.CreateRequest("/").SendAsync("GET")); 213var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.CreateRequest("/").SendAsync("GET")); 244var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.CreateRequest("/").SendAsync("GET")); 343var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => server.CreateRequest("/").SendAsync("GET"));
MinimalFormTests.cs (3)
208var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.SendAsync(request)); 428var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.SendAsync(request)); 487var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.SendAsync(request));
Microsoft.AspNetCore.Routing.Tests (6)
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (1)
826var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => endpoint.RequestDelegate!(httpContext));
EndpointRoutingMiddlewareTest.cs (3)
152await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await middleware.Invoke(httpContext)); 153await Assert.ThrowsAsync<InvalidTimeZoneException>(async () => await middleware.Invoke(httpContext)); 225await Assert.ThrowsAsync<InvalidOperationException>(() => middleware.Invoke(httpContext));
Matching\DefaultEndpointSelectorTest.cs (1)
161var ex = await Assert.ThrowsAsync<AmbiguousMatchException>(() => selector.SelectAsync(httpContext, candidateSet));
Tree\TreeRouterTest.cs (1)
1842await Assert.ThrowsAsync<Exception>(() => route.RouteAsync(context));
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (44)
Http2Tests.cs (3)
859await Assert.ThrowsAsync<IOException>(() => readTask); 907await Assert.ThrowsAsync<IOException>(() => readTask); 957await Assert.ThrowsAsync<IOException>(() => readTask);
Http3Tests.cs (4)
176var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address)); 209var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); 235var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); 256var ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(address));
Listener\RequestBodyTests.cs (5)
135await Assert.ThrowsAsync<IOException>(async () => await readTask); 139await Assert.ThrowsAsync<HttpRequestException>(async () => await responseTask); 160await Assert.ThrowsAsync<IOException>(async () => await readTask); 164await Assert.ThrowsAsync<HttpRequestException>(async () => await responseTask); 185var assertTask = Assert.ThrowsAsync<IOException>(async () => await context.Request.Body.ReadAsync(input, 0, input.Length, context.DisconnectToken));
Listener\ResponseBodyTests.cs (7)
161await Assert.ThrowsAsync<HttpRequestException>(() => responseTask); 181await Assert.ThrowsAsync<HttpRequestException>(() => responseTask); 204await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.LoadIntoBufferAsync()); 226await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.LoadIntoBufferAsync()); 251await Assert.ThrowsAsync<IOException>(async () => 287await Assert.ThrowsAsync<IOException>(async () => 297await Assert.ThrowsAsync<ObjectDisposedException>(() => context.Response.Body.WriteAsync(Utilities.WriteBuffer, 0, Utilities.WriteBuffer.Length));
OpaqueUpgradeTests.cs (3)
272var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await SendOpaqueRequestAsync(method, address, extraHeader)); 354var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => upgrade.Task); 358ex = await Assert.ThrowsAsync<InvalidOperationException>(() => ParseResponseAsync(stream));
RequestBodyLimitTests.cs (3)
266var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length)); 269ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length)); 347var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length));
ResponseBodyTests.cs (4)
243await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address)); 257await Assert.ThrowsAsync<HttpRequestException>(async () => await SendRequestAsync(address)); 270await Assert.ThrowsAsync<InvalidOperationException>(() => 275await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address));
ResponseSendFileTests.cs (9)
165await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => 184await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => 391await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address)); 419await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address)); 446await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address)); 473await Assert.ThrowsAsync<HttpRequestException>(() => SendRequestAsync(address)); 497await Assert.ThrowsAsync<IOException>(async () => 506await Assert.ThrowsAsync<ObjectDisposedException>(() => 595await Assert.ThrowsAsync<IOException>(async () =>
ServerTests.cs (6)
182await Assert.ThrowsAsync<HttpRequestException>(async () => await responseTask); 204await Assert.ThrowsAsync<HttpRequestException>(async () => await responseTask); 216var ex = await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask); 221ex = await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask); 235var ex = await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask); 240ex = await Assert.ThrowsAsync<HttpRequestException>(async () => await requestTask);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (48)
BodyControlTests.cs (13)
29await Assert.ThrowsAsync<Exception>(() => request.ReadAsync(new byte[1], 0, 1))); 31await Assert.ThrowsAsync<Exception>(async () => await requestPipe.ReadAsync())); 44var writeEx = await Assert.ThrowsAsync<InvalidOperationException>(() => response.WriteAsync(new byte[1], 0, 1)); 48await Assert.ThrowsAsync<Exception>(() => request.ReadAsync(new byte[1], 0, 1))); 51await Assert.ThrowsAsync<Exception>(() => upgrade.ReadAsync(new byte[1], 0, 1))); 54await Assert.ThrowsAsync<Exception>(async () => await requestPipe.ReadAsync())); 70var writeEx = await Assert.ThrowsAsync<InvalidOperationException>(() => response.WriteAsync(new byte[1], 0, 1)); 74await Assert.ThrowsAsync<Exception>(() => request.ReadAsync(new byte[1], 0, 1))); 77await Assert.ThrowsAsync<Exception>(() => upgrade.ReadAsync(new byte[1], 0, 1))); 79await Assert.ThrowsAsync<Exception>(async () => await requestPipe.ReadAsync())); 120await Assert.ThrowsAsync<ObjectDisposedException>(async () => await requestPipe.ReadAsync()); 137await Assert.ThrowsAsync<ObjectDisposedException>(async () => await responsePipe.WriteAsync(new Memory<byte>())); 138await Assert.ThrowsAsync<ObjectDisposedException>(async () => await responsePipe.FlushAsync());
DiagnosticMemoryPoolTests.cs (1)
197var aggregateException = await Assert.ThrowsAsync<AggregateException>(async () => await memoryPool.WhenAllBlocksReturnedAsync(TimeSpan.FromSeconds(5)));
HttpRequestPipeReaderTests.cs (3)
21await Assert.ThrowsAsync<ObjectDisposedException>(async () => { await pipeReader.ReadAsync(); }); 30await Assert.ThrowsAsync<TaskCanceledException>(() => pipeReader.ReadAsync().AsTask()); 41var exception = await Assert.ThrowsAsync<Exception>(() => pipeReader.ReadAsync().AsTask());
HttpRequestStreamTests.cs (9)
86await Assert.ThrowsAsync<NotSupportedException>(() => stream.WriteAsync(new byte[1], 0, 1)); 138await Assert.ThrowsAsync<TaskCanceledException>(() => stream.ReadAsync(new byte[1], 0, 1)); 150var exception = await Assert.ThrowsAsync<Exception>(() => stream.ReadAsync(new byte[1], 0, 1)); 163await Assert.ThrowsAsync<ObjectDisposedException>(async () => { await stream.ReadAsync(new byte[1], 0, 1); }); 173await Assert.ThrowsAsync<TaskCanceledException>(() => stream.CopyToAsync(Mock.Of<Stream>())); 184var exception = await Assert.ThrowsAsync<Exception>(() => stream.CopyToAsync(Mock.Of<Stream>())); 196await Assert.ThrowsAsync<ObjectDisposedException>(async () => { await stream.CopyToAsync(Mock.Of<Stream>()); }); 205await Assert.ThrowsAsync<ArgumentNullException>(async () => { await stream.CopyToAsync(null); }); 215await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => { await stream.CopyToAsync(Mock.Of<Stream>(), 0); });
HttpResponseStreamTests.cs (2)
57await Assert.ThrowsAsync<NotSupportedException>(() => stream.ReadAsync(new byte[1], 0, 1)); 103var ex = await Assert.ThrowsAsync<ObjectDisposedException>(async () => { await stream.WriteAsync(new byte[1], 0, 1); });
KestrelServerTests.cs (5)
349var exception = await Assert.ThrowsAsync<InvalidOperationException>( 390var exception = await Assert.ThrowsAsync<InvalidOperationException>( 646Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask1.TimeoutAfter(timeout))); 647Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask2.TimeoutAfter(timeout))); 648Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask3.TimeoutAfter(timeout)));
MessageBodyTests.cs (13)
125await Assert.ThrowsAsync<InvalidOperationException>(async () => await reader.ReadAsync()); 228await Assert.ThrowsAsync<BadHttpRequestException>(() => task); 256await Assert.ThrowsAsync<BadHttpRequestException>(() => task); 297await Assert.ThrowsAsync<BadHttpRequestException>(() => task); 378var ex = await Assert.ThrowsAsync<IOException>(async () => 401var ex = await Assert.ThrowsAsync<BadHttpRequestException>(async () => 811var exception = await Assert.ThrowsAsync<BadHttpRequestException>(() => stream.CopyToAsync(ms)); 1223var ex2 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask()); 1224var ex3 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask()); 1256var ex2 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask()); 1257var ex3 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask()); 1283var ex2 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask()); 1284var ex3 = await Assert.ThrowsAsync<BadHttpRequestException>(() => reader.ReadAsync().AsTask());
ThrowingWasUpgradedWriteOnlyStreamTests.cs (2)
23Assert.Equal(CoreStrings.ResponseStreamWasUpgraded, (await Assert.ThrowsAsync<InvalidOperationException>(() => stream.WriteAsync(new byte[1], 0, 1))).Message); 25Assert.Equal(CoreStrings.ResponseStreamWasUpgraded, (await Assert.ThrowsAsync<InvalidOperationException>(() => stream.FlushAsync())).Message);
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (17)
QuicConnectionContextTests.cs (5)
138var ex = await Assert.ThrowsAsync<ConnectionResetException>(() => acceptStreamTask.AsTask()).DefaultTimeout(); 301var ex = await Assert.ThrowsAsync<ConnectionResetException>(() => acceptTask).DefaultTimeout(); 426var ex = await Assert.ThrowsAsync<ConnectionResetException>(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); 475var serverEx = await Assert.ThrowsAsync<ConnectionResetException>(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); 487var clientEx = await Assert.ThrowsAsync<QuicException>(() => clientStream.ReadAsync(buffer).AsTask()).DefaultTimeout();
QuicConnectionListenerTests.cs (6)
86var ex = await Assert.ThrowsAsync<AuthenticationException>(async () => 184await Assert.ThrowsAsync<AuthenticationException>(() => QuicConnection.ConnectAsync(options).AsTask()); 257var ex = await Assert.ThrowsAsync<AuthenticationException>(() => QuicConnection.ConnectAsync(options).AsTask()).DefaultTimeout(); 280await Assert.ThrowsAsync<AddressInUseException>(() => QuicTestHelpers.CreateConnectionListenerFactory(LoggerFactory, port: port)); 295await Assert.ThrowsAsync<AddressInUseException>(() => QuicTestHelpers.CreateConnectionListenerFactory(LoggerFactory, port: port)); 404await Assert.ThrowsAsync<AuthenticationException>(() => clientConnectionTask.AsTask()).DefaultTimeout();
QuicStreamContextTests.cs (5)
275var ex = await Assert.ThrowsAsync<ConnectionResetException>(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); 353var ex = await Assert.ThrowsAsync<ConnectionResetException>(() => serverStream.Transport.Input.ReadAsync().AsTask()).DefaultTimeout(); 466var ex = await Assert.ThrowsAsync<QuicException>(() => clientStream.ReadAsync(new byte[1024]).AsTask()).DefaultTimeout(); 521var clientEx = await Assert.ThrowsAsync<QuicException>(() => clientStream.WriteAsync(data).AsTask()).DefaultTimeout(); 526var serverEx = await Assert.ThrowsAsync<ConnectionAbortedException>(() => serverReadTask).DefaultTimeout();
WebHostTests.cs (1)
409var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => host.StartAsync()).DefaultTimeout();
Microsoft.AspNetCore.Session.Tests (4)
SessionTests.cs (4)
704await Assert.ThrowsAsync<InvalidOperationException>(() => context.Session.LoadAsync()); 756await Assert.ThrowsAsync<OperationCanceledException>(() => context.Session.LoadAsync()); 804await Assert.ThrowsAsync<OperationCanceledException>(() => context.Session.LoadAsync(token)); 985await Assert.ThrowsAsync<OperationCanceledException>(() => context.Session.CommitAsync(token));
Microsoft.AspNetCore.Shared.Tests (4)
ObjectMethodExecutorTest.cs (4)
122await Assert.ThrowsAsync<NotImplementedException>( 139await Assert.ThrowsAsync<NotImplementedException>( 372var exception = await Assert.ThrowsAsync<AggregateException>(async () => await resultTask); 405var exception = await Assert.ThrowsAsync<AggregateException>(async () => await resultTask);
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (23)
HubConnectionTests.cs (21)
575var ex = Assert.ThrowsAsync<OperationCanceledException>(async () => 615await Assert.ThrowsAsync<TaskCanceledException>(async () => 657var ex = await Assert.ThrowsAsync<HubException>(async () => 894var ex = await Assert.ThrowsAsync<OperationCanceledException>(async () => 941await Assert.ThrowsAsync<TaskCanceledException>(async () => 991await Assert.ThrowsAsync<TaskCanceledException>(() => channel.Completion); 1054var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync().DefaultTimeout()); 1081var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("!@#$%")).DefaultTimeout(); 1108var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("!@#$%", 10, "test")).DefaultTimeout(); 1135var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("Echo", "p1", 42)).DefaultTimeout(); 1162var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("Echo", new[] { 42 })).DefaultTimeout(); 1190var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync().DefaultTimeout()); 1218var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync().DefaultTimeout()); 1246var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync().DefaultTimeout()); 1273var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync()).DefaultTimeout(); 1300var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("Stream", 3)).DefaultTimeout(); 1327var ex = await Assert.ThrowsAsync<HubException>(() => channel.ReadAndCollectAllAsync()).DefaultTimeout(); 1375var hubException = await Assert.ThrowsAsync<HubException>(() => result).DefaultTimeout(); 1429var hubException = await Assert.ThrowsAsync<HubException>(() => result).DefaultTimeout(); 1463var hubException = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync<int>("StreamEcho", new List<string> { "1", "2" }).DefaultTimeout()); 1896var ex = await Assert.ThrowsAsync<AggregateException>(() => hubConnection.StartAsync().DefaultTimeout());
HubConnectionTests.Tracing.cs (2)
408await Assert.ThrowsAsync<TaskCanceledException>(async () => 505var ex = await Assert.ThrowsAsync<HubException>(async () =>
Microsoft.AspNetCore.SignalR.Client.Tests (50)
HttpConnectionFactoryTests.cs (2)
53var ex = await Assert.ThrowsAsync<NotSupportedException>(async () => await factory.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 0))); 72var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await factory.ConnectAsync(new UriEndPoint(url2)));
HttpConnectionTests.ConnectionLifecycle.cs (10)
69await Assert.ThrowsAsync<ObjectDisposedException>( 157var ex = await Assert.ThrowsAsync<AggregateException>(() => connection.StartAsync()).DefaultTimeout(); 317await Assert.ThrowsAsync<HttpRequestException>(async () => await connection.Transport.Input.ReadAsync()); 346await Assert.ThrowsAsync<AggregateException>( 422await Assert.ThrowsAsync<TaskCanceledException>(() => startTask).DefaultTimeout(); 447var ex = await Assert.ThrowsAsync<AggregateException>(async () => await connection.StartAsync(cts.Token)).DefaultTimeout(); 473await Assert.ThrowsAsync<TaskCanceledException>(async () => await connection.StartAsync(new CancellationToken(canceled: true))).DefaultTimeout(); 504var ex = await Assert.ThrowsAsync<AggregateException>(async () => await connection.StartAsync()).DefaultTimeout(); 530var ex = await Assert.ThrowsAsync<AggregateException>(async () => await connection.StartAsync(cts.Token).DefaultTimeout()); 538await Assert.ThrowsAsync<ObjectDisposedException>(() => connection.StartAsync());
HttpConnectionTests.Negotiate.cs (3)
326var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.StartAsync().DefaultTimeout()); 599var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.StartAsync().DefaultTimeout()); 615var exception = await Assert.ThrowsAsync<TException>(
HttpConnectionTests.Transport.cs (5)
261var exception = await Assert.ThrowsAsync<InvalidOperationException>( 277var exception = await Assert.ThrowsAsync<ObjectDisposedException>( 338await Assert.ThrowsAsync<HttpRequestException>(async () => await connection.StartAsync().DefaultTimeout()); 447await Assert.ThrowsAsync<HttpRequestException>(async () => await connection.Transport.Input.ReadAllAsync()); 551await Assert.ThrowsAsync<HttpRequestException>(async () => await connection.Transport.Input.ReadAllAsync());
HubConnectionTests.ConnectionLifecycle.cs (7)
73await Assert.ThrowsAsync<InvalidOperationException>(() => secondStart).DefaultTimeout(); 199var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => method(connection)).DefaultTimeout(); 377var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.SendAsync("Foo")).DefaultTimeout(); 412var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.SendAsync("Foo")).DefaultTimeout(); 450var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.SendAsync("Foo")).DefaultTimeout(); 480var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => targetTask).DefaultTimeout(); 543await Assert.ThrowsAsync<TaskCanceledException>(() => hubConnection.StartAsync(new CancellationToken(canceled: true))).DefaultTimeout();
HubConnectionTests.cs (15)
40await Assert.ThrowsAsync<InvalidOperationException>(async () => await hubConnection.InvokeAsync<int>("test").DefaultTimeout()); 55await Assert.ThrowsAsync<InvalidOperationException>(async () => await hubConnection.SendAsync("test").DefaultTimeout()); 137await Assert.ThrowsAsync<TaskCanceledException>(async () => await invokeTask); 161var actualException = await Assert.ThrowsAsync<InvalidOperationException>(async () => await invokeTask); 178await Assert.ThrowsAsync<TaskCanceledException>(async () => await invokeTask); 191await Assert.ThrowsAsync<TaskCanceledException>(() => 210await Assert.ThrowsAsync<TaskCanceledException>(() => 237await Assert.ThrowsAsync<OperationCanceledException>(() => sendTask.DefaultTimeout()); 252await Assert.ThrowsAsync<TaskCanceledException>(() => 272await Assert.ThrowsAsync<TaskCanceledException>(() => result.GetAsyncEnumerator().MoveNextAsync().DefaultTimeout()); 341await Assert.ThrowsAsync<TaskCanceledException>(async () => await e.MoveNextAsync()).DefaultTimeout(); 421var exception = await Assert.ThrowsAsync<TimeoutException>(() => invokeTask); 629await Assert.ThrowsAsync<TaskCanceledException>(() => invokeTask).DefaultTimeout(); 743await Assert.ThrowsAsync<TaskCanceledException>(() => tcs.Task.DefaultTimeout()); 786await Assert.ThrowsAsync<InvalidOperationException>(() => connection.StartAsync().DefaultTimeout());
HubConnectionTests.Protocol.cs (7)
83var ex = await Assert.ThrowsAsync<InvalidDataException>(() => startTask).DefaultTimeout(); 306var ex = await Assert.ThrowsAsync<HubException>(() => invokeTask).DefaultTimeout(); 329var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => channel.ReadAndCollectAllAsync()).DefaultTimeout(); 352var ex = await Assert.ThrowsAsync<HubException>(async () => await channel.ReadAndCollectAllAsync()).DefaultTimeout(); 375var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => invokeTask).DefaultTimeout(); 456var ex = Assert.ThrowsAsync<TimeoutException>(async () => await handlerTask.DefaultTimeout(2000)); 490var ex = Assert.ThrowsAsync<TimeoutException>(async () => await handlerTask.DefaultTimeout(2000));
HubConnectionTests.Reconnect.cs (1)
719Assert.Same(firstException, await Assert.ThrowsAsync<Exception>(() => startTask).DefaultTimeout());
Microsoft.AspNetCore.SignalR.Specification.Tests (10)
HubLifetimeManagerTestBase.cs (5)
223var ex = await Assert.ThrowsAsync<HubException>(() => resultTask).DefaultTimeout(); 251var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => 280await Assert.ThrowsAsync<IOException>(() => manager1.InvokeConnectionAsync<int>("none", "Result", new object[] { "test" }, cancellationToken: default)).DefaultTimeout(); 337var ex = await Assert.ThrowsAsync<IOException>(() => invoke1).DefaultTimeout(); 362await Assert.ThrowsAsync<HubException>(() => invoke1).DefaultTimeout();
ScaleoutHubLifetimeManagerTests.cs (5)
524var ex = await Assert.ThrowsAsync<HubException>(() => resultTask).DefaultTimeout(); 547await Assert.ThrowsAsync<IOException>(() => manager1.InvokeConnectionAsync<int>("none", "Result", new object[] { "test" }, cancellationToken: default)).DefaultTimeout(); 575var ex = await Assert.ThrowsAsync<HubException>(() => invoke1).DefaultTimeout(); 626var ex = await Assert.ThrowsAsync<IOException>(() => manager1.InvokeConnectionAsync<int>("1234", "Result", new object[] { "test" }, cancellationToken: default)).DefaultTimeout(); 656var ex = await Assert.ThrowsAsync<HubException>(() => resultTask).DefaultTimeout();
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
RedisHubLifetimeManagerTests.cs (1)
116var ex = await Assert.ThrowsAsync<ApplicationException>(() => manager.OnConnectedAsync(connection)).DefaultTimeout();
Microsoft.AspNetCore.SignalR.Tests (13)
ClientProxyTests.cs (1)
216var ex = await Assert.ThrowsAsync<NotImplementedException>(async () => await proxy.InvokeAsync<int>("method", cancellationToken: default)).DefaultTimeout();
EndToEndTests.cs (3)
240var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => connection.StartAsync().DefaultTimeout()); 389var exception = await Assert.ThrowsAsync<HttpRequestException>(() => connection.StartAsync().DefaultTimeout()); 420await Assert.ThrowsAsync<WebSocketException>(() => connection.StartAsync().DefaultTimeout());
HubConnectionHandlerTests.ClientResult.cs (3)
122var ex = await Assert.ThrowsAsync<IOException>(() => connectionHandlerTask).DefaultTimeout(); 384var ex = await Assert.ThrowsAsync<HubException>(() => resultTask).DefaultTimeout(); 429var ex = await Assert.ThrowsAsync<HubException>(() => resultTask).DefaultTimeout();
HubConnectionHandlerTests.cs (6)
709await Assert.ThrowsAsync<InvalidOperationException>( 784var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await connectionHandlerTask); 2499await Assert.ThrowsAsync<InvalidOperationException>(async () => await await client.ConnectAsync(connectionHandler, expectedHandshakeResponseMessage: false)).DefaultTimeout(); 2523await Assert.ThrowsAsync<InvalidOperationException>(async () => await await client.ConnectAsync(connectionHandler, expectedHandshakeResponseMessage: false)).DefaultTimeout(); 3609var ex = await Assert.ThrowsAsync<TimeoutException>(async () => 4585var exception = await Assert.ThrowsAsync<OperationCanceledException>(() => task).DefaultTimeout();
Microsoft.AspNetCore.TestHost.Tests (31)
ClientHandlerTests.cs (8)
458await Assert.ThrowsAsync<OperationCanceledException>(() => readTask.DefaultTimeout()); 481await Assert.ThrowsAsync<OperationCanceledException>(() => readTask.DefaultTimeout()); 504await Assert.ThrowsAsync<ObjectDisposedException>(() => responseTask); 516return Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("https://example.com/", 536var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsStringAsync()); 552return Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("https://example.com/", 568return Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("https://example.com/", 593return Assert.ThrowsAsync<InvalidOperationException>(() => httpClient.GetAsync("https://example.com/",
HttpContextBuilderTests.cs (5)
212await Assert.ThrowsAsync<OperationCanceledException>(() => readTask.DefaultTimeout()); 236await Assert.ThrowsAsync<OperationCanceledException>(() => contextTask.DefaultTimeout()); 262await Assert.ThrowsAsync<OperationCanceledException>(() => readTask.DefaultTimeout()); 277return Assert.ThrowsAsync<InvalidOperationException>(() => server.SendAsync(c => { })); 343var ex = await Assert.ThrowsAsync<OperationCanceledException>(() => server.SendAsync(c => { }));
RequestLifetimeTests.cs (4)
28var ex = await Assert.ThrowsAsync<OperationCanceledException>(() => client.GetAsync("/", HttpCompletionOption.ResponseHeadersRead)); 44var ex = await Assert.ThrowsAsync<OperationCanceledException>(() => client.GetAsync("/", HttpCompletionOption.ResponseHeadersRead)); 66var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsByteArrayAsync()); 89var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsByteArrayAsync());
ResponseBodyTests.cs (2)
61var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.GetAsync("/")); 97var requestException = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("/"));
ResponseResetTests.cs (4)
81var rex = await Assert.ThrowsAsync<HttpResetTestException>(() => client.GetAsync("/")); 100var rex = await Assert.ThrowsAsync<HttpResetTestException>(() => client.GetAsync("/", HttpCompletionOption.ResponseHeadersRead)); 125var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsByteArrayAsync()); 151var ex = await Assert.ThrowsAsync<HttpRequestException>(() => response.Content.ReadAsByteArrayAsync());
TestClientTests.cs (4)
256var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.SendAsync(message, CancellationToken.None)); 441var ex = await Assert.ThrowsAsync<IOException>(async () => 776await Assert.ThrowsAsync<IOException>(async () => await clientSocket.ReceiveAsync(new System.ArraySegment<byte>(buffer), CancellationToken.None)); 1031await Assert.ThrowsAsync<NotSupportedException>(() => upgradeFeature.UpgradeAsync());
TestServerTests.cs (3)
675await Assert.ThrowsAsync<ObjectDisposedException>(() => server.CreateClient().GetAsync("/")); 693await Assert.ThrowsAsync<TaskCanceledException>(async () => { string result = await server.CreateClient().GetStringAsync("/path"); }); 765await Assert.ThrowsAsync<Exception>(() => server.CreateClient().GetAsync("/path"));
WebSocketClientTests.cs (1)
105await Assert.ThrowsAsync<NotSupportedException>(() => upgradeFeature.UpgradeAsync());
Microsoft.AspNetCore.Tests (4)
WebApplicationTests.cs (4)
355await Assert.ThrowsAsync<InvalidOperationException>(() => app.RunAsync("http://localhost:5001")); 366await Assert.ThrowsAsync<InvalidOperationException>(() => app.RunAsync("http://localhost:5001")); 2058var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.GetAsync("/")); 2089var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.GetAsync("/"));
Microsoft.AspNetCore.WebUtilities.Tests (22)
FileBufferingReadStreamTests.cs (2)
362var exception = await Assert.ThrowsAsync<IOException>(() => stream.ReadAsync(bytes, 0, bytes.Length)); 394var exception = await Assert.ThrowsAsync<IOException>(() => stream.ReadAsync(bytes, 0, bytes.Length));
FileBufferingWriteStreamTests.cs (2)
299var exception = await Assert.ThrowsAsync<IOException>(() => bufferingStream.WriteAsync(input, 0, input.Length)); 314var exception = await Assert.ThrowsAsync<IOException>(() => bufferingStream.WriteAsync(input, 0, input.Length));
FormPipeReaderTests.cs (6)
82var exception = await Assert.ThrowsAsync<InvalidDataException>( 108var exception = await Assert.ThrowsAsync<InvalidDataException>( 123var exception = await Assert.ThrowsAsync<InvalidDataException>( 151var exception = await Assert.ThrowsAsync<InvalidDataException>( 179var exception = await Assert.ThrowsAsync<InvalidDataException>( 199var readTask = Assert.ThrowsAsync<InvalidDataException>(
FormReaderTests.cs (4)
83var exception = await Assert.ThrowsAsync<InvalidDataException>( 95var exception = await Assert.ThrowsAsync<InvalidDataException>( 122var exception = await Assert.ThrowsAsync<InvalidDataException>( 149var exception = await Assert.ThrowsAsync<InvalidDataException>(
HttpRequestStreamReaderTest.cs (1)
394await Assert.ThrowsAsync<ObjectDisposedException>(() => action(httpRequestStreamReader));
HttpResponseStreamWriterTest.cs (4)
192await Assert.ThrowsAsync<IOException>(() => writer.FlushAsync()); 388await Assert.ThrowsAsync<TaskCanceledException>(async () => await writer.WriteAsync(memory, cancellationToken)); 446await Assert.ThrowsAsync<TaskCanceledException>(async () => await writer.WriteLineAsync(memory, cancellationToken)); 782await Assert.ThrowsAsync<ObjectDisposedException>(() =>
MultipartReaderTests.cs (3)
133var exception = await Assert.ThrowsAsync<InvalidDataException>(() => reader.ReadNextSectionAsync()); 146var exception = await Assert.ThrowsAsync<InvalidDataException>(() => reader.ReadNextSectionAsync()); 305await Assert.ThrowsAsync<IOException>(async () =>
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Diagnostics\GetDiagnosticsTests.cs (1)
753await Assert.ThrowsAsync<OperationCanceledException>(() => compilationWithAnalyzers.GetAnalyzerSyntaxDiagnosticsAsync(tree, analyzer.CancellationToken));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (1)
InteractiveSessionTests.cs (1)
2116await Assert.ThrowsAsync<OperationCanceledException>(() =>
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeGeneration\CodeGenerationTests.VisualBasic.cs (1)
1400await Assert.ThrowsAsync<AggregateException>(async () =>
MetadataAsSource\MetadataAsSourceTests.cs (1)
1881await Assert.ThrowsAsync<ArgumentException>(async () =>
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (2)
Ordering\RequestOrderingTests.cs (2)
121await Assert.ThrowsAsync<StreamJsonRpc.RemoteInvocationException>(() => waitables[0]); 176await Assert.ThrowsAsync<StreamJsonRpc.RemoteInvocationException>(() => waitables[0]);
Microsoft.CodeAnalysis.UnitTests (2)
AsyncQueueTests.cs (2)
170await Assert.ThrowsAsync<TaskCanceledException>(() => task); 182await Assert.ThrowsAsync<TaskCanceledException>(() => task);
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (14)
MSBuildWorkspaceTestBase.cs (1)
189await Assert.ThrowsAsync<FileNotFoundException>(testCode);
VisualStudioMSBuildWorkspaceTests.cs (13)
855var e = await Assert.ThrowsAsync<InvalidOperationException>(async delegate 870var e = await Assert.ThrowsAsync<InvalidOperationException>(async delegate 927await Assert.ThrowsAsync<FileNotFoundException>(() => workspace.OpenSolutionAsync(solutionFilePath)); 1065await Assert.ThrowsAsync<FileNotFoundException>(() => workspace.OpenSolutionAsync(solutionFilePath)); 1123var e = await Assert.ThrowsAsync<InvalidOperationException>(async () => 1145var e = await Assert.ThrowsAsync<InvalidOperationException>(async () => 1184var e = await Assert.ThrowsAsync<InvalidOperationException>(() => workspace.OpenProjectAsync(projectName)); 1207await Assert.ThrowsAsync<FileNotFoundException>(async () => 1267await Assert.ThrowsAsync<FileNotFoundException>(async () => 1301await Assert.ThrowsAsync<InvalidOperationException>(async () => 2629await Assert.ThrowsAsync<FileNotFoundException>(async () => 2643await Assert.ThrowsAsync<FileNotFoundException>(async () => 3288var exception = await Assert.ThrowsAsync<Exception>(() => workspace.OpenSolutionAsync(solutionFilePath));
Microsoft.CodeAnalysis.Workspaces.UnitTests (10)
SolutionTests\TextLoaderTests.cs (1)
111await Assert.ThrowsAsync<NotImplementedException>(() => loader.LoadTextAndVersionAsync(workspace: null, documentId: null, CancellationToken.None));
UtilityTest\AsyncLazyTests.cs (1)
295? await Assert.ThrowsAsync<ArgumentException>(async () => await lazy.GetValueAsync(CancellationToken.None))
UtilityTest\SpecializedTasksTests.cs (8)
57await Assert.ThrowsAsync<TaskCanceledException>(async () => await whenAll); 171var exception = await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 228var exception = await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 288var exception = await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 355var exception = await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 430var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => task.AsTask()); 513var exception = await Assert.ThrowsAsync<TaskCanceledException>(() => task.AsTask()); 553var exception = await Assert.ThrowsAsync<InvalidOperationException>(() => task.AsTask());
Microsoft.DotNet.Build.Tasks.Feed.Tests (3)
PublishToSymbolServerTest.cs (3)
292var actualError = await Assert.ThrowsAsync<Exception>(() => 335var actualError = await Assert.ThrowsAsync<Exception>(() => 443var actualError = await Assert.ThrowsAsync<Exception>(() =>
Microsoft.DotNet.XUnitAssert.Tests (5)
ExceptionAssertsTests.cs (5)
691 await Assert.ThrowsAsync<ArgumentNullException>("testCode", () => Assert.ThrowsAsync<ArgumentException>(default(Func<Task>)!)); 699 var ex = await Record.ExceptionAsync(() => Assert.ThrowsAsync<ArgumentException>(testCode)); 715 await Assert.ThrowsAsync<ArgumentException>(testCode); 724 var ex = await Record.ExceptionAsync(() => Assert.ThrowsAsync<ArgumentException>(testCode)); 742 var ex = await Record.ExceptionAsync(() => Assert.ThrowsAsync<ArgumentException>(testCode));
Microsoft.Extensions.Caching.SqlServer.Tests (1)
SqlServerCacheWithDatabaseTest.cs (1)
81var exception = await Assert.ThrowsAsync<InvalidOperationException>(() =>
Microsoft.Extensions.Caching.StackExchangeRedis.Tests (1)
TimeExpirationAsyncTests.cs (1)
22var ex = await Assert.ThrowsAsync<ArgumentOutOfRangeException>(test);
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (2)
DefaultHealthCheckServiceTest.cs (1)
270await Assert.ThrowsAsync<TaskCanceledException>(async () => await task);
HealthCheckPublisherHostedServiceTest.cs (1)
792await Assert.ThrowsAsync<TaskCanceledException>(() => Task.Delay(TimeSpan.FromSeconds(10), cancellationToken));
Microsoft.Extensions.Diagnostics.Testing.Tests (6)
Metrics\MetricCollectorTests.cs (6)
245await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await collector.WaitForMeasurementsAsync(-1)); 246await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await collector.WaitForMeasurementsAsync(0)); 309await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await collector.WaitForMeasurementsAsync(-1)); 310await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await collector.WaitForMeasurementsAsync(0)); 366await Assert.ThrowsAsync<ObjectDisposedException>(async () => await collector.WaitForMeasurementsAsync(1)); 367await Assert.ThrowsAsync<ObjectDisposedException>(async () => await collector.WaitForMeasurementsAsync(1, TimeSpan.FromSeconds(1)));
Microsoft.Extensions.Http.Diagnostics.Tests (5)
Logging\HttpClientLoggerTest.cs (5)
75await Assert.ThrowsAsync<ArgumentNullException>(act); 110var actualException = await Assert.ThrowsAsync<HttpRequestException>(act); 437await Assert.ThrowsAsync<TaskCanceledException>(act); 554await Assert.ThrowsAsync<InvalidOperationException>(act); 820await Assert.ThrowsAsync<TaskCanceledException>(act);
Microsoft.Extensions.Http.Polly.Tests (6)
DependencyInjection\PollyHttpClientBuilderExtensionsTest.cs (3)
108await Assert.ThrowsAsync<OverflowException>(() => client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/throw"))); 146await Assert.ThrowsAsync<OverflowException>(() => client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/throw"))); 231await Assert.ThrowsAsync<OverflowException>(() => client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "/throw")));
PolicyHttpMessageHandlerTest.cs (3)
214var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => 342var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => 368var exception = await Assert.ThrowsAsync<OperationCanceledException>(async () =>
Microsoft.Extensions.Http.Resilience.Tests (3)
Hedging\HedgingTests.cs (2)
151var exception = await Assert.ThrowsAsync<InvalidOperationException>( 173var exception = await Assert.ThrowsAsync<HttpRequestException>(
Resilience\ResilienceHandlerTest.cs (1)
159await Assert.ThrowsAsync<InvalidOperationException>(() => InvokeHandler(invoker, request, asynchronous));
Microsoft.Extensions.ServiceDiscovery.Tests (3)
ServiceEndpointResolverTests.cs (3)
42exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await watcher.GetEndpointsAsync()); 63var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await client.GetStringAsync("/")); 255var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
Microsoft.Extensions.TimeProvider.Testing.Tests (6)
FakeTimeProviderTests.cs (5)
261await Assert.ThrowsAsync<TaskCanceledException>(async () => await delay); 273await Assert.ThrowsAsync<TaskCanceledException>(() => timeProvider.Delay(TimeSpan.FromTicks(1), cts.Token)); 284await Assert.ThrowsAsync<TimeoutException>(() => source.Task.WaitAsync(TimeSpan.FromTicks(-1), timeProvider, CancellationToken.None)); 288await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => source.Task.WaitAsync(TimeSpan.FromMilliseconds(-2), timeProvider, CancellationToken.None)); 352await Assert.ThrowsAsync<TaskCanceledException>(() => t);
TimerTests.cs (1)
156await Assert.ThrowsAsync<TaskCanceledException>(async () =>
Microsoft.Gen.Logging.Unit.Tests (1)
ParserTests.cs (1)
595await Assert.ThrowsAsync<OperationCanceledException>(async () =>
Microsoft.Gen.Metrics.Unit.Tests (1)
ParserTests.cs (1)
553await Assert.ThrowsAsync<OperationCanceledException>(async () =>
Microsoft.JSInterop.Tests (8)
Infrastructure\DotNetDispatcherTest.cs (2)
296var ex = await Assert.ThrowsAsync<JSException>(async () => await task); 312var ex = await Assert.ThrowsAsync<JSException>(async () => await task);
JSObjectReferenceTest.cs (2)
50await Assert.ThrowsAsync<ObjectDisposedException>(async () => await jsObject.InvokeAsync<object>("test", "arg1", "arg2")); 51await Assert.ThrowsAsync<ObjectDisposedException>(async () => await jsObject.InvokeAsync<object>("test", CancellationToken.None, "arg1", "arg2"));
JSRuntimeTest.cs (4)
50await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 82await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 99await Assert.ThrowsAsync<TaskCanceledException>(async () => await task); 231var jsException = await Assert.ThrowsAsync<JSException>(async () => await task);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (2)
ProjectSystemShim\CPS\CSharpCompilerOptionsTests.cs (2)
112await Assert.ThrowsAsync<InvalidProjectDataException>(() => CSharpHelpers.CreateCSharpCPSProjectAsync(environment, "Test2", binOutputPath: "")); 113await Assert.ThrowsAsync<InvalidProjectDataException>(() => CSharpHelpers.CreateCSharpCPSProjectAsync(environment, "Test3", binOutputPath: "Test.dll"));
Sockets.BindTests (1)
SocketTransportFactoryTests.cs (1)
21await Assert.ThrowsAsync<NotImplementedException>(async () => await socketTransportFactory.BindAsync(new UriEndPoint(new Uri("http://127.0.0.1:5554"))));
Sockets.FunctionalTests (1)
src\Servers\Kestrel\test\FunctionalTests\RequestTests.cs (1)
922await Assert.ThrowsAsync<TaskCanceledException>(async () => await readTcs.Task);
System.Windows.Forms.Primitives.TestUtilities (1)
Extensions\AssertExtensions.cs (1)
141T exception = await Assert.ThrowsAsync<T>(testCode);
System.Windows.Forms.Tests (1)
System\Windows\Forms\ToolStripTests.cs (1)
7315await Assert.ThrowsAsync<TaskCanceledException>(() => Task.Delay(SystemInformation.MouseHoverTime * 2, cancellationTokenSource.Token));
VBCSCompiler.UnitTests (1)
NamedPipeClientConnectionHostTests.cs (1)
66await Assert.ThrowsAsync<TaskCanceledException>(async () => await task);
xunit.assert (1)
ExceptionAsserts.cs (1)
291 var ex = await ThrowsAsync<T>(testCode);