828 references to Throws
IIS.Tests (1)
MaxRequestBodySizeTests.cs (1)
251invalidOpEx = Assert.Throws<InvalidOperationException>(() =>
InMemory.FunctionalTests (19)
ChunkedRequestTests.cs (6)
246Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 253Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 261Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); 372Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 379Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 387Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header"));
Http2\Http2StreamTests.cs (3)
2143Assert.Throws<InvalidOperationException>(() => context.Response.ContentType = "Custom 你好 Type"); 2470Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.ETag = "Custom 你好 Tag"); 2471Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.Accept = "Custom 你好 Tag");
Http3\Http3StreamTests.cs (3)
868Assert.Throws<InvalidOperationException>(() => context.Response.ContentType = "Custom 你好 Type"); 1022Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.ETag = "Custom 你好 Tag"); 1023Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.Accept = "Custom 你好 Tag");
MaxRequestBodySizeTests.cs (2)
290invalidOpEx = Assert.Throws<InvalidOperationException>(() => 330invalidOpEx = Assert.Throws<InvalidOperationException>(() =>
RequestTests.cs (2)
1692var ioEx = Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(new byte[1], 0, 1)); 1785var ioEx = Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(new byte[1], 0, 1));
ResponseHeaderTests.cs (2)
24Assert.Throws<InvalidOperationException>(() => context.Response.ContentType = "Custom 你好 Type"); // Special cased 25Assert.Throws<InvalidOperationException>(() => context.Response.Headers.Accept = "Custom 你好 Accept"); // Not special cased
ResponseTests.cs (1)
4236writeEx = Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.GetMemory());
Microsoft.AspNetCore.Antiforgery.Test (1)
AntiforgeryApplicationBuilderExtensionsTest.cs (1)
41var exception = Assert.Throws<InvalidOperationException>(() => builder.UseAntiforgery());
Microsoft.AspNetCore.Authentication.Core.Test (1)
AuthenticationSchemeProviderTests.cs (1)
153var error = Assert.Throws<InvalidOperationException>(() => services.GetRequiredService<IAuthenticationSchemeProvider>());
Microsoft.AspNetCore.Authentication.Test (2)
CookieTests.cs (1)
293Assert.Throws<OptionsValidationException>(() => options.Get(CookieAuthenticationDefaults.AuthenticationScheme));
OpenIdConnect\OpenIdConnectTests.cs (1)
510Assert.Throws<FormatException>(() =>
Microsoft.AspNetCore.Authorization.Test (2)
AuthorizationPolicyFacts.cs (1)
14Assert.Throws<InvalidOperationException>(() => new AuthorizationPolicyBuilder().RequireRole());
DefaultAuthorizationServiceTests.cs (1)
482Assert.Throws<InvalidOperationException>(() => BuildAuthorizationService(services =>
Microsoft.AspNetCore.Components.Forms.Tests (10)
EditContextDataAnnotationsExtensionsTest.cs (1)
17var ex = Assert.Throws<ArgumentNullException>(() => editContext.EnableDataAnnotationsValidation(_serviceProvider));
EditContextTest.cs (4)
11var ex = Assert.Throws<ArgumentNullException>(() => new EditContext(null)); 281Assert.Throws<KeyNotFoundException>(() => editContext.Properties[key1]); 290Assert.Throws<KeyNotFoundException>(() => editContext.Properties[key3]); 336Assert.Throws<KeyNotFoundException>(() => editContext.Properties[key]);
FieldIdentifierTest.cs (4)
15var ex = Assert.Throws<ArgumentNullException>(() => new FieldIdentifier(null, "somefield")); 22var ex = Assert.Throws<ArgumentException>(() => new FieldIdentifier(DateTime.Now, "somefield")); 30var ex = Assert.Throws<ArgumentNullException>(() => new FieldIdentifier(new object(), null)); 164var ex = Assert.Throws<ArgumentException>(() =>
ValidationMessageStoreTest.cs (1)
11var ex = Assert.Throws<ArgumentNullException>(() => new ValidationMessageStore(null));
Microsoft.AspNetCore.Components.Server.Tests (1)
src\SignalR\common\SignalR.Common\test\Internal\Protocol\MessagePackHubProtocolTestBase.cs (1)
364var exception = Assert.Throws<InvalidDataException>(() => HubProtocol.TryParseMessage(ref data, binder, out _));
Microsoft.AspNetCore.Components.Tests (18)
CascadingParameterTest.cs (1)
566var ex = Assert.Throws<InvalidOperationException>(() => renderer.AssignRootComponentId(component));
EventCallbackFactoryBinderExtensionsTest.cs (1)
605var ex = Assert.Throws<InvalidOperationException>(() => EventCallback.Factory.CreateBinder(component, setter, value));
NavigationManagerTest.cs (3)
140var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameter(name, "test")); 193var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameters(unsupportedParameterValues)); 209var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameters(values));
ParameterViewTest.cs (4)
336Assert.Throws<InvalidOperationException>(() => parameterView.GetEnumerator()); 337Assert.Throws<InvalidOperationException>(() => parameterView.GetValueOrDefault<object>("anything")); 339Assert.Throws<InvalidOperationException>(() => parameterView.ToDictionary()); 340var ex = Assert.Throws<InvalidOperationException>(() => parameterView.TryGetValue<object>("anything", out _));
RendererTest.cs (6)
663var ex = Assert.Throws<InvalidOperationException>(() => renderer.GetEventArgsType(eventHandlerId)); 686var ex = Assert.Throws<InvalidOperationException>(() => renderer.GetEventArgsType(eventHandlerId)); 4458Assert.Throws<InvalidOperationException>(() => parameterView.GetEnumerator()); 4459Assert.Throws<InvalidOperationException>(() => parameterView.GetValueOrDefault<object>("anything")); 4461Assert.Throws<InvalidOperationException>(parameterView.ToDictionary); 4462var ex = Assert.Throws<InvalidOperationException>(() => parameterView.TryGetValue<object>("anything", out _));
RenderTreeDiffBuilderTest.cs (3)
398var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent()); 415var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent()); 432var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent());
Microsoft.AspNetCore.Components.Web.Tests (3)
Forms\InputFileChangeEventArgsTest.cs (3)
30var ex = Assert.Throws<InvalidOperationException>(() => instance.File); 38var ex = Assert.Throws<InvalidOperationException>(() => instance.File); 62var ex = Assert.Throws<InvalidOperationException>(() => instance.GetMultipleFiles(1));
Microsoft.AspNetCore.Components.WebAssembly.Tests (1)
Hosting\WebAssemblyHostBuilderTest.cs (1)
106Assert.Throws<InvalidOperationException>(() => host.Services.GetRequiredService<TestServiceThatTakesStringBuilder>());
Microsoft.AspNetCore.CookiePolicy.Test (1)
CookieChunkingTests.cs (1)
182Assert.Throws<FormatException>(() => new ChunkingCookieManager() { ThrowForPartialCookies = true }
Microsoft.AspNetCore.Cors.Test (3)
CorsPolicyBuilderTests.cs (3)
145Assert.Throws<ArgumentNullException>(() => builder.WithOrigins(args)); 156Assert.Throws<ArgumentNullException>(() => builder.WithOrigins(args)); 342var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
Microsoft.AspNetCore.DataProtection.Abstractions.Tests (1)
DataProtectionCommonExtensionsTests.cs (1)
116var ex = Assert.Throws<InvalidOperationException>(() => services.GetDataProtectionProvider());
Microsoft.AspNetCore.DataProtection.Extensions.Tests (2)
DataProtectionProviderTests.cs (1)
199Assert.Throws<CryptographicException>(() => keylessUnprotector.Unprotect(data));
TimeLimitedDataProtectorTests.cs (1)
170Assert.Throws<CryptographicException>(() => ephemeralProtector.Unprotect(timeLimitedProtectedPayload));
Microsoft.AspNetCore.DataProtection.Tests (9)
AuthenticatedEncryption\ConfigurationModel\ManagedAuthenticatedEncryptorDescriptorDeserializerTests.cs (1)
125var ex = Assert.Throws<InvalidOperationException>(() => new ManagedAuthenticatedEncryptorDescriptorDeserializer().ImportFromXml(XElement.Parse(xml)));
Internal\KeyManagementOptionsPostSetupTest.cs (1)
172Assert.Throws<InvalidOperationException>(() => options.XmlEncryptor.Encrypt(xElement));
KeyManagement\KeyRingProviderTests.cs (2)
183Assert.Throws<InvalidOperationException>(() => keyRingProvider.GetCacheableKeyRing(now)); // The would-be default key is revoked 264var exception = Assert.Throws<InvalidOperationException>(() => keyRingProvider.GetCacheableKeyRing(now));
KeyManagement\XmlKeyManagerTests.cs (1)
592Assert.Throws<FormatException>(() => RunGetAllKeysCore(xml, new Mock<IActivator>().Object));
ServiceCollectionTests.cs (1)
106Assert.Throws<InvalidOperationException>(() => options.XmlEncryptor.Encrypt(xElement));
XmlEncryption\EncryptedXmlDecryptorTests.cs (3)
24var ex = Assert.Throws<CryptographicException>(() => 42var ex = Assert.Throws<CryptographicException>(() => 60var ex = Assert.Throws<CryptographicException>(() =>
Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests (2)
HealthCheckMiddlewareTests.cs (2)
936var exception = Assert.Throws<InvalidOperationException>(() => 947var exception = Assert.Throws<InvalidOperationException>(() =>
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (6)
JsonTranscodingServiceMethodProviderTests.cs (6)
97var ex = Assert.Throws<InvalidOperationException>(() => FindGrpcEndpoint(endpoints, nameof(JsonTranscodingGreeterService.NoOption))); 166var ex = Assert.Throws<InvalidOperationException>(() => MapEndpoints<JsonTranscodingInvalidResponseBodyGreeterService>()); 178var ex = Assert.Throws<InvalidOperationException>(() => MapEndpoints<JsonTranscodingInvalidNestedResponseBodyGreeterService>()); 190var ex = Assert.Throws<InvalidOperationException>(() => MapEndpoints<JsonTranscodingInvalidBodyGreeterService>()); 202var ex = Assert.Throws<InvalidOperationException>(() => MapEndpoints<JsonTranscodingInvalidNestedBodyGreeterService>()); 214var ex = Assert.Throws<InvalidOperationException>(() => MapEndpoints<JsonTranscodingInvalidPatternGreeterService>());
Microsoft.AspNetCore.Hosting.Tests (15)
WebHostBuilderTests.cs (9)
69Assert.Throws<ArgumentNullException>(() => builder.UseServer(server).UseStartup((Func<WebHostBuilderContext, object>)null)); 77var ex = Assert.Throws<InvalidOperationException>(() => builder.UseServer(server).UseStartup<object>(context => null).Build()); 424var exception = Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 441Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 454var exception = Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 841var ex = Assert.Throws<InvalidOperationException>(() => builder.Build()); 1005var exception = Assert.Throws<NotSupportedException>(() => builder.Build()); 1260Assert.Throws<ArgumentNullException>(() => new HostingStartupAttribute(null)); 1266Assert.Throws<ArgumentException>(() => new HostingStartupAttribute(typeof(WebHostTests)));
WebHostTests.cs (6)
34Assert.Throws<ArgumentNullException>(() => CreateBuilder().UseStartup((string)null)); 734Assert.Throws<NotImplementedException>(() => builder.Build()); 960Assert.Throws<ObjectDisposedException>(() => capturedContext.TraceIdentifier); 961Assert.Throws<ObjectDisposedException>(() => capturedContext.Features.Get<IHttpRequestIdentifierFeature>()); 963Assert.Throws<ObjectDisposedException>(() => capturedRequest.Scheme); 990var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
Microsoft.AspNetCore.Http.Abstractions.Tests (27)
EndpointFilterInvocationContextOfTTests.cs (5)
24Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(1)); 25Assert.Throws<InvalidCastException>(() => context.GetArgument<int>(0)); 26Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(3)); 80Assert.Throws<NullReferenceException>(() => context.GetArgument<int>(1)); 81Assert.Throws<NullReferenceException>(() => context.GetArgument<bool>(2));
EndpointMetadataCollectionTests.cs (1)
90Assert.Throws<InvalidOperationException>(() => metadata.GetRequiredMetadata<string>());
HostStringTest.cs (1)
171Assert.Throws<FormatException>(() => HostString.MatchesAny("example.com:1abc", new StringSegment[] { "example.com" }));
HttpProtocolTests.cs (1)
131Assert.Throws<ArgumentOutOfRangeException>(() => HttpProtocol.GetHttpProtocol(version));
MapPathMiddlewareTests.cs (3)
41Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", configuration: null!)); 42Assert.Throws<ArgumentNullException>(() => new MapMiddleware(noMiddleware, null!)); 131Assert.Throws<ArgumentException>(() => new ApplicationBuilder(serviceProvider: null!).Map(matchPath, map => { }).Build());
MapPredicateMiddlewareTests.cs (6)
51Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null!, UseNotImplemented)); 52Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, configuration: null!)); 53Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null!, noOptions)); 54Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null!)); 55Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(null!, noOptions)); 56Assert.Throws<ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null!));
UseMiddlewareTest.cs (10)
15var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNoParametersStub))); 29var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareAsyncNoParametersStub))); 43var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNonTaskReturnStub))); 57var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareAsyncNonTaskReturnStub))); 71var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNoInvokeStub))); 84var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokesStub))); 97var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokeAsyncStub))); 110var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokeAndInvokeAsyncStub))); 148var exception = Assert.Throws<NotSupportedException>(() => builder.Build()); 156var exception = Assert.Throws<NotSupportedException>(() => builder.UseMiddleware(typeof(Middleware), "arg"));
Microsoft.AspNetCore.Http.Connections.Tests (4)
HttpConnectionManagerTests.cs (2)
38Assert.Throws<ArgumentOutOfRangeException>(() => httpOptions.TransportMaxBufferSize = -1); 39Assert.Throws<ArgumentOutOfRangeException>(() => httpOptions.ApplicationMaxBufferSize = -1);
NegotiateProtocolTests.cs (2)
62var exception = Assert.Throws<InvalidDataException>(() => NegotiateProtocol.ParseResponse(responseData)); 82var exception = Assert.Throws<InvalidDataException>(() => NegotiateProtocol.ParseResponse(responseData));
Microsoft.AspNetCore.Http.Extensions.Tests (46)
HeaderDictionaryTypeExtensionsTest.cs (2)
161Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().Get<object>("custom")); 285Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().GetList<object>("custom"));
ProblemDetailsServiceCollectionExtensionsTest.cs (1)
125Assert.Throws<InvalidOperationException>(() => jsonOptions.Value);
RequestDelegateFactoryTests.cs (38)
210var exNullAction = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(handler: null!)); 211var exNullMethodInfo1 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(methodInfo: null!)); 729var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(action)); 738var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(lambda.Compile())); 906var ex1 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method1)); 907var ex2 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method2)); 908var ex3 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method3)); 932Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestAttributedInvalidAction)); 933Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestInferredInvalidAction)); 934Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBothInvalidAction)); 943Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestTryParseStruct)); 944Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestTryParseClass)); 966var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBindAsyncStruct)); 967Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBindAsyncClass)); 1021var exception = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(@delegate)); 1031Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestNestedParameterListRecordOnType)); 1032Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestNestedParameterListRecordOnArgument)); 1122var outParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(OutMethod)); 1123var inParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(InMethod)); 1124var refParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(RefMethod)); 1412Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction, new() { ServiceProvider = httpContext.RequestServices })); 2003Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileAndJson)); 2004Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFilesAndJson)); 2005Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileAndJsonWithAttribute)); 2006Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileCollectionAndJson)); 2007Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormCollectionAndJson)); 2008Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormWithAttributeAndJson)); 2009Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFile)); 2010Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFiles)); 2011Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFileCollection)); 2012Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFileWithAttribute)); 2013Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormCollection)); 2014Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormWithAttribute)); 2027var nse = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction)); 2076var nse = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction)); 2113var exception = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(action)); 2126var exception = Assert.Throws<ArgumentException>(() => RequestDelegateFactory.Create(TestAction)); 3226var exception = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(@delegate));
RequestDelegateGenerator\CompileTimeCreationTests.cs (1)
426var exception = Assert.Throws<InvalidOperationException>(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider));
RequestDelegateGenerator\RequestDelegateCreationTests.KeyServices.cs (2)
48var exception = Assert.Throws<NotSupportedException>(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider)); 216var runtimeException = Assert.Throws<InvalidOperationException>(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider));
RequestDelegateGenerator\RuntimeCreationTests.cs (1)
26var ex = Assert.Throws<InvalidOperationException>(() => GetEndpointFromCompilation(compilation));
UriHelperTests.cs (1)
180Assert.Throws<ArgumentNullException>(() => UriHelper.BuildAbsolute(null, resHost, resPath, resPath, resQuery, resFragment));
Microsoft.AspNetCore.Http.Results.Tests (1)
ResultsOfTHelperTests.cs (1)
75Assert.Throws<InvalidOperationException>(() => GetMetadata<DefaultInterfaceMethodEndpointMetadataProvider>());
Microsoft.AspNetCore.Http.Tests (15)
BindingAddressTests.cs (3)
16Assert.Throws<FormatException>(() => BindingAddress.Parse(url)); 30Assert.Throws<FormatException>(() => BindingAddress.Parse(url)); 40Assert.Throws<FormatException>(() => BindingAddress.Parse(url));
DefaultHttpContextTests.cs (1)
23var exception = Assert.Throws<InvalidOperationException>(() => context.Session);
HeaderDictionaryTests.cs (6)
93Assert.Throws<InvalidOperationException>(() => headers["header1"] = "value1"); 94Assert.Throws<InvalidOperationException>(() => ((IDictionary<string, StringValues>)headers)["header1"] = "value1"); 95Assert.Throws<InvalidOperationException>(() => headers.ContentLength = 12); 99Assert.Throws<InvalidOperationException>(() => headers.Remove(new KeyValuePair<string, StringValues>("header1", "value1"))); 100Assert.Throws<InvalidOperationException>(() => headers.Remove("header1")); 133Assert.Throws<KeyNotFoundException>(() => asIDictionary["Header1"]);
Timeouts\RequestTimeoutOptionsTests.cs (5)
49Assert.Throws<ArgumentException>(() => options.AddPolicy("", TimeSpan.FromSeconds(47))); 50Assert.Throws<ArgumentNullException>(() => options.AddPolicy(null, TimeSpan.FromSeconds(47))); 52Assert.Throws<ArgumentException>(() => options.AddPolicy("", new RequestTimeoutPolicy())); 53Assert.Throws<ArgumentNullException>(() => options.AddPolicy(null, new RequestTimeoutPolicy())); 55Assert.Throws<ArgumentNullException>(() => options.AddPolicy("policy1", null));
Microsoft.AspNetCore.HttpLogging.Tests (14)
HttpLoggingAttributeTests.cs (4)
11var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpLoggingAttribute(HttpLoggingFields.None) { RequestBodyLogLimit = -1 }); 14ex = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpLoggingAttribute(HttpLoggingFields.None) { ResponseBodyLogLimit = -1 }); 23Assert.Throws<InvalidOperationException>(() => attribute.RequestBodyLogLimit); 24Assert.Throws<InvalidOperationException>(() => attribute.ResponseBodyLogLimit);
HttpLoggingEndpointConventionBuilderTests.cs (2)
44var ex = Assert.Throws<ArgumentOutOfRangeException>(() => 48ex = Assert.Throws<ArgumentOutOfRangeException>(() =>
HttpLoggingServicesExtensionsTests.cs (4)
14Assert.Throws<ArgumentNullException>(() => 21Assert.Throws<ArgumentNullException>(() => 33var ex = Assert.Throws<InvalidOperationException>(() => appBuilder.UseHttpLogging()); 45var ex = Assert.Throws<InvalidOperationException>(() => appBuilder.UseW3CLogging());
W3CLoggerOptionsTests.cs (4)
21var ex = Assert.Throws<ArgumentOutOfRangeException>(() => options.FileSizeLimit = -1); 29Assert.Throws<ArgumentException>(() => options.FileName = ""); 36Assert.Throws<ArgumentException>(() => options.LogDirectory = ""); 43var ex = Assert.Throws<ArgumentOutOfRangeException>(() => options.FlushInterval = TimeSpan.FromSeconds(-1));
Microsoft.AspNetCore.HttpOverrides.Tests (5)
CertificateForwardingTest.cs (2)
24Assert.Throws<OptionsValidationException>(() => options.Value); 34Assert.Throws<OptionsValidationException>(() => options.Value);
IPNetworkTest.cs (3)
72var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new IPNetwork(address, prefixLength)); 96var ex = Assert.Throws<FormatException>(() => IPNetwork.Parse(input)); 105var ex = Assert.Throws<ArgumentOutOfRangeException>(() => IPNetwork.Parse(input));
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (3)
UserStoreEncryptPersonalDataTest.cs (1)
290var e = Assert.Throws<InvalidOperationException>(() => dbContext.Database.EnsureCreated());
UserStoreWithGenericsTest.cs (2)
83var e = Assert.Throws<InvalidOperationException>(() => builder.AddEntityFrameworkStores<ContextWithGenerics>()); 92var e = Assert.Throws<InvalidOperationException>(() => builder.AddEntityFrameworkStores<ContextWithGenerics>());
Microsoft.AspNetCore.Identity.Test (12)
IdentityBuilderTest.cs (8)
32Assert.Throws<ArgumentException>(() => new IdentityBuilder(typeof(int), new ServiceCollection())); 38Assert.Throws<ArgumentException>(() => new IdentityBuilder(typeof(PocoUser), typeof(int), new ServiceCollection())); 50Assert.Throws<InvalidOperationException>(() => sp.GetService<RoleManager<PocoRole>>()); 256Assert.Throws<InvalidOperationException>(() => builder.AddUserManager<object>()); 257Assert.Throws<InvalidOperationException>(() => builder.AddRoleManager<object>()); 258Assert.Throws<InvalidOperationException>(() => builder.AddSignInManager<object>()); 267Assert.Throws<InvalidOperationException>(() => builder.AddTokenProvider<object>("whatevs")); 268Assert.Throws<InvalidOperationException>(() => builder.AddTokenProvider("whatevs", typeof(object)));
RoleManagerTest.cs (1)
55Assert.Throws<NotSupportedException>(() => manager.Roles.Count());
UserManagerTest.cs (3)
683Assert.Throws<NotSupportedException>(() => manager.Users.Count()); 811var e = Assert.Throws<InvalidOperationException>(() => services.BuildServiceProvider().GetService<UserManager<PocoUser>>()); 822var e = Assert.Throws<InvalidOperationException>(() => services.BuildServiceProvider().GetService<UserManager<PocoUser>>());
Microsoft.AspNetCore.InternalTesting.Tests (7)
MaximumOSVersionAttributeTest.cs (3)
14Assert.Throws<NotImplementedException>(() => new MaximumOSVersionAttribute(OperatingSystems.Linux, "2.5")); 20Assert.Throws<NotImplementedException>(() => new MaximumOSVersionAttribute(OperatingSystems.MacOSX, "2.5")); 26Assert.Throws<NotImplementedException>(() => new MaximumOSVersionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, "2.5"));
MinimumOSVersionAttributeTest.cs (3)
14Assert.Throws<NotImplementedException>(() => new MinimumOSVersionAttribute(OperatingSystems.Linux, "2.5")); 20Assert.Throws<NotImplementedException>(() => new MinimumOSVersionAttribute(OperatingSystems.MacOSX, "2.5")); 26Assert.Throws<NotImplementedException>(() => new MinimumOSVersionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, "2.5"));
TestPathUtilitiesTest.cs (1)
18var exception = Assert.Throws<Exception>(() => TestPathUtilities.GetSolutionRootDirectory("NotTesting"));
Microsoft.AspNetCore.Localization.Tests (1)
RequestLocalizationOptionsTest.cs (1)
55Assert.Throws<ArgumentNullException>(() => options.DefaultRequestCulture = null);
Microsoft.AspNetCore.Mvc.Abstractions.Test (6)
ModelBinding\BindingInfoTest.cs (1)
327Assert.Throws<NotSupportedException>(() => BindingInfo.GetBindingInfo(attributes, modelMetadata));
ModelBinding\ModelMetadataTest.cs (3)
386Assert.Throws<NotImplementedException>(() => metadata.ContainerMetadata); 396var result = Assert.Throws<NotImplementedException>(() => metadata.GetMetadataForType(typeof(string))); 406var result = Assert.Throws<NotImplementedException>(() => metadata.GetMetadataForProperties(typeof(string)));
ModelBinding\ModelStateDictionaryTest.cs (2)
1652var invalidException = Assert.Throws<InvalidOperationException>(() => dictionary.TryAddModelException(key, exception)); 1670var invalidException = Assert.Throws<InvalidOperationException>(() => dictionary.TryAddModelError(key, "errorMessage"));
Microsoft.AspNetCore.Mvc.Core.Test (40)
ActionResultOfTTest.cs (3)
18var ex = Assert.Throws<ArgumentException>(() => new ActionResult<FileStreamResult>(value: input)); 29var ex = Assert.Throws<ArgumentException>(() => new ActionResult<FileStreamResult>(result: actionResult)); 40var ex = Assert.Throws<ArgumentException>(() => new ActionResult<TestResult>(value: result));
ApplicationParts\RelatedAssemblyPartTest.cs (2)
36var ex = Assert.Throws<InvalidOperationException>(() => RelatedAssemblyAttribute.GetRelatedAssemblies(assembly, throwOnError: true)); 51Assert.Throws<FileNotFoundException>(() => RelatedAssemblyAttribute.GetRelatedAssemblies(assembly, throwOnError: true));
Builder\MvcApplicationBuilderExtensionsTest.cs (1)
24var exception = Assert.Throws<InvalidOperationException>(
ConsumesAttributeTests.cs (3)
28var exception = Assert.Throws<FormatException>(() => new ConsumesAttribute(contentType)); 45var ex = Assert.Throws<FormatException>( 65var ex = Assert.Throws<InvalidOperationException>(
Controllers\ServiceBasedControllerActivatorTest.cs (1)
66var ex = Assert.Throws<InvalidOperationException>(
Formatters\InputFormatterTest.cs (2)
393Assert.Throws<InvalidOperationException>(() => formatter.CanRead(context)); 403Assert.Throws<InvalidOperationException>(
Formatters\MediaTypeTest.cs (1)
131Assert.Throws<ArgumentException>(() => new MediaType("lengthof9", 5, 5));
Formatters\OutputFormatterTests.cs (2)
216Assert.Throws<InvalidOperationException>(() => formatter.CanWriteResult(context)); 227Assert.Throws<InvalidOperationException>(
Formatters\TextInputFormatterTest.cs (1)
57Assert.Throws<InvalidOperationException>(() => formatter.TestSelectCharacterEncoding(context));
ModelBinding\Binders\BodyModelBinderProviderTest.cs (1)
52var exception = Assert.Throws<InvalidOperationException>(() => provider.GetBinder(context));
ModelBinding\Binders\ComplexTypeModelBinderTest.cs (3)
539var exception = Assert.Throws<InvalidOperationException>(() => binder.CreateModelPublic(bindingContext)); 564var exception = Assert.Throws<InvalidOperationException>(() => binder.CreateModelPublic(bindingContext)); 581var exception = Assert.Throws<InvalidOperationException>(() => binder.CreateModelPublic(bindingContext));
ModelBinding\Binders\FormCollectionModelBinderProviderTest.cs (1)
20var exception = Assert.Throws<InvalidOperationException>(() => provider.GetBinder(context));
ModelBinding\Metadata\ModelAttributesTest.cs (1)
298var exception = Assert.Throws<InvalidOperationException>(() => ModelAttributes.GetAttributesForProperty(modelType, property));
ModelBinding\ModelBinderFactoryTest.cs (2)
34var exception = Assert.Throws<InvalidOperationException>(() => factory.CreateBinder(context)); 56var exception = Assert.Throws<InvalidOperationException>(() => factory.CreateBinder(context));
ModelBinding\Validation\DefaultComplexObjectValidationStrategyTest.cs (3)
150Assert.Throws<NullReferenceException>(() => entry.Model); 156Assert.Throws<NullReferenceException>(() => entry.Model); 182var exception = Assert.Throws<InvalidOperationException>(() => BufferEntries(enumerator));
MvcOptionsTest.cs (1)
15var ex = Assert.Throws<ArgumentOutOfRangeException>(() => options.MaxModelValidationErrors = -1);
ProducesAttributeTests.cs (2)
100var ex = Assert.Throws<FormatException>( 122var ex = Assert.Throws<InvalidOperationException>(
ProducesResponseTypeAttributeTests.cs (1)
41var ex = Assert.Throws<InvalidOperationException>(
ResponseCacheAttributeTest.cs (1)
54var ex = Assert.Throws<InvalidOperationException>(
Routing\ActionEndpointFactoryTest.cs (1)
213var exception = Assert.Throws<InvalidOperationException>(() => CreateAttributeRoutedEndpoint(action));
Routing\ControllerLinkGeneratorExtensionsTest.cs (4)
25var exception = Assert.Throws<ArgumentException>(() => 29exception = Assert.Throws<ArgumentNullException>(() => 33exception = Assert.Throws<ArgumentNullException>(() => 37exception = Assert.Throws<ArgumentNullException>(() =>
Routing\KnownRouteValueConstraintTests.cs (1)
191var ex = Assert.Throws<InvalidOperationException>(
Routing\UrlHelperExtensionsTest.cs (1)
549var ex = Assert.Throws<InvalidOperationException>(() => urlHelper.Object.Page(expected));
Routing\UrlHelperTestBase.cs (1)
1088var ex = Assert.Throws<InvalidOperationException>(() => urlHelper.ActionLink("contact", "home"));
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (2)
XmlDataContractSerializerInputFormatterTest.cs (1)
452Assert.Throws<ArgumentOutOfRangeException>(() => formatter.MaxDepth = 0);
XmlSerializerInputFormatterTest.cs (1)
469Assert.Throws<ArgumentOutOfRangeException>(() => formatter.MaxDepth = 0);
Microsoft.AspNetCore.Mvc.FunctionalTests (3)
AntiforgeryMiddlewareTest.cs (1)
63var exception = Assert.Throws<InvalidOperationException>(() => app.MapControllers());
SimpleWithWebApplicationBuilderExceptionTests.cs (1)
18var ex = Assert.Throws<InvalidOperationException>(() => _fixture.CreateClient());
TestingInfrastructureTests.cs (1)
48var ex = Assert.Throws<InvalidOperationException>(() => factory.CreateClient());
Microsoft.AspNetCore.Mvc.IntegrationTests (6)
ValidationIntegrationTests.cs (3)
1489Assert.Throws<NullReferenceException>(() => model.ValidateNeverLength); 1596Assert.Throws<NullReferenceException>(() => model.ControlLength); 1686Assert.Throws<NullReferenceException>(() => model.ControlLength);
ValidationWithRecordIntegrationTests.cs (3)
1333Assert.Throws<NullReferenceException>(() => model.ValidateNeverLength); 1404Assert.Throws<NullReferenceException>(() => model.ControlLength); 1492Assert.Throws<NullReferenceException>(() => model.ControlLength);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (2)
DependencyInjection\MvcNewtonsoftJsonOptionsExtensionsTest.cs (2)
221var exception = Assert.Throws<InvalidOperationException>( 235var exception = Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.Mvc.Razor.Test (1)
RazorPageTest.cs (1)
444ex = Assert.Throws<InvalidOperationException>(() => v.RenderSection("bar"));
Microsoft.AspNetCore.Mvc.RazorPages.Test (1)
Infrastructure\ServiceBasedPageModelActivatorProviderTest.cs (1)
115var ex = Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (34)
AttributeDictionaryTest.cs (1)
387Assert.Throws<KeyNotFoundException>(() => attributes["nada"]);
ControllerUnitTestabilityTests.cs (1)
557Assert.Throws<ArgumentNullException>(() => controller.Redirect_Action(null));
DefaultDisplayTemplatesTest.cs (1)
366var ex = Assert.Throws<ArgumentException>(() => helper.DisplayFor(m => m.Property1));
DefaultEditorTemplatesTest.cs (1)
1314var ex = Assert.Throws<FormatException>(() => helper.EditorFor(m => m.Property1));
DefaultHtmlGeneratorTest.cs (1)
525var exception = Assert.Throws<InvalidOperationException>(() => htmlGenerator.GetCurrentValues(
Infrastructure\DefaultTempDataSerializerTest.cs (1)
51var ex = Assert.Throws<InvalidOperationException>(() => testProvider.Serialize(input));
RemoteAttributeTest.cs (1)
149var exception = Assert.Throws<InvalidOperationException>(() => testableAttribute.InvokeGetUrl(context));
Rendering\HtmlHelperCheckboxTest.cs (1)
81var ex = Assert.Throws<FormatException>(
Rendering\HtmlHelperDisplayNameExtensionsTest.cs (2)
166var exception = Assert.Throws<InvalidOperationException>( 181var exception = Assert.Throws<InvalidOperationException>(
Rendering\HtmlHelperLabelExtensionsTest.cs (1)
429var exception = Assert.Throws<InvalidOperationException>(
Rendering\HtmlHelperPartialExtensionsTest.cs (1)
85var actual = Assert.Throws<InvalidOperationException>(() => partialMethod(helper.Object));
ViewComponents\DefaultViewComponentDescriptorProviderTest.cs (5)
22var ex = Assert.Throws<InvalidOperationException>(() => provider.GetViewComponents().ToArray()); 38var ex = Assert.Throws<InvalidOperationException>(() => provider.GetViewComponents().ToArray()); 53var ex = Assert.Throws<InvalidOperationException>(() => provider.GetViewComponents().ToArray()); 67var ex = Assert.Throws<InvalidOperationException>(() => provider.GetViewComponents().ToArray()); 80var ex = Assert.Throws<InvalidOperationException>(() => provider.GetViewComponents().ToArray());
ViewComponents\DefaultViewComponentSelectorTest.cs (2)
104var ex = Assert.Throws<InvalidOperationException>(() => selector.SelectComponent("Ambiguous")); 125var ex = Assert.Throws<InvalidOperationException>(() => selector.SelectComponent(name));
ViewDataDictionaryOfTModelTest.cs (10)
216var exception = Assert.Throws<InvalidOperationException>(() => new ViewDataDictionary<string>(source)); 219exception = Assert.Throws<InvalidOperationException>(() => new ViewDataDictionary<string>(source, model: 24)); 385var exception = Assert.Throws<InvalidOperationException>(() => viewData1.Model = 23); 388exception = Assert.Throws<InvalidOperationException>(() => viewData2.Model = 24); 391exception = Assert.Throws<InvalidOperationException>(() => viewData3.Model = 25); 395exception = Assert.Throws<InvalidOperationException>(() => viewData4.Model = 26); 412var exception = Assert.Throws<InvalidOperationException>(() => viewData1.Model = null); 415exception = Assert.Throws<InvalidOperationException>(() => viewData2.Model = null); 418exception = Assert.Throws<InvalidOperationException>(() => viewData3.Model = null); 422exception = Assert.Throws<InvalidOperationException>(() => viewData4.Model = null);
ViewDataOfTTest.cs (2)
18Exception ex = Assert.Throws<InvalidOperationException>(() => viewData.Model = null); 30Exception ex = Assert.Throws<InvalidOperationException>(() => viewData.Model = DateTime.UtcNow);
ViewEngines\CompositeViewEngineTest.cs (3)
44var exception = Assert.Throws<InvalidOperationException>( 172var exception = Assert.Throws<InvalidOperationException>( 311var exception = Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.OpenApi.Tests (1)
Services\OpenApiGeneratorTests.cs (1)
77var ex = Assert.Throws<InvalidOperationException>(() => GetOpenApiOperation(lambda.Compile()));
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
108Assert.Throws<KeyNotFoundException>(() => env[key]);
Microsoft.AspNetCore.RateLimiting.Tests (8)
RateLimitingApplicationBuilderExtensionsTests.cs (3)
16Assert.Throws<ArgumentNullException>(() => RateLimiterApplicationBuilderExtensions.UseRateLimiter(null)); 23Assert.Throws<ArgumentNullException>(() => appBuilder.UseRateLimiter(null)); 34var ex = Assert.Throws<InvalidOperationException>(() => appBuilder.UseRateLimiter());
RateLimitingOptionsTests.cs (5)
16Assert.Throws<ArgumentNullException>(() => options.AddPolicy<string>(null, context => RateLimitPartition.GetNoLimiter<string>("myKey"))); 23Assert.Throws<ArgumentNullException>(() => options.AddPolicy<string>("myKey", partitioner: null)); 30Assert.Throws<ArgumentNullException>(() => options.AddPolicy<string>("myKey", policy: null)); 38Assert.Throws<ArgumentException>(() => options.AddPolicy<string>("myKey", context => RateLimitPartition.GetNoLimiter<string>("yourKey"))); 46Assert.Throws<ArgumentException>(() => options.AddPolicy<string, TestRateLimiterPolicy>("myKey"));
Microsoft.AspNetCore.ResponseCaching.Tests (1)
ResponseCachingFeatureTests.cs (1)
52Assert.Throws<ArgumentException>(() => new ResponseCachingFeature().VaryByQueryKeys = value);
Microsoft.AspNetCore.Routing.FunctionalTests (1)
MinimalFormTests.cs (1)
229exception = Assert.Throws<InvalidOperationException>(() => app.UseAntiforgery());
Microsoft.AspNetCore.Routing.Tests (44)
Builder\EndpointRoutingApplicationBuilderExtensionsTest.cs (4)
28var ex = Assert.Throws<InvalidOperationException>(() => app.UseRouting()); 45var ex = Assert.Throws<InvalidOperationException>(() => app.UseEndpoints(endpoints => { })); 118var ex = Assert.Throws<InvalidOperationException>(() => app.UseEndpoints(endpoints => { })); 140var ex = Assert.Throws<InvalidOperationException>(() => app.Map("/Test", b => b.UseEndpoints(endpoints => { })));
Builder\GroupTest.cs (1)
309var ex = Assert.Throws<NotSupportedException>(() => dataSource.Endpoints);
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (1)
469Assert.Throws<InvalidOperationException>(() => endpointBuilder.WithMetadata(new RouteNameMetadata("Foo")));
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (6)
216var ex = Assert.Throws<InvalidOperationException>(() => dataSource.Endpoints); 227var ex = Assert.Throws<InvalidOperationException>(() => dataSource.Endpoints); 255var ex = Assert.Throws<InvalidOperationException>(() => dataSource.Endpoints); 499Assert.Throws<InvalidOperationException>(() => endpointBuilder.WithMetadata(new RouteNameMetadata("Foo"))); 596var ex = Assert.Throws<InvalidOperationException>(() => dataSource.Endpoints); 654var ex = Assert.Throws<InvalidOperationException>(() => dataSource.Endpoints);
Builder\RoutingBuilderExtensionsTest.cs (3)
25var exception = Assert.Throws<InvalidOperationException>( 42var ex = Assert.Throws<InvalidOperationException>(() => app.UseRouter(Mock.Of<IRouter>())); 59var ex = Assert.Throws<InvalidOperationException>(() => app.UseRouter(b => { }));
CompositeEndpointDataSourceTest.cs (4)
77Assert.Same(ex, Assert.Throws<Exception>(() => compositeDataSource.Endpoints)); 78Assert.Same(ex, Assert.Throws<Exception>(() => compositeDataSource.Endpoints)); 79Assert.Same(ex, Assert.Throws<Exception>(() => compositeDataSource.GetGroupedEndpoints(groupContext))); 80Assert.Same(ex, Assert.Throws<Exception>(() => compositeDataSource.GetGroupedEndpoints(groupContext)));
DefaultEndpointDataSourceTests.cs (2)
49var actual = Assert.Throws<ArgumentNullException>(() => new DefaultEndpointDataSource(endpoints)); 93var actual = Assert.Throws<ArgumentNullException>(() => new DefaultEndpointDataSource(endpoints));
DefaultInlineConstraintResolverTest.cs (4)
48var ex = Assert.Throws<RouteCreationException>( 319var ex = Assert.Throws<RouteCreationException>(() => resolver.ResolveConstraint("custom")); 334var ex = Assert.Throws<RouteCreationException>(() => resolver.ResolveConstraint("custom(5,6)")); 360var ex = Assert.Throws<RouteCreationException>(() => _constraintResolver.ResolveConstraint("int(5,6)"));
DefaultParameterPolicyFactoryTest.cs (4)
21var exception = Assert.Throws<InvalidOperationException>( 43var exception = Assert.Throws<RouteCreationException>( 331var exception = Assert.Throws<RouteCreationException>( 372var exception = Assert.Throws<RouteCreationException>(
Patterns\RoutePatternFactoryTest.cs (8)
76var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Pattern( 124var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Pattern( 390var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Pattern( 757var ex = Assert.Throws<RoutePatternException>(() => RoutePatternFactory.Combine(left, right)); 805var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Combine(left, right)); 817var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Combine(left, right)); 830var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Combine(left, right)); 842var ex = Assert.Throws<InvalidOperationException>(() => RoutePatternFactory.Combine(left, right));
RouteBuilderTest.cs (1)
43var exception = Assert.Throws<InvalidOperationException>(() => new RouteBuilder(applicationBuilderMock.Object));
RouteCollectionTest.cs (2)
303var ex = Assert.Throws<InvalidOperationException>(() => routeCollection.GetVirtualPath(virtualPathContext)); 325var ex = Assert.Throws<InvalidOperationException>(() => routeCollection.GetVirtualPath(virtualPathContext));
RouteEndpointBuilderTest.cs (1)
23var ex = Assert.Throws<ArgumentNullException>(() => new RouteEndpointBuilder(context => Task.CompletedTask, routePattern: null, order: 0));
RouteTest.cs (1)
31var exception = Assert.Throws<RouteCreationException>(
TemplateParserDefaultValuesTests.cs (2)
60var ex = Assert.Throws<RouteCreationException>( 85var ex = Assert.Throws<RouteCreationException>(
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (12)
OpaqueUpgradeTests.cs (1)
146Assert.Throws<InvalidOperationException>(() => feature.MaxRequestBodySize = 12);
RequestBodyLimitTests.cs (9)
165var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 168ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 215var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 218ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 241var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 244ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 291var ex = Assert.Throws<BadHttpRequestException>(() => body.EndRead(body.BeginRead(input, 0, input.Length, null, null))); 294ex = Assert.Throws<BadHttpRequestException>(() => body.EndRead(body.BeginRead(input, 0, input.Length, null, null))); 321var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length));
ResponseHeaderTests.cs (2)
228Assert.Throws<InvalidOperationException>(() => response.StatusCode = 404); 259Assert.Throws<InvalidOperationException>(() => response.StatusCode = 404);
Microsoft.AspNetCore.Server.HttpSys.Tests (4)
UrlPrefixTests.cs (4)
18Assert.Throws<FormatException>(() => UrlPrefix.Create(url)); 27Assert.Throws<ArgumentOutOfRangeException>(() => UrlPrefix.Create(url)); 39Assert.Throws<ArgumentException>(() => UrlPrefix.Create(url)); 49Assert.Throws<FormatException>(() => UrlPrefix.Create(url));
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (73)
BodyControlTests.cs (3)
101Assert.Throws<Exception>(() => requestPipe.TryRead(out var res))); 118Assert.Throws<ObjectDisposedException>(() => requestPipe.TryRead(out var res)); 134Assert.Throws<ObjectDisposedException>(() => responsePipe.GetMemory());
DiagnosticMemoryPoolTests.cs (8)
56var exception = Assert.Throws<InvalidOperationException>(() => block.Memory); 69var exception = Assert.Throws<InvalidOperationException>(() => memory.Pin()); 104var exception = Assert.Throws<InvalidOperationException>(() => MemoryMarshal.TryGetArray<byte>(memory, out _)); 116var exception = Assert.Throws<ObjectDisposedException>(() => block.Memory); 131var exception = Assert.Throws<ObjectDisposedException>(() => memory.Pin()); 170var exception = Assert.Throws<ObjectDisposedException>(() => MemoryMarshal.TryGetArray<byte>(memory, out _)); 193var exception = Assert.Throws<InvalidOperationException>(() => block.Memory); 210var exception = Assert.Throws<InvalidOperationException>(() => block.Memory);
Http1\Http1ConnectionTests.cs (6)
56var exception = Assert.Throws<InvalidOperationException>(() => TakeMessageHeaders(readableBuffer, trailers: false, out _consumed, out _examined)); 304Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).StatusCode = StatusCodes.Status404NotFound); 315Assert.Throws<InvalidOperationException>(() => ((IHttpResponseFeature)_http1Connection).ReasonPhrase = "Reason phrase"); 557var exception = Assert.Throws<BadHttpRequestException>(() => 937var ex = Assert.Throws<InvalidOperationException>(() => ((IHttpMaxRequestBodySizeFeature)_http1Connection).MaxRequestBodySize = 1); 945var ex = Assert.Throws<ArgumentOutOfRangeException>(() => ((IHttpMaxRequestBodySizeFeature)_http1Connection).MaxRequestBodySize = -1);
Http2\Http2HttpProtocolFeatureCollectionTests.cs (3)
54Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate); 55Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate = new MinDataRate(1, TimeSpan.FromSeconds(2))); 61Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate);
Http3\Http3HttpProtocolFeatureCollectionTests.cs (3)
54Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate); 55Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate = new MinDataRate(1, TimeSpan.FromSeconds(2))); 61Assert.Throws<NotSupportedException>(() => minRateFeature.MinDataRate);
HttpParserTests.cs (7)
86var exception = Assert.Throws<BadHttpRequestException>(() => 114var exception = Assert.Throws<BadHttpRequestException>(() => 133var exception = Assert.Throws<BadHttpRequestException>(() => 152var exception = Assert.Throws<BadHttpRequestException>(() => 170var exception = Assert.Throws<BadHttpRequestException>(() => 513var exception = Assert.Throws<BadHttpRequestException>(() => 524exception = Assert.Throws<BadHttpRequestException>(() =>
HttpRequestHeadersTests.cs (3)
97Assert.Throws<KeyNotFoundException>(() => headers["custom"]); 98Assert.Throws<KeyNotFoundException>(() => headers["host"]); 99Assert.Throws<KeyNotFoundException>(() => headers["Content-Length"]);
HttpRequestStreamTests.cs (5)
43Assert.Throws<NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin)); 50Assert.Throws<NotSupportedException>(() => stream.Length); 64Assert.Throws<NotSupportedException>(() => stream.Position); 65Assert.Throws<NotSupportedException>(() => stream.Position = 0); 120var ioEx = Assert.Throws<InvalidOperationException>(() => stream.Read(new byte[1], 0, 1));
HttpResponseHeadersTests.cs (2)
282Assert.Throws<InvalidOperationException>(() => dictionary["my-header"] = "other-value"); 293Assert.Throws<InvalidOperationException>(() => dictionary.Remove("my-header"));
HttpResponseStreamTests.cs (7)
43Assert.Throws<NotSupportedException>(() => stream.Read(new byte[1], 0, 1)); 50Assert.Throws<NotSupportedException>(() => stream.ReadByte()); 64Assert.Throws<NotSupportedException>(() => stream.BeginRead(new byte[1], 0, 1, null, null)); 71Assert.Throws<NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin)); 78Assert.Throws<NotSupportedException>(() => stream.Length); 92Assert.Throws<NotSupportedException>(() => stream.Position); 93Assert.Throws<NotSupportedException>(() => stream.Position = 0);
KestrelServerLimitsTests.cs (9)
108var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().MaxRequestHeadersTotalSize = value); 173var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits { KeepAliveTimeout = value }); 202var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits { RequestHeadersTimeout = value }); 235var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().MaxConcurrentConnections = value); 259var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().MaxConcurrentUpgradedConnections = value); 290var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().MaxRequestBodySize = value); 322var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().Http2.MaxFrameSize = value); 337var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().Http2.HeaderTableSize = value); 353var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new KestrelServerLimits().Http2.MaxRequestHeaderFieldSize = value);
KestrelServerOptionsTests.cs (3)
63Assert.Throws<InvalidOperationException>(() => options.Configure()); 74Assert.Throws<InvalidOperationException>(() => options.Configure()); 102var ex = Assert.Throws<ArgumentNullException>(() => options.RequestHeaderEncodingSelector = null);
KestrelServerTests.cs (1)
281var exception = Assert.Throws<ArgumentNullException>(() =>
MemoryPoolTests.cs (1)
46var exception = Assert.Throws<ObjectDisposedException>(() => memoryPool.Rent());
MessageBodyTests.cs (10)
146Assert.Throws<InvalidOperationException>(() => reader.TryRead(out readResult)); 1203Assert.Throws<InvalidOperationException>(() => reader.TryRead(out readResult)); 1221var ex0 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1222var ex1 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1254var ex0 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1255var ex1 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1281var ex0 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1282var ex1 = Assert.Throws<BadHttpRequestException>(() => reader.TryRead(out var readResult)); 1340Assert.Throws<InvalidOperationException>(() => reader.TryRead(out readResult)); 1366Assert.Throws<InvalidOperationException>(() => reader.TryRead(out readResult));
MinDataRateTests.cs (2)
26var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new MinDataRate(bytesPerSecond: value, gracePeriod: TimeSpan.MaxValue)); 43var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new MinDataRate(bytesPerSecond: 1, gracePeriod: value));
Microsoft.AspNetCore.Server.Kestrel.Tests (2)
ConfigurationReaderTests.cs (1)
97var exception = Assert.Throws<ArgumentException>(() =>
HttpsConnectionAdapterOptionsTest.cs (1)
37var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpsConnectionAdapterOptions { HandshakeTimeout = value });
Microsoft.AspNetCore.Shared.Tests (39)
CommandLineApplicationTests.cs (18)
70var ex = Assert.Throws<CommandParsingException>(() => app.Execute("test", "one", "two", "three")); 111var ex = Assert.Throws<CommandParsingException>(() => app.Execute("test2", "one", "two", "three")); 163var ex = Assert.Throws<InvalidOperationException>(() => app.Argument("second", "Second argument")); 203var ex = Assert.Throws<CommandParsingException>(() => app.Execute("test", "--first")); 261var exception = Assert.Throws<CommandParsingException>(() => app.Execute("test", unexpectedArg)); 433var exception = Assert.Throws<CommandParsingException>(() => app.Execute("test", unexpectedOption)); 643var exception = Assert.Throws<CommandParsingException>(() => app.Execute("test", unexpectedOption)); 676var exception = Assert.Throws<CommandParsingException>(() => app.Execute("test", unexpectedOption)); 711var exception = Assert.Throws<CommandParsingException>(() => app.Execute("k", unexpectedOption, "run")); 814Assert.Throws<CommandParsingException>(() => app.Execute("subcmd", "-b", "B")); 829Assert.Throws<InvalidOperationException>(() => app.Execute("subcmd", "-a", "b")); 891Assert.Throws<CommandParsingException>(() => app.Execute("--nest2", "N2", "--nest1", "N1", "-g", "G")); 892Assert.Throws<CommandParsingException>(() => app.Execute("lvl1", "--nest2", "N2", "--nest1", "N1", "-g", "G")); 1117var exception = Assert.Throws<CommandParsingException>(() => app.Execute(inputOptions)); 1143var exception = Assert.Throws<CommandParsingException>(() => app.Execute(inputOption)); 1154var exception = Assert.Throws<CommandParsingException>(() => app.Execute(inputOption)); 1165var exception = Assert.Throws<CommandParsingException>(() => app.Execute(inputOption)); 1219var exception = Assert.Throws<CommandParsingException>(() => app.Execute("test", firstOption));
ObjectMethodExecutorTest.cs (3)
74Assert.Throws<NotImplementedException>( 152Assert.Throws<ArgumentOutOfRangeException>(() => executor.GetDefaultValueForParameter(2)); 159Assert.Throws<InvalidOperationException>(() => executor.GetDefaultValueForParameter(0));
PropertyHelperTest.cs (2)
496Assert.Throws<NullReferenceException>(() => accessor(null)); 510Assert.Throws<NullReferenceException>(() => accessor(null));
runtime\Http2\DynamicTableTest.cs (2)
67Assert.Throws<IndexOutOfRangeException>(() => dynamicTable[0]); 70Assert.Throws<IndexOutOfRangeException>(() => dynamicTable[1]);
runtime\Http2\HPackIntegerTest.cs (1)
103Assert.Throws<HPackDecodingException>(() => decoder.TryDecode(octets[octets.Length - 1], out intResult));
runtime\Http2\HuffmanDecodingTests.cs (4)
89Assert.Throws<HuffmanDecodingException>(() => Huffman.Decode(encoded, ref decoded)); 271Exception exception = Assert.Throws<HuffmanDecodingException>(() => Huffman.Decode(new ReadOnlySpan<byte>(encoded), ref dst)); 288Exception exception = Assert.Throws<HuffmanDecodingException>(() => Huffman.Decode(new ReadOnlySpan<byte>(encoded), ref dst)); 333Exception exception = Assert.Throws<HuffmanDecodingException>(() => Huffman.Decode(new ReadOnlySpan<byte>(encoded), ref dst));
SegmentWriteStreamTests.cs (4)
18Assert.Throws<ArgumentOutOfRangeException>(() => new SegmentWriteStream(segmentSize)); 26Assert.Throws<NotSupportedException>(() => stream.Read(new byte[1], 0, 0)); 27Assert.Throws<NotSupportedException>(() => stream.Position = 0); 28Assert.Throws<NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin));
UrlDecoderTests.cs (4)
57Assert.Throws<ArgumentException>(() => UrlDecoder.DecodeRequestLine(source.AsSpan(), source.AsSpan(0, 1))); 64Assert.Throws<ArgumentException>(() => UrlDecoder.DecodeRequestLine(source.AsSpan(), source.AsSpan(0, 1), false)); 87Assert.Throws<InvalidOperationException>(() => UrlDecoder.DecodeInPlace(source.AsSpan())); 94Assert.Throws<InvalidOperationException>(() => UrlDecoder.DecodeInPlace(source.AsSpan(), false));
ValueStopwatchTest.cs (1)
28Assert.Throws<InvalidOperationException>(() => stopwatch.GetElapsedTime());
Microsoft.AspNetCore.SignalR.Client.Tests (10)
HttpConnectionTests.cs (6)
45Assert.Throws<ArgumentOutOfRangeException>(() => httpOptions.TransportMaxBufferSize = -1); 46Assert.Throws<ArgumentOutOfRangeException>(() => httpOptions.ApplicationMaxBufferSize = -1); 52var exception = Assert.Throws<ArgumentNullException>(() => new HttpConnection(null)); 59var exception = Assert.Throws<ArgumentException>(() => new HttpConnection(new HttpConnectionOptions(), NullLoggerFactory.Instance)); 67var exception = Assert.Throws<InvalidOperationException>(() => connection.ConnectionId = "custom conneciton ID"); 122Assert.Throws<ArgumentNullException>(() => httpOptions.Cookies = null);
HubConnectionBuilderTests.cs (3)
22var ex = Assert.Throws<InvalidOperationException>(() => new HubConnectionBuilder().Build()); 32var ex = Assert.Throws<InvalidOperationException>(() => builder.Build()); 69var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
HubConnectionTests.Protocol.cs (1)
716var ex = Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.SignalR.Common.Tests (6)
Internal\Protocol\HandshakeProtocolTests.cs (1)
107var exception = Assert.Throws<InvalidDataException>(() =>
Internal\Protocol\JsonHubProtocolTests.cs (1)
54var ex = Assert.Throws<InvalidDataException>(() => JsonHubProtocol.TryParseMessage(ref data, binder, out var _));
Internal\Protocol\JsonHubProtocolTestsBase.cs (2)
196var ex = Assert.Throws<InvalidDataException>(() => JsonHubProtocol.TryParseMessage(ref data, binder, out var _)); 269var ex = Assert.Throws<InvalidDataException>(() => JsonHubProtocol.TryParseMessage(ref data, binder, out var message));
Internal\Protocol\MessagePackHubProtocolTestBase.cs (1)
364var exception = Assert.Throws<InvalidDataException>(() => HubProtocol.TryParseMessage(ref data, binder, out _));
Internal\Protocol\NewtonsoftJsonHubProtocolTests.cs (1)
52var ex = Assert.Throws<InvalidDataException>(() => JsonHubProtocol.TryParseMessage(ref data, binder, out var _));
Microsoft.AspNetCore.SignalR.Tests (6)
AddSignalRTests.cs (1)
196Assert.Throws<ArgumentOutOfRangeException>(() => new HubOptions() { MaximumParallelInvocationsPerClient = 0 });
HubConnectionHandlerTests.cs (5)
243var ex = Assert.Throws<InvalidOperationException>(() => 1361var exception = Assert.Throws<NotSupportedException>(() => serviceProvider.GetService<HubConnectionHandler<GenericMethodHub>>()); 5046var ex = Assert.Throws<InvalidOperationException>(() => serviceProvider.GetService<HubConnectionHandler<KeyedServicesHub>>()); 5062var ex = Assert.Throws<InvalidOperationException>(() => serviceProvider.GetService<HubConnectionHandler<BadServicesHub>>()); 5073Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.TestHost.Tests (4)
ClientHandlerTests.cs (1)
344Assert.Throws<NotSupportedException>(() => invoker.Send(message, CancellationToken.None));
HttpContextBuilderTests.cs (1)
298var ex = Assert.Throws<IOException>(() => context.Response.Body.Read(new byte[100], 0, 100));
TestServerTests.cs (2)
118Assert.Throws<InvalidOperationException>(() => new TestServer(builder)); 306Assert.Throws<ArgumentNullException>(() => new TestServer(builder, null));
Microsoft.AspNetCore.Tests (34)
WebApplicationTests.cs (34)
282Assert.Throws<InvalidOperationException>(() => app.Urls); 373Assert.Throws<NotSupportedException>(() => ((IHostBuilder)createBuilder().Host).Build()); 380Assert.Throws<NotSupportedException>(() => ((IWebHostBuilder)createBuilder().WebHost).Build()); 393Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ApplicationKey, nameof(WebApplicationTests))); 394Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.EnvironmentKey, envName)); 395Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ContentRootKey, contentRoot)); 396Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.WebRootKey, webRoot)); 397Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "hosting")); 398Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, "hostingexclude")); 399Assert.Throws<NotSupportedException>(() => builder.WebHost.UseEnvironment(envName)); 400Assert.Throws<NotSupportedException>(() => builder.WebHost.UseContentRoot(contentRoot)); 413Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 421Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 429Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 437Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 445Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 453Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 1080Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureHostConfiguration(builder => 1088Assert.Throws<NotSupportedException>(() => builder.Host.UseEnvironment(envName)); 1089Assert.Throws<NotSupportedException>(() => builder.Host.UseContentRoot(contentRoot)); 1620var ex = Assert.Throws<InvalidOperationException>(() => app.UseEndpoints(endpoints => { })); 1817Assert.Throws<InvalidOperationException>(() => builder.Services.AddSingleton<IService>(new Service())); 1819Assert.Throws<InvalidOperationException>(() => builder.Services.AddScoped<IService, Service>()); 1821Assert.Throws<InvalidOperationException>(() => builder.Services.Remove(ServiceDescriptor.Singleton(new Service()))); 1822Assert.Throws<InvalidOperationException>(() => builder.Services[0] = ServiceDescriptor.Singleton(new Service())); 1831var ex = Assert.Throws<NotSupportedException>(() => builder.WebHost.Configure(app => { })); 1832var ex1 = Assert.Throws<NotSupportedException>(() => builder.WebHost.Configure((context, app) => { })); 1833var ex2 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup<MyStartup>()); 1834var ex3 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup(typeof(MyStartup))); 1835var ex4 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup(context => new MyStartup())); 1843var ex5 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHost(webHostBuilder => { })); 1844var ex6 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHost(webHostBuilder => { }, options => { })); 1845var ex7 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureSlimWebHost(webHostBuilder => { }, options => { })); 1846var ex8 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHostDefaults(webHostBuilder => { }));
Microsoft.AspNetCore.WebUtilities.Tests (2)
FileBufferingReadStreamTests.cs (2)
159var exception = Assert.Throws<IOException>(() => stream.Read(bytes, 0, bytes.Length)); 191var exception = Assert.Throws<IOException>(() => stream.Read(bytes, 0, bytes.Length));
Microsoft.Build.Engine.UnitTests (23)
BackEnd\ConfigCache_Tests.cs (1)
125Assert.Throws<InternalErrorException>(() => ((ConfigCache)obj).GetSmallestConfigId());
BackEnd\TargetBuilder_Tests.cs (1)
1435Assert.Throws<InternalErrorException>(() => resultsCache.GetResultForRequest(entry.Request));
BuildEventArgsSerialization_Tests.cs (1)
902Assert.Throws<EndOfStreamException>(() => buildEventArgsReader.Read());
Evaluation\Expander_Tests.cs (8)
2608Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([Microsoft.FOO.FileIO.FileSystem]::CurrentDirectory)", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2609Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([Foo.Baz]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2610Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([Foo]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2611Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([Foo.]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2612Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([.Foo]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2613Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([.]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 2614Assert.Throws<InvalidProjectFileException>(() => expander.ExpandIntoStringLeaveEscaped("$([]::new())", ExpanderOptions.ExpandProperties, MockElementLocation.Instance)); 3298var ex = Assert.Throws<InvalidProjectFileException>(
Evaluation\ImportFromMSBuildExtensionsPath_Tests.cs (5)
60Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath)); 310Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath)); 643Assert.Throws<InvalidProjectFileException>(() => projectCollection.LoadProject(mainProjectPath)); 837Assert.Throws<InvalidProjectFileException>(() => projectCollection.LoadProject(mainProjectPath)); 871Assert.Throws<InvalidProjectFileException>(() => projectCollection.LoadProject(mainProjectPath));
Evaluation\ProjectSdkImplicitImport_Tests.cs (2)
328Assert.Throws<InvalidProjectFileException>( 396Assert.Throws<InvalidProjectFileException>(() => new Project(
Globbing\MSBuildGlob_Tests.cs (4)
57Assert.Throws<ArgumentNullException>(() => MSBuildGlob.Parse(null, "*")); 75Assert.Throws<ArgumentException>(() => MSBuildGlob.Parse(invalidPathChar.ToString(), "*")); 104Assert.Throws<ArgumentNullException>(() => MSBuildGlob.Parse(null)); 177Assert.Throws<ArgumentNullException>(() => glob.IsMatch(null));
Graph\ProjectGraph_Tests.cs (1)
126Assert.Throws<InternalErrorException>(() => new ProjectGraphNode(null));
Microsoft.Build.Tasks.UnitTests (1)
AssemblyDependency\AssemblyFoldersFromConfig_Tests.cs (1)
157Assert.Throws<InternalErrorException>(() => Execute(t));
Microsoft.DotNet.XUnitAssert.Tests (7)
ExceptionAssertsTests.cs (7)
244 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Func<object>)!)); 252 var ex = Record.Exception(() => Assert.Throws<Exception>(testCode)); 263 var ex = Record.Exception(() => Assert.Throws<ArgumentException>(testCode)); 279 Assert.Throws<ArgumentException>(testCode); 288 var ex = Record.Exception(() => Assert.Throws<ArgumentException>(testCode)); 306 var ex = Record.Exception(() => Assert.Throws<ArgumentException>(testCode)); 413 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Func<object>)!));
Microsoft.Extensions.Caching.Hybrid.Tests (2)
StampedeTests.cs (2)
198var ex = Assert.Throws<OperationCanceledException>(() => result.GetAwaiter().GetResult()); 275var ex = Assert.Throws<OperationCanceledException>(() => result.GetAwaiter().GetResult());
Microsoft.Extensions.Configuration.KeyPerFile.Tests (1)
KeyPerFileTests.cs (1)
35var e = Assert.Throws<ArgumentException>(() => new ConfigurationBuilder().AddKeyPerFile("nonexistent", false).Build());
Microsoft.Extensions.Features.Tests (2)
FeatureCollectionExtensionsTests.cs (1)
36Assert.Throws<InvalidOperationException>(() => features.GetRequiredFeature<object>());
FeatureCollectionTests.cs (1)
55var ex = Assert.Throws<InvalidOperationException>(() => interfaces.Get<int>());
Microsoft.Extensions.FileProviders.Embedded.Tests (1)
EmbeddedFileProviderTests.cs (1)
19Assert.Throws<ArgumentNullException>(() => new EmbeddedFileProvider(null));
Microsoft.Extensions.Localization.Tests (4)
ResourceManagerStringLocalizerFactoryTest.cs (1)
297Assert.Throws<ArgumentNullException>(() => factory.Create("baseName", location: null!));
StringLocalizerOfTTest.cs (3)
16var exception = Assert.Throws<ArgumentNullException>( 47var exception = Assert.Throws<ArgumentNullException>(() => localizer[name: null!]); 82var exception = Assert.Throws<ArgumentNullException>(() => localizer[name: null!]);
Microsoft.Extensions.ObjectPool.Tests (1)
DisposableObjectPoolTest.cs (1)
107Assert.Throws<ObjectDisposedException>(() => pool.Get());
Microsoft.JSInterop.Tests (23)
Infrastructure\ByteArrayJsonConverterTest.cs (8)
25var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 51var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 89var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 121var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 137var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 153var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 169var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions));
Infrastructure\DotNetDispatcherTest.cs (6)
169var ex = Assert.Throws<InvalidOperationException>(() => 238var ex = Assert.Throws<ArgumentException>( 257var ex = Assert.Throws<ArgumentException>( 498var ex = Assert.Throws<ArgumentException>(() => DotNetDispatcher.Invoke(jsRuntime, new DotNetInvocationInfo(thisAssemblyName, methodIdentifier, 0, default), "[7]")); 513var ex = Assert.Throws<ArgumentException>(() => DotNetDispatcher.Invoke(jsRuntime, new DotNetInvocationInfo(null, methodIdentifier, 1, default), argsJson)); 527Assert.Throws<JsonException>(() =>
Infrastructure\DotNetObjectReferenceJsonConverterTest.cs (2)
23var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)); 37var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions));
Infrastructure\DotNetStreamReferenceJsonConverterTest.cs (1)
26var ex = Assert.Throws<NotSupportedException>(() => JsonSerializer.Deserialize<DotNetStreamReference>(json, JsonSerializerOptions));
Infrastructure\JSObjectReferenceJsonConverterTest.cs (2)
27var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions));
Infrastructure\JSStreamReferenceJsonConverterTest.cs (3)
27var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 72var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions));
JSObjectReferenceTest.cs (1)
65Assert.Throws<ObjectDisposedException>(() => jsObject.Invoke<object>("test", "arg1", "arg2"));
Microsoft.Net.Http.Headers.Tests (76)
CacheControlHeaderValueTest.cs (1)
575Assert.Throws<FormatException>(() => CacheControlHeaderValue.Parse(input));
ContentDispositionHeaderValueTest.cs (6)
14Assert.Throws<ArgumentException>(() => new ContentDispositionHeaderValue(null)); 21Assert.Throws<ArgumentException>(() => new ContentDispositionHeaderValue(string.Empty)); 382Assert.Throws<ArgumentOutOfRangeException>(() => contentDisposition.Size = -279172874240); 636Assert.Throws<FormatException>(() => ContentDispositionHeaderValue.Parse(input)); 687Assert.Throws<FormatException>(() => ContentDispositionHeaderValue.Parse(input)); 704Assert.Throws<FormatException>(() => new ContentDispositionHeaderValue(contentDisposition));
ContentRangeHeaderValueTest.cs (16)
11Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(-1)); 30Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(-1, 1)); 31Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(0, -1)); 32Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(2, 1)); 51Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(-1, 1, 2)); 52Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(0, -1, 2)); 53Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(0, 1, -1)); 54Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(2, 1, 3)); 55Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(1, 2, 1)); 56Assert.Throws<ArgumentOutOfRangeException>(() => new ContentRangeHeaderValue(1, 2, 2)); 79Assert.Throws<ArgumentException>(() => range.Unit = null); 80Assert.Throws<ArgumentException>(() => range.Unit = ""); 81Assert.Throws<FormatException>(() => range.Unit = " x"); 82Assert.Throws<FormatException>(() => range.Unit = "x "); 83Assert.Throws<FormatException>(() => range.Unit = "x y"); 172Assert.Throws<FormatException>(() => ContentRangeHeaderValue.Parse(input));
CookieHeaderValueTest.cs (5)
154Assert.Throws<ArgumentNullException>(() => new CookieHeaderValue(null, "value")); 161Assert.Throws<ArgumentException>(() => new CookieHeaderValue(name, "value")); 168Assert.Throws<ArgumentException>(() => new CookieHeaderValue("name", value)); 231Assert.Throws<FormatException>(() => CookieHeaderValue.Parse(value)); 305Assert.Throws<FormatException>(() => CookieHeaderValue.ParseStrictList(input));
EntityTagHeaderValueTest.cs (5)
11Assert.Throws<ArgumentException>(() => new EntityTagHeaderValue(null)); 13Assert.Throws<ArgumentException>(() => new EntityTagHeaderValue(string.Empty)); 442Assert.Throws<FormatException>(() => EntityTagHeaderValue.ParseStrictList(inputs)); 501Assert.Throws<FormatException>(() => EntityTagHeaderValue.Parse(input)); 518Assert.Throws<FormatException>(() => new EntityTagHeaderValue(tag));
HeaderUtilitiesTest.cs (1)
115Assert.Throws<ArgumentOutOfRangeException>(() => HeaderUtilities.FormatNonNegativeInt64(value));
MediaTypeHeaderValueTest.cs (8)
13Assert.Throws<ArgumentException>(() => new MediaTypeHeaderValue(null)); 15Assert.Throws<ArgumentException>(() => new MediaTypeHeaderValue(string.Empty)); 185Assert.Throws<NotSupportedException>(() => mediaType1.Parameters.Remove(new NameValueHeaderValue("name"))); 316Assert.Throws<ArgumentOutOfRangeException>(() => new MediaTypeHeaderValue("application/xml", -0.01)); 323Assert.Throws<ArgumentOutOfRangeException>(() => mediaType.Quality = 1.01); 643Assert.Throws<FormatException>(() => MediaTypeHeaderValue.ParseStrictList(inputs)); 928Assert.Throws<FormatException>(() => MediaTypeHeaderValue.Parse(input)); 945Assert.Throws<FormatException>(() => new MediaTypeHeaderValue(mediaType));
NameValueHeaderValueTest.cs (5)
11Assert.Throws<ArgumentException>(() => new NameValueHeaderValue(null)); 13Assert.Throws<ArgumentException>(() => new NameValueHeaderValue(string.Empty)); 512Assert.Throws<FormatException>(() => NameValueHeaderValue.ParseStrictList(inputs)); 658Assert.Throws<FormatException>(() => NameValueHeaderValue.Parse(input)); 681Assert.Throws<FormatException>(() => new NameValueHeaderValue(name, value));
RangeConditionHeaderValueTest.cs (3)
16Assert.Throws<ArgumentNullException>(() => new RangeConditionHeaderValue(input)); 26Assert.Throws<ArgumentException>(() => new RangeConditionHeaderValue((string?)null)); 120Assert.Throws<FormatException>(() => RangeConditionHeaderValue.Parse(input));
RangeHeaderValueTest.cs (7)
11Assert.Throws<ArgumentOutOfRangeException>(() => new RangeHeaderValue(5, 2)); 21Assert.Throws<ArgumentException>(() => range.Unit = null); 22Assert.Throws<ArgumentException>(() => range.Unit = ""); 23Assert.Throws<FormatException>(() => range.Unit = " x"); 24Assert.Throws<FormatException>(() => range.Unit = "x "); 25Assert.Throws<FormatException>(() => range.Unit = "x y"); 160Assert.Throws<FormatException>(() => RangeHeaderValue.Parse(input));
RangeItemHeaderValueTest.cs (4)
11Assert.Throws<ArgumentException>(() => new RangeItemHeaderValue(null, null)); 17Assert.Throws<ArgumentOutOfRangeException>(() => new RangeItemHeaderValue(-1, null)); 23Assert.Throws<ArgumentOutOfRangeException>(() => new RangeItemHeaderValue(2, 1)); 29Assert.Throws<ArgumentOutOfRangeException>(() => new RangeItemHeaderValue(null, -1));
SetCookieHeaderValueTest.cs (5)
300Assert.Throws<ArgumentNullException>(() => new SetCookieHeaderValue(null, "value")); 307Assert.Throws<ArgumentException>(() => new SetCookieHeaderValue(name, "value")); 314Assert.Throws<ArgumentException>(() => new SetCookieHeaderValue("name", value)); 388Assert.Throws<FormatException>(() => SetCookieHeaderValue.Parse(value)); 474Assert.Throws<FormatException>(() => SetCookieHeaderValue.ParseStrictList(input));
StringWithQualityHeaderValueTest.cs (10)
15Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue(null)); 16Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue("")); 17Assert.Throws<FormatException>(() => new StringWithQualityHeaderValue("in valid")); 27Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue(null, 0.1)); 28Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue("", 0.1)); 29Assert.Throws<FormatException>(() => new StringWithQualityHeaderValue("in valid", 0.1)); 31Assert.Throws<ArgumentOutOfRangeException>(() => new StringWithQualityHeaderValue("t", 1.1)); 32Assert.Throws<ArgumentOutOfRangeException>(() => new StringWithQualityHeaderValue("t", -0.1)); 161Assert.Throws<FormatException>(() => StringWithQualityHeaderValue.Parse(input)); 404Assert.Throws<FormatException>(() => StringWithQualityHeaderValue.ParseStrictList(inputs));
Sockets.FunctionalTests (2)
src\Servers\Kestrel\test\FunctionalTests\Http2\HandshakeTests.cs (1)
48var ex = Assert.Throws<NotSupportedException>(() => new TestServer(context =>
src\Servers\Kestrel\test\FunctionalTests\RequestTests.cs (1)
708Assert.Throws<SocketException>(() => socket.Receive(new byte[32]));
System.ServiceModel.Http.Tests (30)
Channels\HttpRequestMessagePropertyTest.cs (2)
67Assert.Throws<ArgumentNullException>(() => requestMsgProperty.Method = null); 83Assert.Throws<ArgumentNullException>(() => requestMsgProperty.QueryString = null);
Channels\WebSocketTransportSettingsTest.cs (2)
17Assert.Throws<PlatformNotSupportedException>(() => setting.DisablePayloadMasking = true); 25Assert.Throws<PlatformNotSupportedException>(() => disablePayloadMasking = setting.DisablePayloadMasking);
ServiceModel\BasicHttpBindingTest.cs (11)
119Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferPoolSize = value); 139Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferSize = value); 159Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxReceivedMessageSize = value); 177Assert.Throws<ArgumentException>(() => binding.Name = value); 196Assert.Throws<ArgumentNullException>(() => binding.Namespace = value); 217Assert.Throws<ArgumentNullException>(() => binding.ReaderQuotas = null); 234Assert.Throws<ArgumentOutOfRangeException>(() => binding.CloseTimeout = timeSpan); 251Assert.Throws<ArgumentOutOfRangeException>(() => binding.OpenTimeout = timeSpan); 268Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 285Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 302Assert.Throws<ArgumentException>(() => binding.TextEncoding = encoding);
ServiceModel\BasicHttpsBindingTest.cs (12)
77Assert.Throws<PlatformNotSupportedException>(() => channel.Echo("hello")); 107Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferPoolSize = value); 127Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferSize = value); 147Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxReceivedMessageSize = value); 165Assert.Throws<ArgumentException>(() => binding.Name = value); 184Assert.Throws<ArgumentNullException>(() => binding.Namespace = value); 205Assert.Throws<ArgumentNullException>(() => binding.ReaderQuotas = null); 222Assert.Throws<ArgumentOutOfRangeException>(() => binding.CloseTimeout = timeSpan); 239Assert.Throws<ArgumentOutOfRangeException>(() => binding.OpenTimeout = timeSpan); 256Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 273Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 290Assert.Throws<ArgumentException>(() => binding.TextEncoding = encoding);
ServiceModel\BasicHttpSecurityTest.cs (1)
22Assert.Throws<PlatformNotSupportedException>(() => security.Mode = value);
ServiceModel\HttpIdentityTests.cs (2)
20Assert.Throws<InvalidOperationException>(() => channel.Echo("")); 32Assert.Throws<InvalidOperationException>(() => channel.Echo(""));
System.ServiceModel.NetTcp.Tests (9)
Channels\TcpConnectionPoolSettingsTest.cs (4)
32Assert.Throws<ArgumentNullException>(() => settings.GroupName = null); 53Assert.Throws<ArgumentOutOfRangeException>(() => settings.IdleTimeout = timeSpan); 74Assert.Throws<ArgumentOutOfRangeException>(() => settings.LeaseTimeout = timeSpan); 96Assert.Throws<ArgumentOutOfRangeException>(() => settings.MaxOutboundConnectionsPerEndpoint = value);
ServiceModel\NetTcpBindingTest.cs (3)
68Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferSize = value); 87Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxReceivedMessageSize = value); 103Assert.Throws<ArgumentNullException>(() => binding.Security = null);
ServiceModel\NetTcpSecurityTest.cs (1)
37Assert.Throws<ArgumentOutOfRangeException>(() => security.Mode = (SecurityMode)999);
ServiceModel\TcpTransportSecurityTest.cs (1)
38Assert.Throws<ArgumentOutOfRangeException>(() => transport.ClientCredentialType = (TcpClientCredentialType)999);
System.ServiceModel.Primitives.Tests (27)
Channels\BinaryMessageEncodingBindingElementTest.cs (5)
58Assert.Throws<ArgumentOutOfRangeException>(() => bindingElement.MaxSessionSize = value); 75Assert.Throws<InvalidOperationException>(() => bindingElement.MessageVersion = version); 82Assert.Throws<ArgumentNullException>(() => bindingElement.MessageVersion = null); 109Assert.Throws<ArgumentOutOfRangeException>(() => bindingElement.MaxReadPoolSize = value); 136Assert.Throws<ArgumentOutOfRangeException>(() => bindingElement.MaxWritePoolSize = value);
Channels\CustomChannelTest.cs (2)
468Assert.Throws<InvalidOperationException>(() => factory.CreateChannel()); 722Assert.Throws<InvalidOperationException>(() => channel.Process(inputMessage));
Channels\TextMessageEncodingBindingElementTest.cs (2)
37Assert.Throws<ArgumentException>(() => element.WriteEncoding = encoding); 53Assert.Throws<ArgumentNullException>(() => element.MessageVersion = null);
IdentityModel\SecurityTokenSerializerTest.cs (9)
57Assert.Throws<ArgumentNullException>(() => sts.CanReadKeyIdentifier(null)); 58Assert.Throws<ArgumentNullException>(() => sts.CanReadKeyIdentifierClause(null)); 59Assert.Throws<ArgumentNullException>(() => sts.CanReadToken(null)); 60Assert.Throws<ArgumentNullException>(() => sts.CanWriteKeyIdentifier(null)); 61Assert.Throws<ArgumentNullException>(() => sts.CanWriteKeyIdentifierClause(null)); 62Assert.Throws<ArgumentNullException>(() => sts.CanWriteToken(null)); 63Assert.Throws<ArgumentNullException>(() => sts.ReadToken(null, null)); 64Assert.Throws<ArgumentNullException>(() => sts.ReadKeyIdentifier(null)); 65Assert.Throws<ArgumentNullException>(() => sts.ReadKeyIdentifierClause(null));
Security\SecurityTokenRequirementTest.cs (1)
47Assert.Throws<ArgumentException>(() => tokenrequirement.TryGetProperty(tokenrequirement.TokenType, out int Tvalue));
ServiceModel\ClientBaseTest.cs (6)
46Assert.Throws<InvalidOperationException>(() => MyClientBase.CacheSetting = CacheSetting.AlwaysOn); 67Assert.Throws<InvalidOperationException>(() => MyClientBase.CacheSetting = CacheSetting.AlwaysOn); 96Assert.Throws<InvalidOperationException>(() => MyClientBase2.CacheSetting = CacheSetting.Default); 132Assert.Throws<InvalidOperationException>(() => MyClientBase2.CacheSetting = CacheSetting.Default); 152Assert.Throws<InvalidOperationException>(() => MyClientBase.CacheSetting = CacheSetting.AlwaysOn); 173Assert.Throws<InvalidOperationException>(() => MyClientBase.CacheSetting = CacheSetting.AlwaysOn);
ServiceModel\MessageContractTest.cs (2)
52Assert.Throws<ArgumentOutOfRangeException>(() => messageCA.WrapperName = wrapperName); 60Assert.Throws<ArgumentNullException>(() => messageCA.WrapperName = wrapperName);
System.ServiceModel.UnixDomainSocket.Tests (5)
ServiceModel\UnixDomainSocketBindingTest.cs (3)
69Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferSize = value); 88Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxReceivedMessageSize = value); 104Assert.Throws<ArgumentNullException>(() => binding.Security = null);
ServiceModel\UnixDomainSocketSecurityTest.cs (1)
37Assert.Throws<ArgumentOutOfRangeException>(() => security.Mode = (UnixDomainSocketSecurityMode)999);
ServiceModel\UnixDomainSocketTransportSecurityTest.cs (1)
40Assert.Throws<ArgumentOutOfRangeException>(() => transport.ClientCredentialType = (UnixDomainSocketClientCredentialType)999);
System.Xaml.Tests (37)
System\Windows\Markup\ArrayExtensionTests.cs (3)
71Assert.Throws<RankException>(() => new ArrayExtension(new int[1, 1])); 109Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(null)); 117Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(null));
System\Windows\Markup\DateTimeValueSerializerTests.cs (2)
52Assert.Throws<NotSupportedException>(() => serializer.ConvertToString(value, null)); 84Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(null!, null));
System\Windows\Markup\NameReferenceConverterTests.cs (5)
87Assert.Throws<InvalidOperationException>(() => converter.ConvertFrom(context, null, "name")); 102Assert.Throws<InvalidCastException>(() => converter.ConvertFrom(context, null, "name")); 120Assert.Throws<InvalidOperationException>(() => converter.ConvertFrom(context, null, value)); 179Assert.Throws<InvalidOperationException>(() => converter.ConvertTo(context, null, "value", null)); 194Assert.Throws<InvalidCastException>(() => converter.ConvertTo(context, null, "value", null));
System\Windows\Markup\ReferenceTests.cs (2)
81Assert.Throws<InvalidOperationException>(() => reference.ProvideValue(provider)); 94Assert.Throws<InvalidOperationException>(() => reference.ProvideValue(provider));
System\Windows\Markup\StaticExtensionTests.cs (7)
96Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(null)); 113Assert.Throws<ArgumentException>(() => extension.ProvideValue(provider)); 133Assert.Throws<ArgumentException>(() => extension.ProvideValue(provider)); 144Assert.Throws<ArgumentException>(() => extension.ProvideValue(null)); 166Assert.Throws<ArgumentException>(() => extension.ProvideValue(provider)); 236Assert.Throws<ArgumentException>(() => converter.ConvertTo(1, typeof(InstanceDescriptor))); 244Assert.Throws<NotSupportedException>(() => converter.ConvertTo(extension, typeof(int)));
System\Windows\Markup\StringValueSerializerTests.cs (1)
38Assert.Throws<InvalidCastException>(() => serializer.ConvertToString(1, null));
System\Windows\Markup\TypeExtensionTests.cs (5)
85Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(null)); 105Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(provider)); 123Assert.Throws<InvalidOperationException>(() => extension.ProvideValue(provider)); 198Assert.Throws<ArgumentException>(() => converter.ConvertTo(1, typeof(InstanceDescriptor))); 206Assert.Throws<NotSupportedException>(() => converter.ConvertTo(extension, typeof(int)));
System\Windows\Markup\ValueSerializerTests.cs (12)
44Assert.Throws<NotSupportedException>(() => serializer.ConvertToString(value, null)); 45Assert.Throws<NotSupportedException>(() => serializer.ConvertToString(value, new CustomValueSerializerContext())); 68Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(null!, null)); 69Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(null!, new CustomValueSerializerContext())); 78Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(value, null)); 79Assert.Throws<NotSupportedException>(() => serializer.ConvertFromString(value, new CustomValueSerializerContext())); 214Assert.Throws<ArgumentException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithEmptyTypeConverterAttribute))); 215Assert.Throws<ArgumentException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithEmptyTypeConverterAttribute), null!)); 236Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithInvalidValueSerializerAttribute))); 237Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(typeof(ClassWithInvalidValueSerializerAttribute), null)); 302Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(descriptor)); 303Assert.Throws<InvalidCastException>(() => ValueSerializer.GetSerializerFor(descriptor, null));
xunit.assert (1)
ExceptionAsserts.cs (1)
158 var ex = Throws<T>(testCode);