2533 references to Throws
Analyzer.Utilities.UnitTests (5)
Lightup\LightupHelpersTests.cs (5)
32Assert.Throws<NullReferenceException>(() => propertyAccessor(null!)); 38Assert.Throws<NullReferenceException>(() => withPropertyAccessor(null!, new object())); 51Assert.Throws<NullReferenceException>(() => propertyAccessor(null!)); 57Assert.Throws<NullReferenceException>(() => withPropertyAccessor(null!, new object())); 70Assert.Throws<NullReferenceException>(() => accessor(null!, 0));
IIS.Tests (1)
MaxRequestBodySizeTests.cs (1)
250invalidOpEx = Assert.Throws<InvalidOperationException>(() =>
InMemory.FunctionalTests (22)
ChunkedRequestTests.cs (6)
243Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 250Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 258Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); 369Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 376Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header")); // Not yet 384Assert.Throws<InvalidOperationException>(() => request.GetTrailer("X-Trailer-Header"));
Http2\Http2StreamTests.cs (3)
2145Assert.Throws<InvalidOperationException>(() => context.Response.ContentType = "Custom 你好 Type"); 2473Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.ETag = "Custom 你好 Tag"); 2474Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.Accept = "Custom 你好 Tag");
Http3\Http3StreamTests.cs (3)
865Assert.Throws<InvalidOperationException>(() => context.Response.ContentType = "Custom 你好 Type"); 1019Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.ETag = "Custom 你好 Tag"); 1020Assert.Throws<InvalidOperationException>(() => context.Features.Get<IHttpResponseTrailersFeature>().Trailers.Accept = "Custom 你好 Tag");
HttpsConnectionMiddlewareTests.cs (3)
278Assert.Throws<ArgumentException>(() => CreateMiddleware(new HttpsConnectionAdapterOptions(), ListenOptions.DefaultHttpProtocols)); 1348var ex = Assert.Throws<InvalidOperationException>(() => 1451Assert.Throws<NotSupportedException>(() => CreateMiddleware(httpConnectionAdapterOptions, HttpProtocols.Http2));
MaxRequestBodySizeTests.cs (2)
297invalidOpEx = Assert.Throws<InvalidOperationException>(() => 337invalidOpEx = Assert.Throws<InvalidOperationException>(() =>
RequestTests.cs (2)
1698var ioEx = Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(new byte[1], 0, 1)); 1791var 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)
4464writeEx = Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.GetMemory());
Microsoft.AspNetCore.Antiforgery.Test (9)
AntiforgeryApplicationBuilderExtensionsTest.cs (1)
41var exception = Assert.Throws<InvalidOperationException>(() => builder.UseAntiforgery());
BinaryBlobTest.cs (2)
27var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new BinaryBlob(bitLength)); 62var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new BinaryBlob(32, data!));
DefaultAntiforgeryTest.cs (2)
79var exception = Assert.Throws<InvalidOperationException>( 100var exception = Assert.Throws<InvalidOperationException>(
DefaultAntiforgeryTokenGeneratorTest.cs (3)
95var exception = Assert.Throws<InvalidOperationException>( 279var ex = Assert.Throws<ArgumentNullException>( 300var ex = Assert.Throws<ArgumentNullException>(
DefaultAntiforgeryTokenSerializerTest.cs (1)
50var ex = Assert.Throws<AntiforgeryValidationException>(() => testSerializer.Deserialize(serializedToken));
Microsoft.AspNetCore.AsyncState.Tests (2)
AsyncContextHttpContextOfTTests.cs (1)
78Assert.Throws<InvalidOperationException>(() => _context.Get());
AsyncStateHttpContextExtensionsTests.cs (1)
18Assert.Throws<ArgumentNullException>(() => AsyncStateHttpContextExtensions.AddAsyncStateHttpContext(null!));
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)
350Assert.Throws<OptionsValidationException>(() => options.Get(CookieAuthenticationDefaults.AuthenticationScheme));
OpenIdConnect\OpenIdConnectTests.cs (1)
517Assert.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.Endpoints.Tests (7)
Binding\FormDataMapperTests.cs (2)
125var exception = Assert.Throws<FormDataMappingException>(() => FormDataMapper.Map<int>(reader, options)); 545var result = Assert.Throws<InvalidOperationException>(() => FormDataMapper.Map<int[]>(reader, options));
SSRRenderModeBoundaryTest.cs (4)
36var ex = Assert.Throws<InvalidOperationException>(() => new SSRRenderModeBoundary( 50var ex = Assert.Throws<InvalidOperationException>(() => new SSRRenderModeBoundary( 64var ex = Assert.Throws<InvalidOperationException>(() => new SSRRenderModeBoundary( 78var ex = Assert.Throws<InvalidOperationException>(() => new SSRRenderModeBoundary(
TypeNameHashTest.cs (1)
75var ex = Assert.Throws<InvalidOperationException>(() => TypeNameHash.Compute(type));
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.QuickGrid.Tests (3)
GridSortTest.cs (3)
155var exception = Assert.Throws<ArgumentException>(() => gridSort.ToPropertyList(ascending: true)); 167var exception = Assert.Throws<ArgumentException>(() => gridSort.ToPropertyList(ascending: true)); 179var exception = Assert.Throws<ArgumentException>(() => gridSort.ToPropertyList(ascending: true));
Microsoft.AspNetCore.Components.Server.Tests (3)
Circuits\CircuitHostTest.cs (2)
591Assert.Throws<ArgumentException>(() => 692Assert.Throws<ArgumentException>(() =>
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 (49)
CascadingParameterStateTest.cs (1)
396var ex = Assert.Throws<InvalidOperationException>(() => CreateAncestry(
CascadingParameterTest.cs (1)
566var ex = Assert.Throws<InvalidOperationException>(() => renderer.AssignRootComponentId(component));
ComponentFactoryTest.cs (4)
38var ex = Assert.Throws<ArgumentException>(() => factory.InstantiateComponent(GetServiceProvider(), componentType, null, null)); 71var ex = Assert.Throws<InvalidOperationException>(() => factory.InstantiateComponent(GetServiceProvider(), componentType, null, null)); 180Assert.Throws<AmbiguousMatchException>( 226var ex = Assert.Throws<InvalidOperationException>(() =>
EventCallbackFactoryBinderExtensionsTest.cs (1)
605var ex = Assert.Throws<InvalidOperationException>(() => EventCallback.Factory.CreateBinder(component, setter, value));
NavigationManagerTest.cs (3)
143var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameter(name, "test")); 196var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameters(unsupportedParameterValues)); 212var exception = Assert.Throws<InvalidOperationException>(() => navigationManager.GetUriWithQueryParameters(values));
OwningComponentBaseTest.cs (2)
72Assert.Throws<ObjectDisposedException>(() => component1.MyService); 92Assert.Throws<ObjectDisposedException>(() => component1.MyService);
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 _));
PersistentState\PersistentComponentStateTest.cs (1)
59Assert.Throws<InvalidOperationException>(() => applicationState.RegisterOnPersisting(() => Task.CompletedTask));
PersistentValueProviderComponentSubscriptionTests.cs (2)
659var exception = Assert.Throws<InvalidOperationException>(() => 682var exception = Assert.Throws<InvalidOperationException>(() =>
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 _));
Rendering\ArrayBuilderTest.cs (1)
295Assert.Throws<ObjectDisposedException>(() => builder.Append(1));
RenderTreeDiffBuilderTest.cs (3)
398var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent()); 415var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent()); 432var ex = Assert.Throws<InvalidOperationException>(() => GetSingleUpdatedComponent());
Routing\QueryParameterValueSupplierTest.cs (4)
175var ex = Assert.Throws<InvalidOperationException>(() => _supplier.GetQueryParameterValue(targetType, key)); 200var ex = Assert.Throws<InvalidOperationException>(() => _supplier.GetQueryParameterValue(targetType.MakeArrayType(), key)); 217var ex = Assert.Throws<InvalidOperationException>(() => _supplier.GetQueryParameterValue(targetType, key)); 282var ex = Assert.Throws<InvalidOperationException>(
Routing\RouteTableFactoryTests.cs (6)
803Assert.Throws<InvalidOperationException>(() => new TestRouteTableBuilder() 821Assert.Throws<RoutePatternException>(() => new TestRouteTableBuilder() 836Assert.Throws<InvalidOperationException>(() => new TestRouteTableBuilder() 847var exception = Assert.Throws<InvalidOperationException>(() => new TestRouteTableBuilder() 900Assert.Throws<RoutePatternException>(() => new TestRouteTableBuilder() 1044var exception = Assert.Throws<InvalidOperationException>(() => new TestRouteTableBuilder()
Routing\TemplateParserTests.cs (10)
127var ex = Assert.Throws<RoutePatternException>( 147var ex = Assert.Throws<RoutePatternException>( 163var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse(template)); 171var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("{a}/{}/{z}")); 181var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("{a}//{z}")); 191var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("/test/{a?}/test")); 201var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("/test/{a?}/{b}")); 214var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse(template)); 224var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("/test/{*a}/{b}")); 234var ex = Assert.Throws<RoutePatternException>(() => RoutePatternParser.Parse("/test/{a?bc}/{b}"));
Microsoft.AspNetCore.Components.Web.Tests (5)
Forms\BrowserFileTest.cs (2)
18var ex = Assert.Throws<ArgumentOutOfRangeException>(() => file.Size = -7); 28var ex = Assert.Throws<IOException>(() => file.OpenReadStream(80));
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 (3)
Hosting\WebAssemblyHostBuilderTest.cs (3)
102var exception = Assert.Throws<AggregateException>(() => builder.Build()); 266var exception = Assert.Throws<AggregateException>(() => builder.Build()); 299var exception = Assert.Throws<AggregateException>(() => builder.Build());
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 (6)
DataProtectionProviderTests.cs (1)
199Assert.Throws<CryptographicException>(() => keylessUnprotector.Unprotect(data));
TimeLimitedDataProtectorTests.cs (5)
105var ex = Assert.Throws<CryptographicException>(() 126var ex = Assert.Throws<CryptographicException>(() 143var ex = Assert.Throws<CryptographicException>(() 170Assert.Throws<CryptographicException>(() => ephemeralProtector.Unprotect(timeLimitedProtectedPayload)); 171Assert.Throws<CryptographicException>(() => timeLimitedProtector.Unprotect(ephemeralProtectedPayload, out actualExpiration));
Microsoft.AspNetCore.DataProtection.Tests (12)
ActivatorTests.cs (1)
62var ex = Assert.Throws<InvalidCastException>(
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 (2)
592Assert.Throws<FormatException>(() => RunGetAllKeysCore(xml, new Mock<IActivator>().Object)); 998Assert.Throws<NotSupportedException>(() => withoutDeletion.DeleteKeys(_ => false));
ServiceCollectionTests.cs (1)
106Assert.Throws<InvalidOperationException>(() => options.XmlEncryptor.Encrypt(xElement));
TypeForwardingActivatorTests.cs (1)
71Assert.Throws<ArgumentException>(() => activator.CreateInstance<object>(name));
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.Diagnostics.Middleware.Tests (15)
Buffering\PerIncomingRequestLoggingBuilderExtensionsTests.cs (2)
48Assert.Throws<ArgumentNullException>(() => builder!.AddPerIncomingRequestBuffer(LogLevel.Warning)); 49Assert.Throws<ArgumentNullException>(() => builder!.AddPerIncomingRequestBuffer(configuration!));
Latency\RequestCheckpointExtensionsTests.cs (2)
17Assert.Throws<ArgumentNullException>(() => Extensions.DependencyInjection.RequestLatencyTelemetryServiceCollectionExtensions.AddRequestCheckpoint(null!)); 23Assert.Throws<ArgumentNullException>(() => Builder.RequestLatencyTelemetryApplicationBuilderExtensions.UseRequestCheckpoint(null!));
Latency\RequestLatencyTelemetryExtensionsTests.cs (4)
20Assert.Throws<ArgumentNullException>(() => 22Assert.Throws<ArgumentNullException>(() => 24Assert.Throws<ArgumentNullException>(() => 26Assert.Throws<ArgumentNullException>(() =>
Logging\HttpLoggingServiceExtensionsTests.cs (2)
25Assert.Throws<ArgumentNullException>(static () => HttpLoggingServiceCollectionExtensions.AddHttpLogEnricher<TestHttpLogEnricher>(null!)); 27Assert.Throws<ArgumentNullException>(
Logging\LoggingOptionsValidationTests.cs (1)
28var ex = Assert.Throws<InvalidOperationException>(
Logging\RequestHeadersEnricherExtensionsTests.cs (4)
18Assert.Throws<ArgumentNullException>(() => 21Assert.Throws<ArgumentNullException>(() => 24Assert.Throws<ArgumentNullException>(() => 35Assert.Throws<ArgumentNullException>(() => sp.GetRequiredService<ILogEnricher>());
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (7)
HttpRoutePatternParserTests.cs (1)
322var ex = Assert.Throws<InvalidOperationException>(() => HttpRoutePattern.Parse(pattern));
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.HeaderParsing.Tests (2)
HeaderParsingExtensionsTests.cs (2)
37Assert.Throws<OptionsValidationException>(() => services.GetRequiredService<IOptions<HeaderParsingOptions>>().Value); 47Assert.Throws<OptionsValidationException>(() => services.GetRequiredService<IOptions<HeaderParsingOptions>>().Value);
Microsoft.AspNetCore.Hosting.Tests (24)
StartupManagerTests.cs (9)
79var exception = Assert.Throws<InvalidOperationException>(() => startup.ConfigureServicesDelegate(serviceCollection)); 367var ex = Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, type, "Boom")); 416var ex = Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, type, "TwoConfigures")); 431var ex = Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, type, "PrivateConfigure")); 445var ex = Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, type, "TwoConfigureServices")); 528Assert.Throws<Exception>(() => startup.ConfigureServicesDelegate(serviceCollection)); 602Assert.Throws<InvalidOperationException>(() => startup.ConfigureServicesDelegate(serviceCollection)); 611Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupBaseClass), Environments.Development)); 621Assert.Throws<InvalidOperationException>(() => StartupLoader.LoadMethods(services, typeof(MyContainerStartupWithOverloads), Environments.Development));
WebHostBuilderTests.cs (9)
71Assert.Throws<ArgumentNullException>(() => builder.UseServer(server).UseStartup((Func<WebHostBuilderContext, object>)null)); 79var ex = Assert.Throws<InvalidOperationException>(() => builder.UseServer(server).UseStartup<object>(context => null).Build()); 426var exception = Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 445Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 458var exception = Assert.Throws<InvalidOperationException>(() => hostBuilder.Build()); 845var ex = Assert.Throws<InvalidOperationException>(() => builder.Build()); 1009var exception = Assert.Throws<NotSupportedException>(() => builder.Build()); 1264Assert.Throws<ArgumentNullException>(() => new HostingStartupAttribute(null)); 1270Assert.Throws<ArgumentException>(() => new HostingStartupAttribute(typeof(WebHostTests)));
WebHostTests.cs (6)
36Assert.Throws<ArgumentNullException>(() => CreateBuilder().UseStartup((string)null)); 736Assert.Throws<NotImplementedException>(() => builder.Build()); 962Assert.Throws<ObjectDisposedException>(() => capturedContext.TraceIdentifier); 963Assert.Throws<ObjectDisposedException>(() => capturedContext.Features.Get<IHttpRequestIdentifierFeature>()); 965Assert.Throws<ObjectDisposedException>(() => capturedRequest.Scheme); 992var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
Microsoft.AspNetCore.Http.Abstractions.Tests (30)
EndpointFilterInvocationContextOfTTests.cs (7)
16Assert.Throws<NotSupportedException>(() => context.Remove("string")); 24Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(1)); 25Assert.Throws<InvalidCastException>(() => context.GetArgument<int>(0)); 26Assert.Throws<InvalidCastException>(() => context.GetArgument<string>(3)); 43Assert.Throws<InvalidCastException>(() => context[0] = 4); 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 (11)
16var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNoParametersStub))); 30var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareAsyncNoParametersStub))); 44var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNonTaskReturnStub))); 58var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareAsyncNonTaskReturnStub))); 72var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareNoInvokeStub))); 85var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokesStub))); 98var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokeAsyncStub))); 111var exception = Assert.Throws<InvalidOperationException>(() => builder.UseMiddleware(typeof(MiddlewareMultipleInvokeAndInvokeAsyncStub))); 153var exception = Assert.Throws<InvalidOperationException>(builder.Build); 208var exception = Assert.Throws<NotSupportedException>(() => builder.Build()); 216var exception = Assert.Throws<NotSupportedException>(() => builder.UseMiddleware(typeof(Middleware), "arg"));
Microsoft.AspNetCore.Http.Connections.Tests (5)
HttpConnectionDispatcherTests.cs (1)
3089Assert.Throws<ObjectDisposedException>(() => connection.ServiceScope.Value.ServiceProvider.GetService<MessageWrapper>());
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 (55)
HeaderDictionaryTypeExtensionsTest.cs (2)
161Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().Get<object>("custom")); 285Assert.Throws<NotSupportedException>(() => context.Request.GetTypedHeaders().GetList<object>("custom"));
ParameterBindingMethodCacheTests.cs (8)
556var ex = Assert.Throws<InvalidOperationException>( 573var ex = Assert.Throws<InvalidOperationException>( 618var ex = Assert.Throws<InvalidOperationException>( 642var ex = Assert.Throws<InvalidOperationException>(() => cache.FindBindAsyncMethod(parameter)); 683var ex = Assert.Throws<InvalidOperationException>(() => cache.FindConstructor(type)); 693var ex = Assert.Throws<InvalidOperationException>(() => cache.FindConstructor(type)); 703var ex = Assert.Throws<InvalidOperationException>(() => cache.FindConstructor(type)); 715var ex = Assert.Throws<InvalidOperationException>(() => cache.FindConstructor(type));
ProblemDetailsServiceCollectionExtensionsTest.cs (1)
125Assert.Throws<InvalidOperationException>(() => jsonOptions.Value);
RequestDelegateFactoryTests.cs (39)
210var exNullAction = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(handler: null!)); 211var exNullMethodInfo1 = Assert.Throws<ArgumentNullException>(() => RequestDelegateFactory.Create(methodInfo: null!)); 290var ex = Assert.Throws<InvalidOperationException>(() => 757var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(action)); 766var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(lambda.Compile())); 934var ex1 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method1)); 935var ex2 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method2)); 936var ex3 = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(Method3)); 960Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestAttributedInvalidAction)); 961Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestInferredInvalidAction)); 962Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBothInvalidAction)); 971Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestTryParseStruct)); 972Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestTryParseClass)); 994var ex = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBindAsyncStruct)); 995Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestBindAsyncClass)); 1049var exception = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(@delegate)); 1059Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestNestedParameterListRecordOnType)); 1060Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestNestedParameterListRecordOnArgument)); 1150var outParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(OutMethod)); 1151var inParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(InMethod)); 1152var refParamException = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(RefMethod)); 1440Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction, new() { ServiceProvider = httpContext.RequestServices })); 2031Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileAndJson)); 2032Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFilesAndJson)); 2033Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileAndJsonWithAttribute)); 2034Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormFileCollectionAndJson)); 2035Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormCollectionAndJson)); 2036Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestFormWithAttributeAndJson)); 2037Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFile)); 2038Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFiles)); 2039Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFileCollection)); 2040Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormFileWithAttribute)); 2041Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormCollection)); 2042Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(TestJsonAndFormWithAttribute)); 2055var nse = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction)); 2104var nse = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(TestAction)); 2141var exception = Assert.Throws<InvalidOperationException>(() => RequestDelegateFactory.Create(action)); 2154var exception = Assert.Throws<ArgumentException>(() => RequestDelegateFactory.Create(TestAction)); 3312var exception = Assert.Throws<NotSupportedException>(() => RequestDelegateFactory.Create(@delegate));
RequestDelegateGenerator\CompileTimeCreationTests.cs (1)
428var exception = Assert.Throws<InvalidOperationException>(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider));
RequestDelegateGenerator\RequestDelegateCreationTests.KeyServices.cs (2)
50var exception = Assert.Throws<NotSupportedException>(() => GetEndpointFromCompilation(compilation, serviceProvider: serviceProvider)); 218var 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 (23)
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>(() =>
HttpLoggingMiddlewareTests.cs (6)
41Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware( 49Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware(c => 59Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware(c => 69Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware(c => 79Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware(c => 89Assert.Throws<ArgumentNullException>(() => new HttpLoggingMiddleware(c =>
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));
W3CLoggingMiddlewareTests.cs (3)
18Assert.Throws<ArgumentNullException>(() => new W3CLoggingMiddleware( 23Assert.Throws<ArgumentNullException>(() => new W3CLoggingMiddleware(c => 30Assert.Throws<ArgumentNullException>(() => new W3CLoggingMiddleware(c =>
Microsoft.AspNetCore.HttpOverrides.Tests (5)
CertificateForwardingTest.cs (2)
24Assert.Throws<OptionsValidationException>(() => options.Value); 34Assert.Throws<OptionsValidationException>(() => options.Value);
IPNetworkTest.cs (3)
73var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new IPNetwork(address, prefixLength)); 97var ex = Assert.Throws<FormatException>(() => IPNetwork.Parse(input)); 106var 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)
884Assert.Throws<NotSupportedException>(() => manager.Users.Count()); 1143var e = Assert.Throws<InvalidOperationException>(() => services.BuildServiceProvider().GetService<UserManager<PocoUser>>()); 1154var 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 (11)
ModelBinding\BindingInfoTest.cs (1)
327Assert.Throws<NotSupportedException>(() => BindingInfo.GetBindingInfo(attributes, modelMetadata));
ModelBinding\ModelMetadataTest.cs (8)
387Assert.Throws<NotImplementedException>(() => metadata.ContainerMetadata); 397var result = Assert.Throws<NotImplementedException>(() => metadata.GetMetadataForType(typeof(string))); 407var result = Assert.Throws<NotImplementedException>(() => metadata.GetMetadataForProperties(typeof(string))); 419Assert.Throws<NotSupportedException>(() => metadata.ElementType); 420Assert.Throws<NotSupportedException>(() => metadata.IsParseableType); 421Assert.Throws<NotSupportedException>(() => metadata.IsConvertibleType); 422Assert.Throws<NotSupportedException>(() => metadata.IsComplexType); 423Assert.Throws<NotSupportedException>(() => metadata.IsCollectionType);
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 (56)
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));
ApplicationModels\ControllerActionDescriptorProviderTests.cs (3)
681var exception = Assert.Throws<InvalidOperationException>(() => provider.GetDescriptors()); 725var exception = Assert.Throws<InvalidOperationException>(() => provider.GetDescriptors()); 1102var ex = Assert.Throws<InvalidOperationException>(() => provider.GetDescriptors());
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\DefaultControllerFactoryTest.cs (1)
179var exception = Assert.Throws<InvalidOperationException>(() => factory.CreateController(context));
Controllers\ServiceBasedControllerActivatorTest.cs (1)
66var ex = Assert.Throws<InvalidOperationException>(
Filters\MiddlewareFilterConfigurationProviderTest.cs (1)
24var exception = Assert.Throws<InvalidOperationException>(() => MiddlewareFilterConfigurationProvider.CreateConfigureDelegate(configurationType));
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\SystemTextJsonOutputFormatterTest.cs (1)
265var exception = Assert.Throws<InvalidOperationException>(() => SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions));
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\Binders\TryParseTypeModelBinderTest.cs (1)
488Assert.Throws<InvalidOperationException>(() => new TryParseModelBinder(typeof(TestClass), NullLoggerFactory.Instance));
ModelBinding\Metadata\ModelAttributesTest.cs (1)
300var 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\ModelBindingHelperTest.cs (9)
355var ex = Assert.Throws<InvalidOperationException>(() => 396var ex = Assert.Throws<InvalidOperationException>(() => 415var ex = Assert.Throws<InvalidOperationException>(() => 431var ex = Assert.Throws<InvalidOperationException>(() => 447var ex = Assert.Throws<InvalidOperationException>(() => 1182var ex = Assert.Throws<FormatException>( 1196Assert.Throws<FormatException>( 1249var ex = Assert.Throws<InvalidOperationException>( 1265var ex = Assert.Throws<InvalidOperationException>(
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)
29var ex = Assert.Throws<InvalidOperationException>(() => Factory.CreateClient());
TestingInfrastructureTests.cs (1)
47var 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.RuntimeCompilation.Test (3)
RuntimeCompilationFileProviderTest.cs (1)
26var exception = Assert.Throws<InvalidOperationException>(
RuntimeViewCompilerTest.cs (2)
754var ex = Assert.Throws<CompilationFailedException>(() => compiler.CompileAndEmit(codeDocument, content)); 773var ex = Assert.Throws<CompilationFailedException>(() => compiler.CompileAndEmit(codeDocument, content));
Microsoft.AspNetCore.Mvc.Razor.Test (1)
RazorPageTest.cs (1)
444ex = Assert.Throws<InvalidOperationException>(() => v.RenderSection("bar"));
Microsoft.AspNetCore.Mvc.RazorPages.Test (7)
ApplicationModels\CompiledPageActionDescriptorBuilderTest.cs (1)
134var actual = Assert.Throws<InvalidOperationException>(() =>
Infrastructure\DefaultPageActivatorProviderTest.cs (1)
63Assert.Throws<ArgumentException>(() => activator.CreateActivator(descriptor));
Infrastructure\DefaultPageFactoryProviderTest.cs (1)
35var ex = Assert.Throws<InvalidOperationException>(() => factoryProvider.CreatePageFactory(descriptor));
Infrastructure\DefaultPageHandlerMethodSelectorTest.cs (2)
661var ex = Assert.Throws<InvalidOperationException>(() => selector.Select(pageContext)); 721var ex = Assert.Throws<InvalidOperationException>(() => selector.Select(pageContext));
Infrastructure\ExecutorFactoryTest.cs (1)
178var ex = Assert.Throws<InvalidOperationException>(() => ExecutorFactory.CreateExecutor(handler));
Infrastructure\ServiceBasedPageModelActivatorProviderTest.cs (1)
115var ex = Assert.Throws<InvalidOperationException>(
Microsoft.AspNetCore.Mvc.TagHelpers.Test (3)
PartialTagHelperTest.cs (2)
122var exception = Assert.Throws<InvalidOperationException>(() => tagHelper.ResolveModel()); 144var exception = Assert.Throws<InvalidOperationException>(() => tagHelper.ResolveModel());
ProtectedPrerenderComponentApplicationStateTest.cs (1)
69Assert.Throws<CryptographicException>(() =>
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)
76var ex = Assert.Throws<InvalidOperationException>(() => GetOpenApiOperation(lambda.Compile()));
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
109Assert.Throws<KeyNotFoundException>(() => env[key]);
Microsoft.AspNetCore.RateLimiting.Tests (12)
RateLimitingApplicationBuilderExtensionsTests.cs (3)
16Assert.Throws<ArgumentNullException>(() => RateLimiterApplicationBuilderExtensions.UseRateLimiter(null)); 23Assert.Throws<ArgumentNullException>(() => appBuilder.UseRateLimiter(null)); 34var ex = Assert.Throws<InvalidOperationException>(() => appBuilder.UseRateLimiter());
RateLimitingMiddlewareTests.cs (4)
24Assert.Throws<ArgumentNullException>(() => new RateLimitingMiddleware( 31Assert.Throws<ArgumentNullException>(() => new RateLimitingMiddleware(c => 40Assert.Throws<ArgumentNullException>(() => new RateLimitingMiddleware(c => 49Assert.Throws<ArgumentNullException>(() => new RateLimitingMiddleware(c =>
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 (2)
ResponseCachingFeatureTests.cs (1)
52Assert.Throws<ArgumentException>(() => new ResponseCachingFeature().VaryByQueryKeys = value);
ResponseCachingKeyProviderTests.cs (1)
62Assert.Throws<InvalidOperationException>(() => cacheKeyProvider.CreateStorageVaryByKey(context));
Microsoft.AspNetCore.Rewrite.Tests (19)
ApacheModRewrite\ConditionPatternParserTest.cs (1)
97var ex = Assert.Throws<FormatException>(() => ConditionPatternParser.ParseActionCondition(input));
ApacheModRewrite\CookieActionFactoryTest.cs (2)
76var ex = Assert.Throws<FormatException>(() => CookieActionFactory.Create(flagValue)); 87var ex = Assert.Throws<FormatException>(() => CookieActionFactory.Create("NAME:VALUE:DOMAIN:" + badInt));
ApacheModRewrite\FlagParserTest.cs (3)
54var ex = Assert.Throws<FormatException>(() => FlagParser.Parse(input)); 61Assert.Throws<ArgumentNullException>(() => FlagParser.Parse(null)); 62Assert.Throws<ArgumentException>(() => FlagParser.Parse(string.Empty));
ApacheModRewrite\FormatExceptionTests.cs (1)
31var ex = Assert.Throws<FormatException>(() => FileParser.Parse(new StringReader(input)));
ApacheModRewrite\RewriteTokenizerTest.cs (2)
81var ex = Assert.Throws<FormatException>(() => Tokenizer.Tokenize("\\")); 88var ex = Assert.Throws<FormatException>(() => Tokenizer.Tokenize("\""));
ApacheModRewrite\RuleRegexParserTest.cs (2)
13Assert.Throws<FormatException>(() => RuleRegexParser.ParseRuleRegex(null)); 19Assert.Throws<FormatException>(() => RuleRegexParser.ParseRuleRegex(string.Empty));
ApacheModRewrite\TestStringParserTests.cs (1)
120var ex = Assert.Throws<FormatException>(() => TestStringParser.Parse(testString));
IISUrlRewrite\FormatExceptionHandlingTests.cs (1)
63var ex = Assert.Throws<FormatException>(() => new UrlRewriteFileParser().Parse(new StringReader(input), false));
IISUrlRewrite\InputParserTests.cs (3)
118Assert.Throws<FormatException>(() => new InputParser().ParseInputString(testString, UriMatchPart.Path)); 124Assert.Throws<FormatException>(() => new InputParser(null, false).ParseInputString("{apiMap:{R:1}}", UriMatchPart.Path)); 134Assert.Throws<FormatException>(() => new InputParser(maps, false).ParseInputString($"{{{undefinedMapName}:{{R:1}}}}", UriMatchPart.Path));
IISUrlRewrite\InvalidUrlRewriteFormatExceptionHandlingTests.cs (1)
215var ex = Assert.Throws<InvalidUrlRewriteFormatException>(() => new UrlRewriteFileParser().Parse(new StringReader(input), false));
PatternSegments\DateTimeSegmentTests.cs (1)
37var ex = Assert.Throws<FormatException>(() => new DateTimeSegment(input));
UrlMatches\IntegerMatchTests.cs (1)
14var ex = Assert.Throws<FormatException>(() => new IntegerMatch("Not an int", IntegerOperationType.Equal));
Microsoft.AspNetCore.Routing.FunctionalTests (1)
MinimalFormTests.cs (1)
228exception = Assert.Throws<InvalidOperationException>(() => app.UseAntiforgery());
Microsoft.AspNetCore.Routing.Tests (52)
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 (6)
127var ex = Assert.Throws<RoutePatternException>(() => builder.DataSources.Single().Endpoints); 138var ex = Assert.Throws<ArgumentNullException>(() => builder.MapGroup((string)null!)); 140ex = Assert.Throws<ArgumentNullException>(() => builder.MapGroup((RoutePattern)null!)); 145ex = Assert.Throws<ArgumentNullException>(() => builder!.MapGroup(RoutePatternFactory.Parse("/"))); 147ex = Assert.Throws<ArgumentNullException>(() => builder!.MapGroup("/")); 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>(
EndpointNameAddressSchemeTest.cs (1)
170var ex = Assert.Throws<InvalidOperationException>(() => addressScheme.FindEndpoints("any name"));
Matching\DataSourceDependentMatcherTest.cs (2)
163var exception = Assert.Throws<InvalidOperationException>( 201var exception = Assert.Throws<InvalidOperationException>(
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 (14)
Listener\RequestBodyTests.cs (1)
31Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(input, 0, input.Length));
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);
ServerTests.cs (1)
387Assert.Throws<ArgumentOutOfRangeException>(() => server.Listener.Options.MaxConnections = -2);
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 (96)
AsciiDecoding.cs (1)
64Assert.Throws<InvalidOperationException>(() => new Span<byte>(byteRange).GetAsciiString());
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)
57var exception = Assert.Throws<InvalidOperationException>(() => block.Memory); 70var exception = Assert.Throws<InvalidOperationException>(() => memory.Pin()); 105var exception = Assert.Throws<InvalidOperationException>(() => MemoryMarshal.TryGetArray<byte>(memory, out _)); 117var exception = Assert.Throws<ObjectDisposedException>(() => block.Memory); 132var exception = Assert.Throws<ObjectDisposedException>(() => memory.Pin()); 171var exception = Assert.Throws<ObjectDisposedException>(() => MemoryMarshal.TryGetArray<byte>(memory, out _)); 194var exception = Assert.Throws<InvalidOperationException>(() => block.Memory); 211var 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"); 560var exception = Assert.Throws<BadHttpRequestException>(() => 940var ex = Assert.Throws<InvalidOperationException>(() => ((IHttpMaxRequestBodySizeFeature)_http1Connection).MaxRequestBodySize = 1); 948var 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);
HttpHeadersTests.cs (2)
295Assert.Throws<ArgumentOutOfRangeException>(() => httpHeaders.ContentLength = -1); 296Assert.Throws<ArgumentOutOfRangeException>(() => httpHeaders.ContentLength = long.MinValue);
HttpParserTests.cs (7)
86var exception = Assert.Throws<BadHttpRequestException>(() => 120var exception = Assert.Throws<BadHttpRequestException>(() => 139var exception = Assert.Throws<BadHttpRequestException>(() => 167var exception = Assert.Throws<BadHttpRequestException>(() => 185var exception = Assert.Throws<BadHttpRequestException>(() => 528var exception = Assert.Throws<BadHttpRequestException>(() => 539exception = 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 (5)
276Assert.Throws<InvalidOperationException>(() => headers.ContentLength = null); 287Assert.Throws<InvalidOperationException>(() => dictionary["my-header"] = "other-value"); 298Assert.Throws<InvalidOperationException>(() => dictionary.Remove("my-header")); 330var exception = Assert.Throws<InvalidOperationException>(() => ((IHeaderDictionary)headers)["Content-Length"] = contentLength); 340var exception = Assert.Throws<InvalidOperationException>(() => headers.HeaderContentLength = contentLength);
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);
HttpUtilitiesTest.cs (1)
249Assert.Throws<InvalidOperationException>(() =>
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 (2)
281var exception = Assert.Throws<ArgumentNullException>(() => 320var exception = Assert.Throws<InvalidOperationException>(() =>
MemoryPoolTests.cs (1)
46var exception = Assert.Throws<ObjectDisposedException>(() => memoryPool.Rent());
MessageBodyTests.cs (12)
146Assert.Throws<InvalidOperationException>(() => reader.TryRead(out readResult)); 548var ex = Assert.Throws<BadHttpRequestException>(() => 582var ex = Assert.Throws<BadHttpRequestException>(() => 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));
ResourceCounterTests.cs (1)
18Assert.Throws<ArgumentOutOfRangeException>(() => ResourceCounter.Quota(max));
SniOptionsSelectorTests.cs (4)
324var exception = Assert.Throws<ArgumentException>(() => new SniOptionsSelector( 345var authExWithServerName = Assert.Throws<AuthenticationException>(() => sniOptionsSelector.GetOptions(new MockConnectionContext(), "example.org")); 348var authExWithoutServerName = Assert.Throws<AuthenticationException>(() => sniOptionsSelector.GetOptions(new MockConnectionContext(), null)); 513var ex = Assert.Throws<InvalidOperationException>(
src\Shared\test\Shared.Tests\runtime\Http2\DynamicTableTest.cs (2)
67Assert.Throws<IndexOutOfRangeException>(() => dynamicTable[0]); 70Assert.Throws<IndexOutOfRangeException>(() => dynamicTable[1]);
src\Shared\test\Shared.Tests\runtime\Http2\HPackIntegerTest.cs (1)
103Assert.Throws<HPackDecodingException>(() => decoder.TryDecode(octets[octets.Length - 1], out intResult));
src\Shared\test\Shared.Tests\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));
UTF8Decoding.cs (1)
39Assert.Throws<InvalidOperationException>(() =>
Microsoft.AspNetCore.Server.Kestrel.Tests (6)
ConfigurationReaderTests.cs (4)
97var exception = Assert.Throws<ArgumentException>(() => 138Assert.Throws<InvalidOperationException>(() => reader.Endpoints); 149Assert.Throws<InvalidOperationException>(() => reader.Endpoints); 308var end1Ex = Assert.Throws<InvalidOperationException>(() => reader.Endpoints);
HttpsConnectionAdapterOptionsTest.cs (1)
37var exception = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpsConnectionAdapterOptions { HandshakeTimeout = value });
KestrelConfigurationLoaderTests.cs (1)
371Assert.Throws<InvalidOperationException>(() => serverOptions.ConfigurationLoader.Reload());
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (2)
QuicConnectionContextTests.cs (1)
764Assert.Throws<ArgumentOutOfRangeException>(() => protocolErrorCodeFeature.Error = errorCode);
QuicStreamContextTests.cs (1)
555Assert.Throws<ArgumentOutOfRangeException>(() => protocolErrorCodeFeature.Error = errorCode);
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)
744var 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 (20)
AddSignalRTests.cs (1)
196Assert.Throws<ArgumentOutOfRangeException>(() => new HubOptions() { MaximumParallelInvocationsPerClient = 0 });
DefaultTransportFactoryTests.cs (3)
35var exception = Assert.Throws<ArgumentException>( 68var ex = Assert.Throws<InvalidOperationException>( 105var ex = Assert.Throws<InvalidOperationException>(
HubConnectionHandlerTests.cs (5)
243var ex = Assert.Throws<InvalidOperationException>(() => 1361var exception = Assert.Throws<NotSupportedException>(() => serviceProvider.GetService<HubConnectionHandler<GenericMethodHub>>()); 5064var ex = Assert.Throws<InvalidOperationException>(() => serviceProvider.GetService<HubConnectionHandler<KeyedServicesHub>>()); 5080var ex = Assert.Throws<InvalidOperationException>(() => serviceProvider.GetService<HubConnectionHandler<BadServicesHub>>()); 5091Assert.Throws<InvalidOperationException>(
Internal\DefaultHubProtocolResolverTests.cs (1)
59var exception = Assert.Throws<ArgumentNullException>(
Internal\MessageBufferTests.cs (1)
294Assert.Throws<InvalidOperationException>(() => messageBuffer.ShouldProcessMessage(new SequenceMessage(2)));
Internal\TypedClientBuilderTests.cs (9)
135var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<object>.Build(clientProxy)); 143var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<ValueTask>.Build(clientProxy)); 151var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<EventHandler>.Build(clientProxy)); 159var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IVoidMethodClient>.Build(clientProxy)); 167var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IStringMethodClient>.Build(clientProxy)); 175var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IOutParamMethodClient>.Build(clientProxy)); 184var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IRefParamMethodClient>.Build(clientProxy)); 193var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IPropertiesClient>.Build(clientProxy)); 201var ex = Assert.Throws<InvalidOperationException>(() => TypedClientBuilder<IEventsClient>.Build(clientProxy));
Microsoft.AspNetCore.TestHost.Tests (10)
ClientHandlerTests.cs (1)
345Assert.Throws<NotSupportedException>(() => invoker.Send(message, CancellationToken.None));
HttpContextBuilderTests.cs (1)
417var ex = Assert.Throws<IOException>(() => context.Response.Body.Read(new byte[100], 0, 100));
ResponseFeatureTests.cs (5)
63Assert.Throws<InvalidOperationException>(() => responseInformation.StatusCode = 400); 64Assert.Throws<InvalidOperationException>(() => responseInformation.ReasonPhrase = "Hello World"); 72Assert.Throws<ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 99); 73Assert.Throws<ArgumentOutOfRangeException>(() => responseInformation.StatusCode = 0); 74Assert.Throws<ArgumentOutOfRangeException>(() => responseInformation.StatusCode = -200);
TestServerTests.cs (2)
127Assert.Throws<InvalidOperationException>(() => new TestServer(builder)); 382Assert.Throws<ArgumentNullException>(() => new TestServer(builder, null));
UseSolutionRelativeContentRootTests.cs (1)
157var exception = Assert.Throws<InvalidOperationException>(() =>
Microsoft.AspNetCore.Tests (35)
WebApplicationTests.cs (35)
282Assert.Throws<InvalidOperationException>(() => app.Urls); 373Assert.Throws<NotSupportedException>(() => ((IHostBuilder)createBuilder().Host).Build()); 381Assert.Throws<NotSupportedException>(() => ((IWebHostBuilder)createBuilder().WebHost).Build()); 395Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ApplicationKey, nameof(WebApplicationTests))); 396Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.EnvironmentKey, envName)); 397Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.ContentRootKey, contentRoot)); 398Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.WebRootKey, webRoot)); 399Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "hosting")); 400Assert.Throws<NotSupportedException>(() => builder.WebHost.UseSetting(WebHostDefaults.HostingStartupExcludeAssembliesKey, "hostingexclude")); 401Assert.Throws<NotSupportedException>(() => builder.WebHost.UseEnvironment(envName)); 402Assert.Throws<NotSupportedException>(() => builder.WebHost.UseContentRoot(contentRoot)); 415Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 423Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 431Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 439Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 447Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 455Assert.Throws<NotSupportedException>(() => builder.WebHost.ConfigureAppConfiguration(builder => 1082Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureHostConfiguration(builder => 1090Assert.Throws<NotSupportedException>(() => builder.Host.UseEnvironment(envName)); 1091Assert.Throws<NotSupportedException>(() => builder.Host.UseContentRoot(contentRoot)); 1622var ex = Assert.Throws<InvalidOperationException>(() => app.UseEndpoints(endpoints => { })); 1819Assert.Throws<InvalidOperationException>(() => builder.Services.AddSingleton<IService>(new Service())); 1821Assert.Throws<InvalidOperationException>(() => builder.Services.AddScoped<IService, Service>()); 1823Assert.Throws<InvalidOperationException>(() => builder.Services.Remove(ServiceDescriptor.Singleton(new Service()))); 1824Assert.Throws<InvalidOperationException>(() => builder.Services[0] = ServiceDescriptor.Singleton(new Service())); 1833var ex = Assert.Throws<NotSupportedException>(() => builder.WebHost.Configure(app => { })); 1834var ex1 = Assert.Throws<NotSupportedException>(() => builder.WebHost.Configure((context, app) => { })); 1835var ex2 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup<MyStartup>()); 1836var ex3 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup(typeof(MyStartup))); 1837var ex4 = Assert.Throws<NotSupportedException>(() => builder.WebHost.UseStartup(context => new MyStartup())); 1845var ex5 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHost(webHostBuilder => { })); 1846var ex6 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHost(webHostBuilder => { }, options => { })); 1847var ex7 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureSlimWebHost(webHostBuilder => { }, options => { })); 1848var ex8 = Assert.Throws<NotSupportedException>(() => builder.Host.ConfigureWebHostDefaults(webHostBuilder => { })); 2727Assert.Throws<NotSupportedException>(() => debugView.Middleware);
Microsoft.AspNetCore.WebSockets.Tests (1)
AddWebSocketsTests.cs (1)
36Assert.Throws<ArgumentOutOfRangeException>(() => new WebSocketOptions() { KeepAliveTimeout = TimeSpan.FromMicroseconds(-1) });
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.Tasks.CodeAnalysis.UnitTests (1)
CscTests.cs (1)
648Assert.Throws<ArgumentException>(() => csc.GenerateResponseFileContents());
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (1)
CommandLineTests.cs (1)
7838Assert.Throws<Win32Exception>(() => Win32Res.GetResource(lib, resourceId, resourceType, out manifestSize));
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
PdbSourceDocument\PdbSourceDocumentTests.cs (1)
945Assert.Throws<System.ArgumentException>(() => service.TryAddDocumentToWorkspace(fileTwo.FilePath, new StaticSourceTextContainer(SourceText.From(string.Empty)), out var documentIdTwo));
Workspaces\WorkspaceTests_EditorFeatures.cs (1)
1455Assert.Throws<ArgumentException>(() => VersionStamp.Create(DateTime.Now));
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (36)
CodeGen\CodeGenTupleTest.cs (27)
5791Assert.Throws<ArgumentNullException>(() => comp.CreateTupleTypeSymbol(null, default(ImmutableArray<string>))); 5795var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vt2, new[] { "Item1" }.AsImmutable())); 5800e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vt2, elementLocations: new[] { loc1 }.AsImmutable())); 5832Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vt8, default)); 6213Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(underlyingType: vt2)); 6216Assert.Throws<ArgumentNullException>(() => comp.CreateErrorTypeSymbol(null, null, 2)); 6217Assert.Throws<ArgumentException>(() => comp.CreateErrorTypeSymbol(null, "a", -1)); 6218Assert.Throws<ArgumentException>(() => comp.CreateErrorTypeSymbol(vbComp.GlobalNamespace, "a", 1)); 6220Assert.Throws<ArgumentNullException>(() => comp.CreateErrorNamespaceSymbol(null, "a")); 6221Assert.Throws<ArgumentNullException>(() => comp.CreateErrorNamespaceSymbol(vbComp.GlobalNamespace, null)); 6222Assert.Throws<ArgumentException>(() => comp.CreateErrorNamespaceSymbol(vbComp.GlobalNamespace, "a")); 6283var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(intType)); 6296var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vt2, ImmutableArray.Create("123", ""))); 6314var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(vbType, default(ImmutableArray<string>))); 6331var e = Assert.Throws<ArgumentException>(() => comp.CreateAnonymousTypeSymbol(ImmutableArray.Create(vbType), ImmutableArray.Create("m1"))); 6341Assert.Throws<ArgumentNullException>(() => comp.CreateTupleTypeSymbol(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<string>))); 6344Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(ImmutableArray<ITypeSymbol>.Empty, default(ImmutableArray<string>))); 6345Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(new[] { intType }.AsImmutable(), default(ImmutableArray<string>))); 6348Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(new[] { intType, intType }.AsImmutable(), new[] { "Item1" }.AsImmutable())); 6352Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(new[] { intType, intType }.AsImmutable(), elementLocations: ImmutableArray.Create(loc1))); 6355Assert.Throws<ArgumentNullException>(() => comp.CreateTupleTypeSymbol(new[] { intType, null }.AsImmutable(), default(ImmutableArray<string>))); 6586Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(ImmutableArray.Create(intType, vbType), default(ImmutableArray<string>))); 6802var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 6842var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(underlyingType, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.NotAnnotated, 8))); 6871var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 6911var e = Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(elementTypes, elementNullableAnnotations: CreateAnnotations(CodeAnalysis.NullableAnnotation.NotAnnotated, 8))); 10959Assert.Throws<ArgumentNullException>(() => Compilation.GetRequiredLanguageVersion(null));
Emit\CompilationEmitTests.cs (9)
2530Assert.Throws<ArgumentException>(() => comp.Emit(output, pdbOutput, 2544Assert.Throws<ArgumentException>(() => comp.Emit(output, metadataPEStream: metadataPeOutput, 2558Assert.Throws<ArgumentException>(() => comp.Emit(output, metadataPEStream: metadataPeOutput, 2586Assert.Throws<ArgumentException>(() => comp.Emit(output, metadataPEStream: metadataPeOutput, 2599Assert.Throws<ArgumentException>(() => comp.Emit(output, 2638Assert.Throws<ArgumentException>(() => comp.Emit(output, 5181Assert.Throws<ArgumentException>(() => compilation.Emit(outReal)); 5489Assert.Throws<OperationCanceledException>(() => comp.Emit(peStream, 5511Assert.Throws<OperationCanceledException>(() => compilation.Emit(broken));
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Emit\EditAndContinue\EditAndContinueTests.cs (1)
13370Assert.Throws<ArgumentOutOfRangeException>(() =>
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (30)
Attributes\AttributeTests.cs (6)
5759Assert.Throws<InvalidOperationException>(() => args[0].Value); 5763Assert.Throws<InvalidOperationException>(() => args[1].Value); 5769Assert.Throws<InvalidOperationException>(() => named["P"].Value); 5773Assert.Throws<InvalidOperationException>(() => named["F"].Value); 5803Assert.Throws<InvalidOperationException>(() => args[0].Values); 5807Assert.Throws<InvalidOperationException>(() => args[1].Values);
Attributes\AttributeTests_WellKnownAttributes.cs (4)
865Assert.Throws<InvalidOperationException>(() => ps[0].ExplicitDefaultValue); 931Assert.Throws<InvalidOperationException>(() => ps[0].ExplicitDefaultValue); 1020Assert.Throws<InvalidOperationException>(() => ps[0].ExplicitDefaultValue); 1064Assert.Throws<InvalidOperationException>(() => ps[0].ExplicitDefaultValue);
Diagnostics\DiagnosticSuppressorTests.cs (1)
681Assert.Throws<OperationCanceledException>(() => compilation.GetAnalyzerDiagnostics(analyzersAndSuppressors, reportSuppressedDiagnostics: true, cancellationToken: cancellationToken));
FlowAnalysis\RegionAnalysisTests.cs (6)
3103Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeControlFlow(statement, null)); 3104Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeControlFlow(null, statement)); 3105Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeControlFlow(null)); 3106Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeDataFlow(null, statement)); 3107Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeDataFlow(statement, null)); 3108Assert.Throws<ArgumentNullException>(() => semanticModel.AnalyzeDataFlow((StatementSyntax)null));
Semantics\CollectionExpressionTests.cs (2)
27077Assert.Throws<ArgumentNullException>(() => spread.GetElementConversion()); 27084Assert.Throws<ArgumentException>(() => spread.GetElementConversion());
Semantics\OutVarTests.cs (2)
1104Assert.Throws<NotSupportedException>(() => model.AnalyzeDataFlow(dataFlowParent)); 32791Assert.Throws<NotSupportedException>(() => model.AnalyzeDataFlow(dataFlowParent));
Semantics\PatternMatchingTestBase.cs (1)
326Assert.Throws<NotSupportedException>(() => model.AnalyzeDataFlow(dataFlowParent));
Semantics\PrimaryConstructorTests.cs (4)
2196Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, (PrimaryConstructorBaseTypeSyntax)null, out _)); 2197Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, baseWithargs, out _)); 2335Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, (PrimaryConstructorBaseTypeSyntax)null, out _)); 2336Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, baseWithargs, out _));
Semantics\RecordTests.cs (4)
22412Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, (PrimaryConstructorBaseTypeSyntax)null!, out _)); 22413Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, baseWithargs, out _)); 22551Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, (PrimaryConstructorBaseTypeSyntax)null!, out _)); 22552Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(baseWithargs.ArgumentList.OpenParenToken.SpanStart, baseWithargs, out _));
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (20)
IOperation\IOperationTests_IAnonymousFunctionExpression.cs (13)
854Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraph(null)); 855Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraph(lambdaD1.Symbol)); 856Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(null)); 857Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(lambdaD1.Symbol)); 870Assert.Throws<ArgumentNullException>(() => graphM.GetAnonymousFunctionControlFlowGraph(null)); 871Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetAnonymousFunctionControlFlowGraph(lambdaD2)); 872Assert.Throws<ArgumentNullException>(() => graphM.GetAnonymousFunctionControlFlowGraphInScope(null)); 873Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetAnonymousFunctionControlFlowGraphInScope(lambdaD2)); 912Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraph(null)); 913Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraph(lambdaD1.Symbol)); 914Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(null)); 915Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(lambdaD1.Symbol)); 927Assert.Throws<ArgumentOutOfRangeException>(() => graphD2.GetAnonymousFunctionControlFlowGraph(lambdaD1));
IOperation\IOperationTests_IArgument.cs (2)
3072Assert.Throws<ArgumentException>(() => argument.GetInConversion()); 3073Assert.Throws<ArgumentException>(() => argument.GetOutConversion());
IOperation\IOperationTests_ILocalFunctionStatement.cs (5)
1816Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraph(null)); 1817Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraph(localFunctionD2)); 1818Assert.Throws<ArgumentNullException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(null)); 1819Assert.Throws<ArgumentOutOfRangeException>(() => graphM.GetLocalFunctionControlFlowGraphInScope(localFunctionD2)); 1868Assert.Throws<ArgumentOutOfRangeException>(() => graphD2.GetLocalFunctionControlFlowGraph(localFunctionD1));
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (1)
InteractiveSessionReferencesTests.cs (1)
483Assert.Throws<TypeLoadException>(() => script.EvaluateAsync().GetAwaiter().GetResult());
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (17)
InteractiveSessionTests.cs (4)
502Assert.Throws<ArgumentException>(() => compilation2.IsSymbolAccessibleWithin(c3C3, c3C1)); 624Assert.Throws<CompilationErrorException>(() => s0.ContinueWithAsync("invalid$syntax").Result); 628Assert.Throws<CompilationErrorException>(() => s1.ContinueWithAsync("invalid$syntax").Result); 629Assert.Throws<CompilationErrorException>(() => s1.ContinueWithAsync("x = undefined_symbol").Result);
PrintOptionsTests.cs (5)
21Assert.Throws<ArgumentNullException>(() => s_formatter.FormatObject("hello", options: null)); 27Assert.Throws<ArgumentOutOfRangeException>(() => new PrintOptions().NumberRadix = 3); 33Assert.Throws<ArgumentOutOfRangeException>(() => new PrintOptions().MemberDisplayFormat = (MemberDisplayFormat)(-1)); 39Assert.Throws<ArgumentOutOfRangeException>(() => new PrintOptions().MaximumOutputLength = -1); 40Assert.Throws<ArgumentOutOfRangeException>(() => new PrintOptions().MaximumOutputLength = 0);
ScriptOptionsTests.cs (1)
35Assert.Throws<InvalidOperationException>(() => options.WithLanguageVersion(LanguageVersion.CSharp8));
ScriptTests.cs (7)
42Assert.Throws<ArgumentNullException>(() => CSharpScript.Create((string)null)); 55Assert.Throws<ArgumentNullException>(() => CSharpScript.Create((Stream)null, ScriptOptions)); 444Assert.Throws<ArgumentException>(() => state.GetVariable("x").Value = "str"); 445Assert.Throws<InvalidOperationException>(() => state.GetVariable("y").Value = "str"); 446Assert.Throws<InvalidOperationException>(() => state.GetVariable("z").Value = "str"); 447Assert.Throws<InvalidOperationException>(() => state.GetVariable("y").Value = 0); 448Assert.Throws<InvalidOperationException>(() => state.GetVariable("z").Value = 0);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (48)
Semantics\AccessCheckTests.cs (3)
975Assert.Throws<ArgumentException>(() => compilation.IsSymbolAccessibleWithin(classC, classQ)); 1525Assert.Throws<ArgumentException>(() => ((Compilation)comp2).IsSymbolAccessibleWithin(ptr1, b)); 1526Assert.Throws<ArgumentException>(() => ((Compilation)comp2).IsSymbolAccessibleWithin(ptr2, b));
Semantics\AccessibilityTests.cs (3)
42Assert.Throws<ArgumentNullException>(() => 49Assert.Throws<ArgumentOutOfRangeException>(() => 52Assert.Throws<ArgumentOutOfRangeException>(() =>
Semantics\LambdaTests.cs (3)
8013Assert.Throws<InvalidOperationException>(() => lambdas[0].Symbol.Parameters[0].ExplicitDefaultValue); 8023Assert.Throws<InvalidOperationException>(() => lambdas[1].Symbol.Parameters[0].ExplicitDefaultValue); 8030Assert.Throws<InvalidOperationException>(() => lambdas[2].Symbol.Parameters[0].ExplicitDefaultValue);
Semantics\MemberResolutionResultTests.cs (2)
23Assert.Throws<NotSupportedException>(() => d.Equals(d)); 24Assert.Throws<NotSupportedException>(() => d.GetHashCode());
Semantics\NamedAndOptionalTests.cs (18)
2054Assert.Throws<InvalidOperationException>(() => parameters[0].ExplicitDefaultValue); 2072Assert.Throws<InvalidOperationException>(() => parameters[3].ExplicitDefaultValue); 2078Assert.Throws<InvalidOperationException>(() => parameters[4].ExplicitDefaultValue); 2085Assert.Throws<InvalidOperationException>(() => parameters[5].ExplicitDefaultValue); 2137Assert.Throws<InvalidOperationException>(() => parameters[0].ExplicitDefaultValue); 2148Assert.Throws<InvalidOperationException>(() => parameters[2].ExplicitDefaultValue); 2187Assert.Throws<InvalidOperationException>(() => parameters[0].ExplicitDefaultValue); 2205Assert.Throws<InvalidOperationException>(() => parameters[3].ExplicitDefaultValue); 2211Assert.Throws<InvalidOperationException>(() => parameters[4].ExplicitDefaultValue); 2224Assert.Throws<InvalidOperationException>(() => parameters[6].ExplicitDefaultValue); 2270Assert.Throws<InvalidOperationException>(() => parameters[0].ExplicitDefaultValue); 2288Assert.Throws<InvalidOperationException>(() => parameters[3].ExplicitDefaultValue); 2294Assert.Throws<InvalidOperationException>(() => parameters[4].ExplicitDefaultValue); 2301Assert.Throws<InvalidOperationException>(() => parameters[5].ExplicitDefaultValue); 2352Assert.Throws<InvalidOperationException>(() => parameters[0].ExplicitDefaultValue); 2364Assert.Throws<InvalidOperationException>(() => parameters[2].ExplicitDefaultValue); 2370Assert.Throws<InvalidOperationException>(() => parameters[3].ExplicitDefaultValue); 2377Assert.Throws<InvalidOperationException>(() => parameters[4].ExplicitDefaultValue);
Semantics\ScriptSemanticsTests.cs (1)
874Assert.Throws<InvalidOperationException>(() => CreateSubmission("a + 1", previous: s0));
Semantics\SyntaxTreeRootTests.cs (4)
57Assert.Throws<ArgumentException>(() => CSharpCompilation.Create("Grrr", syntaxTrees: new[] { arbitraryTree })); 58Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("Wah").AddSyntaxTrees(arbitraryTree)); 59Assert.Throws<ArgumentException>(() => CSharpCompilation.Create("Bahh", syntaxTrees: new[] { parsedTree }).ReplaceSyntaxTree(parsedTree, arbitraryTree)); 60Assert.Throws<ArgumentException>(() => CSharpCompilation.Create("Woo").GetSemanticModel(arbitraryTree));
Semantics\TopLevelStatementsTests.cs (1)
1983Assert.Throws<System.ArgumentException>(() => CreateCompilation(new[] { Parse(text1, filename: "text1", DefaultParseOptions),
SourceGeneration\GeneratorDriverTests.cs (11)
763Assert.Throws<OperationCanceledException>(() => 1700Assert.Throws<InvalidOperationException>(() => throwsFunc(20, CancellationToken.None)); 1701Assert.Throws<UserFunctionException>(() => userThrowsFunc(20, CancellationToken.None)); 1713Assert.Throws<OperationCanceledException>(() => timeoutFunc(30, new CancellationToken(true))); 1714Assert.Throws<OperationCanceledException>(() => userTimeoutFunc(30, new CancellationToken(true))); 1717Assert.Throws<OperationCanceledException>(() => otherTimeoutFunc(30, CancellationToken.None)); 1718Assert.Throws<UserFunctionException>(() => userOtherTimeoutFunc(30, CancellationToken.None)); 2605Assert.Throws<OperationCanceledException>(() => driver = driver.RunGenerators(compilation, cancellationToken: cts.Token)); 2668Assert.Throws<ArgumentNullException>(() => driver.WithUpdatedParseOptions(null!)); 2819Assert.Throws<ArgumentNullException>(() => driver.WithUpdatedAnalyzerConfigOptions(null!)); 3006Assert.Throws<ArgumentNullException>(() => driver.ReplaceAdditionalText(additionalText1, null!));
SourceGeneration\SyntaxAwareGeneratorTests.cs (2)
1996Assert.Throws<OperationCanceledException>(() => driver = driver.RunGenerators(compilation, cancellationToken: cts.Token)); 2025Assert.Throws<OperationCanceledException>(() => driver = driver.RunGenerators(compilation, cancellationToken: cts.Token));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (135)
Compilation\CompilationAPITests.cs (68)
388Assert.Throws<ArgumentException>(() => c.Emit(peStream)); 389Assert.Throws<ArgumentException>(() => c.Emit(new MemoryStream(), pdbStream)); 818Assert.Throws<ArgumentException>(() => comp.AddSyntaxTrees(t1)); 821Assert.Throws<ArgumentException>(() => comp.ReplaceSyntaxTree(t1, comp.SyntaxTrees[0])); 824Assert.Throws<ArgumentException>(() => comp = comp.RemoveSyntaxTrees(SyntaxFactory.ParseSyntaxTree(s1))); 828Assert.Throws<ArgumentException>(() => comp = comp.RemoveSyntaxTrees(withErrorTree)); 856Assert.Throws<ArgumentException>(() => compCollection = compCollection.AddSyntaxTrees(t4, t5).RemoveSyntaxTrees(col)); 867Assert.Throws<ArgumentException>(() => compCollection = compCollection.AddSyntaxTrees(t4, t6).RemoveSyntaxTrees(stack)); 878Assert.Throws<ArgumentException>(() => compCollection = compCollection.AddSyntaxTrees(t4, t6).RemoveSyntaxTrees(queue)); 913Assert.Throws<ArgumentException>(() => CSharpCompilation.Create("Compilation", new SyntaxTree[] { withExpressionRootTree })); 916Assert.Throws<ArgumentException>(() => comp.AddSyntaxTrees(withExpressionRootTree)); 919Assert.Throws<ArgumentException>(() => comp.ReplaceSyntaxTree(comp.SyntaxTrees[0], withExpressionRootTree)); 956Assert.Throws<ArgumentException>(() => comp = comp.AddSyntaxTrees(listSyntaxTree).AddReferences().ReplaceSyntaxTree(t1, t2)); 1296Assert.Throws<ArgumentException>(() => comp.AddReferences(compRef)); 1340Assert.Throws<ArgumentNullException>(() => CSharpCompilation.Create("goo", syntaxTrees: new SyntaxTree[] { null })); 1341Assert.Throws<ArgumentNullException>(() => CSharpCompilation.Create("goo", references: new MetadataReference[] { null })); 1381Assert.Throws<ArgumentException>(() => comp.AddReferences(compRef)); 1427Assert.Throws<ArgumentException>(() => comp.AddReferences(listRef).AddReferences(ref2).RemoveReferences(ref1, ref2, ref3, ref4).ReplaceReference(ref2, ref2)); 1437Assert.Throws<ArgumentException>(() => comp = comp.RemoveReferences(ref1)); 1442Assert.Throws<ArgumentException>(() => comp = comp.ReplaceReference(MscorlibRef, ref1)); 1488Assert.Throws<ArgumentException>(() => comp.ReplaceSyntaxTree(newTree: SyntaxFactory.ParseSyntaxTree("Using System;"), oldTree: t1)); 1555Assert.Throws<ArgumentException>(() => (comp.AddSyntaxTrees(t1, t1))); 2399Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", returnType: genericParameter)); 2400Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", returnType: open)); 2401Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", returnType: typeof(void))); 2402Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", returnType: byref)); 2404Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: genericParameter)); 2405Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: open)); 2406Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: typeof(void))); 2407Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: typeof(int))); 2408Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: ptr)); 2409Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", globalsType: byref)); 2412Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a1", previousScriptCompilation: s0, globalsType: typeof(List<bool>))); 2415Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseExe)); 2416Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithOutputKind(OutputKind.NetModule))); 2417Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsRuntimeMetadata))); 2418Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsRuntimeApplication))); 2419Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsApplication))); 2420Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithCryptoKeyContainer("goo"))); 2421Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithCryptoKeyFile("goo.snk"))); 2422Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithDelaySign(true))); 2423Assert.Throws<ArgumentException>(() => CSharpCompilation.CreateScriptCompilation("a", options: TestOptions.ReleaseDll.WithDelaySign(false))); 2452Assert.Throws<InvalidOperationException>(() => CreateSubmission("a + 1", previous: s0)); 2467Assert.Throws<ArgumentException>(() => comp.CreateArrayTypeSymbol(elementType, default)); 2468Assert.Throws<ArgumentException>(() => comp.CreateArrayTypeSymbol(elementType, 0)); 2475Assert.Throws<ArgumentException>(() => comp.CreateArrayTypeSymbol(elementType, rank: default)); 2476Assert.Throws<ArgumentException>(() => comp.CreateArrayTypeSymbol(elementType, rank: 0)); 2507Assert.Throws<ArgumentException>(() => 2517Assert.Throws<ArgumentException>(() => 2529Assert.Throws<ArgumentException>(() => 2541Assert.Throws<ArgumentException>(() => 2553Assert.Throws<ArgumentNullException>(() => 2565Assert.Throws<ArgumentNullException>(() => 2575Assert.Throws<ArgumentNullException>(() => 2585Assert.Throws<ArgumentNullException>(() => 2595Assert.Throws<ArgumentNullException>(() => 2704Assert.Throws<ArgumentException>(() => comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations: ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated))); 2770Assert.Throws<ArgumentException>(() => 3033Assert.Throws<ArgumentException>(() => genericType.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>))); 3034Assert.Throws<ArgumentException>(() => genericType.Construct(typeArguments: default, typeArgumentNullableAnnotations: default)); 3041Assert.Throws<ArgumentException>(() => genericType.Construct(typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 3042Assert.Throws<ArgumentException>(() => genericType.Construct(ImmutableArray.Create<ITypeSymbol>(null, null), default)); 3052Assert.Throws<ArgumentException>(() => genericType.Construct(typeArguments, default)); 3068Assert.Throws<ArgumentException>(() => genericMethod.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>))); 3069Assert.Throws<ArgumentException>(() => genericMethod.Construct(typeArguments: default, typeArgumentNullableAnnotations: default)); 3076Assert.Throws<ArgumentException>(() => genericMethod.Construct(typeArguments, ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty)); 3077Assert.Throws<ArgumentException>(() => genericMethod.Construct(ImmutableArray.Create<ITypeSymbol>(null, null), default)); 3087Assert.Throws<ArgumentException>(() => genericMethod.Construct(typeArguments, default));
Compilation\GetSemanticInfoTests.cs (11)
4053Assert.Throws<InvalidOperationException>(() => method1.ReducedFrom.GetTypeInferredDuringReduction(null)); 4054Assert.Throws<ArgumentNullException>(() => method1.GetTypeInferredDuringReduction(null)); 4055Assert.Throws<ArgumentException>(() => method1.GetTypeInferredDuringReduction( 5408Assert.Throws<InvalidOperationException>(() => type.Construct(objectType)); // non-generic type 5414Assert.Throws<InvalidOperationException>(() => type.Construct(objectType)); // non-generic type 5420Assert.Throws<ArgumentException>(() => type.Construct(new ITypeSymbol[] { null })); // null type arg 5421Assert.Throws<ArgumentException>(() => type.Construct()); // typeArgs.Length != Arity 5422Assert.Throws<InvalidOperationException>(() => type.Construct(objectType).Construct(objectType)); // constructed type 5428Assert.Throws<ArgumentException>(() => type.Construct(new ITypeSymbol[] { null })); // null type arg 5429Assert.Throws<ArgumentException>(() => type.Construct()); // typeArgs.Length != Arity 5430Assert.Throws<InvalidOperationException>(() => type.Construct(objectType).Construct(objectType)); // constructed type
Compilation\ReferenceManagerTests.cs (1)
2144Assert.Throws<ObjectDisposedException>(() => compilation.GetTypeByMetadataName("System.Int64").GetMembers());
Compilation\SemanticModelAPITests.cs (9)
2181Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(statement.SpanStart, statement: null, speculativeModel: out speculativeModel)); 2182Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(statement.SpanStart, constructorInitializer: (ConstructorInitializerSyntax)null, speculativeModel: out speculativeModel)); 2183Assert.Throws<ArgumentNullException>(() => model.TryGetSpeculativeSemanticModel(statement.SpanStart, attribute: null, speculativeModel: out speculativeModel)); 2186Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(statement.SpanStart, statement: statement, speculativeModel: out speculativeModel)); 2187Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(ctorInitializer.SpanStart, constructorInitializer: ctorInitializer, speculativeModel: out speculativeModel)); 2188Assert.Throws<ArgumentException>(() => model.TryGetSpeculativeSemanticModel(attribute.SpanStart, attribute: attribute, speculativeModel: out speculativeModel)); 2193Assert.Throws<InvalidOperationException>(() => speculativeModel.TryGetSpeculativeSemanticModel(speculatedStatement.SpanStart, speculatedStatement, speculativeModel: out speculativeModel)); 2235Assert.Throws<InvalidOperationException>(() => speculativeModel.TryGetSpeculativeSemanticModel(speculatedStatement.SpanStart, newSpeculatedStatement, out newModel)); 2239Assert.Throws<InvalidOperationException>(() => speculativeModel.TryGetSpeculativeSemanticModel(speculatedStatement.SpanStart, newSpeculatedStatement, out newModel));
Compilation\SemanticModelGetSemanticInfoTests.cs (7)
1660Assert.Throws<ArgumentNullException>(() => model.GetSymbolInfo((ExpressionSyntax)null)); 1661Assert.Throws<ArgumentNullException>(() => model.GetTypeInfo((ExpressionSyntax)null)); 1662Assert.Throws<ArgumentNullException>(() => model.GetMemberGroup((ExpressionSyntax)null)); 1663Assert.Throws<ArgumentNullException>(() => model.GetConstantValue((ExpressionSyntax)null)); 1665Assert.Throws<ArgumentNullException>(() => model.GetSymbolInfo((ConstructorInitializerSyntax)null)); 1666Assert.Throws<ArgumentNullException>(() => model.GetTypeInfo((ConstructorInitializerSyntax)null)); 1667Assert.Throws<ArgumentNullException>(() => model.GetMemberGroup((ConstructorInitializerSyntax)null));
DocumentationComments\DocumentationCommentCompilerTests.cs (1)
4410Assert.Throws<XmlException>(() => XElement.Parse(xml));
Symbols\AnonymousTypesSemanticsTests.cs (1)
1980Assert.Throws<InvalidOperationException>(() => namedType.Construct(args));
Symbols\CorLibrary\CorTypes.cs (4)
235Assert.Throws<ArgumentOutOfRangeException>(() => c1.GetSpecialType(SpecialType.None)); 236Assert.Throws<ArgumentOutOfRangeException>(() => ((Compilation)c1).GetSpecialType(SpecialType.None)); 237Assert.Throws<ArgumentOutOfRangeException>(() => c1.GetSpecialType(InternalSpecialType.NextAvailable)); 238Assert.Throws<ArgumentOutOfRangeException>(() => ((Compilation)c1).GetSpecialType(SpecialType.Count + 1));
Symbols\CustomModifiersTests.cs (13)
69Assert.Throws<System.IndexOutOfRangeException>(() => type.GetTypeArgumentCustomModifiers(1)); 70Assert.Throws<System.IndexOutOfRangeException>(() => type.GetTypeArgumentCustomModifiers(-1)); 75Assert.Throws<System.IndexOutOfRangeException>(() => nullable.GetTypeArgumentCustomModifiers(1)); 76Assert.Throws<System.IndexOutOfRangeException>(() => nullable.GetTypeArgumentCustomModifiers(-1)); 80Assert.Throws<System.IndexOutOfRangeException>(() => i.GetTypeArgumentCustomModifiers(0)); 85Assert.Throws<System.IndexOutOfRangeException>(() => nullable.GetTypeArgumentCustomModifiers(1)); 86Assert.Throws<System.IndexOutOfRangeException>(() => nullable.GetTypeArgumentCustomModifiers(-1)); 144Assert.Throws<System.IndexOutOfRangeException>(() => type.GetTypeArgumentCustomModifiers(2)); 145Assert.Throws<System.IndexOutOfRangeException>(() => type.GetTypeArgumentCustomModifiers(-1)); 151Assert.Throws<System.IndexOutOfRangeException>(() => dictionary.GetTypeArgumentCustomModifiers(2)); 152Assert.Throws<System.IndexOutOfRangeException>(() => dictionary.GetTypeArgumentCustomModifiers(-1)); 159Assert.Throws<System.IndexOutOfRangeException>(() => dictionary.GetTypeArgumentCustomModifiers(2)); 160Assert.Throws<System.IndexOutOfRangeException>(() => dictionary.GetTypeArgumentCustomModifiers(-1));
Symbols\ExtensionMethodTests.cs (3)
2699Assert.Throws<ArgumentNullException>(() => nonGenericExtension.ReduceExtensionMethod(receiverType: null, compilation: null!)); 2702Assert.Throws<ArgumentNullException>(() => genericExtension.ReduceExtensionMethod(receiverType: null, compilation: null!)); 2743Assert.Throws<InvalidOperationException>(() => methodSymbol.ThisParameter);
Symbols\FunctionPointerTypeSymbolTests.cs (10)
1539Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray.Create(RefKind.None))); 1540Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.Out, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty)); 1541Assert.Throws<ArgumentOutOfRangeException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: (SignatureCallingConvention)10)); 1542Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Default, callingConventionTypes: ImmutableArray.Create(cdeclType)!)); 1543Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.StdCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!)); 1544Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.FastCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!)); 1545Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.CDecl, callingConventionTypes: ImmutableArray.Create(cdeclType)!)); 1546Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.ThisCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!)); 1547Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Unmanaged, callingConventionTypes: ImmutableArray.Create(@string)!)); 1967Assert.Throws<ArgumentException>(() => mainComp.CreateFunctionPointerTypeSymbol(
Symbols\InterfaceImplementationTests.cs (1)
83Assert.Throws<ArgumentNullException>(() => @base.FindImplementationForInterfaceMember(null)); //not a method/property/event
Symbols\MockSymbolTests.cs (1)
100Assert.Throws<InvalidOperationException>(() => ne1.Compilation);
Symbols\Retargeting\RetargetCustomAttributes.cs (4)
309Assert.Throws<InvalidOperationException>(() => args[0].Value); 313Assert.Throws<InvalidOperationException>(() => args[1].Value); 319Assert.Throws<InvalidOperationException>(() => named["P"].Value); 323Assert.Throws<InvalidOperationException>(() => named["F"].Value);
Symbols\Source\FileModifierTests.cs (1)
4590var ex = Assert.Throws<ArgumentException>(() => CreateCompilation(new[] { tree, tree }));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (147)
LexicalAndXml\SyntaxTokenParserTests.cs (1)
21Assert.Throws<NullReferenceException>(() => parser.ParseNextToken());
Syntax\SeparatedSyntaxListTests.cs (22)
43Assert.Throws<NotSupportedException>(() => default(SeparatedSyntaxList<CSharpSyntaxNode>.Enumerator).GetHashCode()); 44Assert.Throws<NotSupportedException>(() => default(SeparatedSyntaxList<CSharpSyntaxNode>.Enumerator).Equals(default(SeparatedSyntaxList<CSharpSyntaxNode>.Enumerator))); 219Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, nodeD)); 220Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, nodeD)); 221Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { nodeD })); 222Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { nodeD })); 223Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1)); 224Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count + 1)); 225Assert.Throws<ArgumentOutOfRangeException>(() => list.Replace(nodeD, nodeE)); 226Assert.Throws<ArgumentOutOfRangeException>(() => list.ReplaceRange(nodeD, new[] { nodeE })); 227Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNode>)null)); 228Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNode>)null)); 229Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxNode>)null)); 267Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(0)); 268Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(1, nodeD)); 269Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, nodeD)); 270Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(1, new[] { nodeD })); 271Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { nodeD })); 272Assert.Throws<ArgumentNullException>(() => list.Add(null)); 273Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNode>)null)); 274Assert.Throws<ArgumentNullException>(() => list.Insert(0, null)); 275Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNode>)null));
Syntax\SyntaxFactoryTests.cs (4)
103Assert.Throws<ArgumentException>(() => SyntaxFactory.Token(SyntaxKind.NumericLiteralExpression)); 141Assert.Throws<ArgumentException>(() => SyntaxFactory.Token(default(SyntaxTriviaList), SyntaxKind.IdentifierToken, "text", "valueText", default(SyntaxTriviaList))); 142Assert.Throws<ArgumentException>(() => SyntaxFactory.Token(default(SyntaxTriviaList), SyntaxKind.CharacterLiteralToken, "text", "valueText", default(SyntaxTriviaList))); 143Assert.Throws<ArgumentException>(() => SyntaxFactory.Token(default(SyntaxTriviaList), SyntaxKind.NumericLiteralToken, "text", "valueText", default(SyntaxTriviaList)));
Syntax\SyntaxListTests.cs (24)
39Assert.Throws<NotSupportedException>(() => default(SyntaxList<CSharpSyntaxNode>.Enumerator).GetHashCode()); 40Assert.Throws<NotSupportedException>(() => default(SyntaxList<CSharpSyntaxNode>.Enumerator).Equals(default(SyntaxList<CSharpSyntaxNode>.Enumerator))); 171Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, nodeD)); 172Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, nodeD)); 173Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { nodeD })); 174Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { nodeD })); 175Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1)); 176Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count)); 177Assert.Throws<ArgumentException>(() => list.Replace(nodeD, nodeE)); 178Assert.Throws<ArgumentException>(() => list.ReplaceRange(nodeD, new[] { nodeE })); 179Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNode>)null)); 180Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNode>)null)); 181Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxNode>)null)); 219Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(0)); 220Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(1, nodeD)); 221Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, nodeD)); 222Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(1, new[] { nodeD })); 223Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { nodeD })); 224Assert.Throws<ArgumentException>(() => list.Replace(nodeD, nodeE)); 225Assert.Throws<ArgumentException>(() => list.ReplaceRange(nodeD, new[] { nodeE })); 226Assert.Throws<ArgumentNullException>(() => list.Add(null)); 227Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNode>)null)); 228Assert.Throws<ArgumentNullException>(() => list.Insert(0, null)); 229Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNode>)null));
Syntax\SyntaxNodeOrTokenListTests.cs (24)
33Assert.Throws<NotSupportedException>(() => default(SyntaxNodeOrTokenList.Enumerator).GetHashCode()); 34Assert.Throws<NotSupportedException>(() => default(SyntaxNodeOrTokenList.Enumerator).Equals(default(SyntaxNodeOrTokenList.Enumerator))); 158Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, tokenD)); 159Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, tokenD)); 160Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { tokenD })); 161Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { tokenD })); 162Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1)); 163Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count)); 164Assert.Throws<ArgumentOutOfRangeException>(() => list.Replace(tokenD, nameE)); 165Assert.Throws<ArgumentOutOfRangeException>(() => list.ReplaceRange(tokenD, new[] { nameE })); 166Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxNodeOrToken))); 167Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxNodeOrToken))); 168Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNodeOrToken>)null)); 169Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNodeOrToken>)null)); 170Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxNodeOrToken>)null)); 208Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(0)); 209Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(1, tokenD)); 210Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, tokenD)); 211Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(1, new[] { tokenD })); 212Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { tokenD })); 213Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxNodeOrToken))); 214Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxNodeOrToken))); 215Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxNodeOrToken>)null)); 216Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxNodeOrToken>)null));
Syntax\SyntaxNodeTests.cs (20)
751Assert.Throws<ArgumentOutOfRangeException>(() => classDecl2.FindNode(EOFSpan)); 761Assert.Throws<ArgumentOutOfRangeException>(() => classDecl.FindNode(nodeEndPositionSpan)); 765Assert.Throws<ArgumentOutOfRangeException>(() => root.FindNode(invalidSpan)); 767Assert.Throws<ArgumentOutOfRangeException>(() => root.FindNode(invalidSpan)); 769Assert.Throws<ArgumentOutOfRangeException>(() => classDecl2.FindNode(invalidSpan)); 771Assert.Throws<ArgumentOutOfRangeException>(() => classDecl2.FindNode(invalidSpan)); 773Assert.Throws<ArgumentOutOfRangeException>(() => classDecl.FindNode(root.FullSpan)); 2156Assert.Throws<InvalidOperationException>(() => ifstatement.ReplaceNode(then, new[] { stat1, stat2 })); 2159Assert.Throws<InvalidOperationException>(() => ifstatement.ReplaceNode(then, new StatementSyntax[] { })); 2196Assert.Throws<InvalidOperationException>(() => ifstatement.InsertNodesBefore(then, new[] { stat1, stat2 })); 2199Assert.Throws<InvalidOperationException>(() => ifstatement.InsertNodesAfter(then, new StatementSyntax[] { })); 2297Assert.Throws<InvalidOperationException>(() => cu.ReplaceToken(identifierC, new[] { identifierA, identifierB })); 2300Assert.Throws<InvalidOperationException>(() => cu.ReplaceToken(identifierC, new SyntaxToken[] { })); 2328Assert.Throws<InvalidOperationException>(() => cu.InsertTokensBefore(identifierC, new[] { identifierA, identifierB })); 2331Assert.Throws<InvalidOperationException>(() => cu.InsertTokensAfter(identifierC, new[] { identifierA, identifierB })); 3522Assert.Throws<ArgumentException>(() => SyntaxFactory.SeparatedList<TypeSyntax>(new SyntaxNodeOrToken[] { commaToken })); 3523Assert.Throws<ArgumentException>(() => SyntaxFactory.SeparatedList<TypeSyntax>(new SyntaxNodeOrToken[] { intType, commaToken, commaToken })); 3524Assert.Throws<ArgumentException>(() => SyntaxFactory.SeparatedList<TypeSyntax>(new SyntaxNodeOrToken[] { intType, intType })); 3711Assert.Throws<ArgumentNullException>(() => FirstUsingClause.SyntaxTree.GetChanges(BlankTree)); 3744Assert.Throws<ArgumentNullException>(() => FirstUsingClause.SyntaxTree.GetChangedSpans(BlankTree));
Syntax\SyntaxTests.cs (2)
33Assert.Throws<ArgumentNullException>(() => SyntaxFactory.IsCompleteSubmission(null)); 34Assert.Throws<ArgumentException>(() =>
Syntax\SyntaxTokenListTests.cs (26)
53Assert.Throws<NotSupportedException>(() => default(SyntaxTokenList.Enumerator).GetHashCode()); 54Assert.Throws<NotSupportedException>(() => default(SyntaxTokenList.Enumerator).Equals(default(SyntaxTokenList.Enumerator))); 55Assert.Throws<NotSupportedException>(() => default(SyntaxTokenList.Reversed.Enumerator).GetHashCode()); 56Assert.Throws<NotSupportedException>(() => default(SyntaxTokenList.Reversed.Enumerator).Equals(default(SyntaxTokenList.Reversed.Enumerator))); 180Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, tokenD)); 181Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, tokenD)); 182Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { tokenD })); 183Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { tokenD })); 184Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1)); 185Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count)); 186Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxToken))); 187Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxToken))); 188Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxToken>)null)); 189Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxToken>)null)); 190Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxToken>)null)); 228Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(0)); 229Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(1, tokenD)); 230Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, tokenD)); 231Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { tokenD })); 232Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { tokenD })); 233Assert.Throws<ArgumentOutOfRangeException>(() => list.Replace(tokenD, tokenE)); 234Assert.Throws<ArgumentOutOfRangeException>(() => list.ReplaceRange(tokenD, new[] { tokenE })); 235Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxToken))); 236Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxToken))); 237Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxToken>)null)); 238Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxToken>)null));
Syntax\SyntaxTriviaListTests.cs (22)
169Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, triviaD)); 170Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, triviaD)); 171Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { triviaD })); 172Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(list.Count + 1, new[] { triviaD })); 173Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1)); 174Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count)); 175Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxTrivia))); 176Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxTrivia))); 177Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxTrivia>)null)); 178Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxTrivia>)null)); 179Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxTrivia>)null)); 216Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(0)); 217Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(1, triviaD)); 218Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, triviaD)); 219Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(1, new[] { triviaD })); 220Assert.Throws<ArgumentOutOfRangeException>(() => list.InsertRange(-1, new[] { triviaD })); 221Assert.Throws<ArgumentOutOfRangeException>(() => list.Replace(triviaD, triviaE)); 222Assert.Throws<ArgumentOutOfRangeException>(() => list.ReplaceRange(triviaD, new[] { triviaE })); 223Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxTrivia))); 224Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxTrivia))); 225Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxTrivia>)null)); 226Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxTrivia>)null));
Syntax\TrackNodeTests.cs (2)
127Assert.Throws<InvalidOperationException>(() => replacedExpr.GetCurrentNode(originalA)); 184Assert.Throws<ArgumentException>(() => expr.TrackNodes(SyntaxFactory.IdentifierName("c")));
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (16)
Attributes\AttributeTests.cs (3)
39=> Assert.Throws<ArgumentNullException>(() => 45Assert.Throws<ArgumentNullException>(() => 47Assert.Throws<ArgumentNullException>(() =>
Debugging\DebugInformationReaderProviderTests.cs (4)
18Assert.Throws<ArgumentException>(() => DebugInformationReaderProvider.CreateFromStream(new TestStream(canRead: false, canSeek: true, canWrite: true))); 19Assert.Throws<ArgumentException>(() => DebugInformationReaderProvider.CreateFromStream(new TestStream(canRead: true, canSeek: false, canWrite: true))); 20Assert.Throws<ArgumentNullException>(() => DebugInformationReaderProvider.CreateFromStream(null)); 21Assert.Throws<ArgumentNullException>(() => DebugInformationReaderProvider.CreateFromMetadataReader(null));
Emit\CompilationOutputFilesTests.cs (2)
22Assert.Throws<ArgumentException>(() => new CompilationOutputFiles(@"a.dll")); 23Assert.Throws<ArgumentException>(() => new CompilationOutputFiles(@"\a.dll", @"a.dll"));
Emit\CompilationOutputsTests.cs (6)
43Assert.Throws<InvalidOperationException>(() => outputs.OpenAssemblyMetadata(prefetch: false)); 44Assert.Throws<InvalidOperationException>(() => outputs.OpenPdb()); 88Assert.Throws<ObjectDisposedException>(() => currentPEStream!.Length); 92Assert.Throws<ObjectDisposedException>(() => currentPdbStream!.Length); 103Assert.Throws<ObjectDisposedException>(() => currentPEStream.Length); 108Assert.Throws<ObjectDisposedException>(() => currentPEStream.Length);
Extensions\SourceTextContainerExtensionsTests.cs (1)
20Assert.Throws<ArgumentException>(() => Microsoft.CodeAnalysis.Text.Extensions.GetTextBuffer(containerMock.Object));
Microsoft.CodeAnalysis.Features.UnitTests (5)
EditAndContinue\EditAndContinueMethodDebugInfoReaderTests.cs (5)
35Assert.Throws<ArgumentNullException>(() => EditAndContinueMethodDebugInfoReader.Create((ISymUnmanagedReader5)null)); 36Assert.Throws<ArgumentNullException>(() => EditAndContinueMethodDebugInfoReader.Create((MetadataReader)null)); 37Assert.Throws<ArgumentNullException>(() => EditAndContinueMethodDebugInfoReader.Create(null, 1)); 40Assert.Throws<ArgumentOutOfRangeException>(() => EditAndContinueMethodDebugInfoReader.Create(mockSymReader, 0)); 41Assert.Throws<ArgumentOutOfRangeException>(() => EditAndContinueMethodDebugInfoReader.Create(mockSymReader, -1));
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (2)
ProtocolConversionsTests.cs (2)
255Assert.Throws<ArgumentException>(() => ProtocolConversions.RangeToTextSpan(range, sourceText)); 266Assert.Throws<ArgumentException>(() => ProtocolConversions.RangeToTextSpan(range, sourceText));
Microsoft.CodeAnalysis.Scripting.Desktop.UnitTests (16)
MetadataShadowCopyProviderTests.cs (16)
56Assert.Throws<ArgumentNullException>(() => _provider.NeedsShadowCopy(null)); 57Assert.Throws<ArgumentException>(() => _provider.NeedsShadowCopy("c:goo.dll")); 58Assert.Throws<ArgumentException>(() => _provider.NeedsShadowCopy("bar.dll")); 59Assert.Throws<ArgumentException>(() => _provider.NeedsShadowCopy(@"\bar.dll")); 60Assert.Throws<ArgumentException>(() => _provider.NeedsShadowCopy(@"../bar.dll")); 68Assert.Throws<ArgumentOutOfRangeException>(() => _provider.GetMetadataShadowCopy(IsRunningOnMono ? "/goo.dll" : @"c:\goo.dll", (MetadataImageKind)Byte.MaxValue)); 69Assert.Throws<ArgumentNullException>(() => _provider.GetMetadataShadowCopy(null, MetadataImageKind.Assembly)); 70Assert.Throws<ArgumentException>(() => _provider.GetMetadataShadowCopy("c:goo.dll", MetadataImageKind.Assembly)); 71Assert.Throws<ArgumentException>(() => _provider.GetMetadataShadowCopy("bar.dll", MetadataImageKind.Assembly)); 72Assert.Throws<ArgumentException>(() => _provider.GetMetadataShadowCopy(@"\bar.dll", MetadataImageKind.Assembly)); 73Assert.Throws<ArgumentException>(() => _provider.GetMetadataShadowCopy(@"../bar.dll", MetadataImageKind.Assembly)); 75Assert.Throws<ArgumentOutOfRangeException>(() => _provider.GetMetadata(IsRunningOnMono ? "/goo.dll" : @"c:\goo.dll", (MetadataImageKind)Byte.MaxValue)); 76Assert.Throws<ArgumentNullException>(() => _provider.GetMetadata(null, MetadataImageKind.Assembly)); 77Assert.Throws<ArgumentException>(() => _provider.GetMetadata("c:goo.dll", MetadataImageKind.Assembly)); 186Assert.Throws<BadImageFormatException>(() => _provider.GetMetadata(f0, MetadataImageKind.Assembly)); 189Assert.Throws<FileNotFoundException>(() => _provider.GetMetadata(f1, MetadataImageKind.Assembly));
Microsoft.CodeAnalysis.Test.Utilities (4)
Compilation\TestOperationVisitor.cs (4)
97Assert.Throws<InvalidOperationException>(() => operation.ChildOperations.First()); 98Assert.Throws<InvalidOperationException>(() => operation.ChildOperations.Last()); 853Assert.Throws<ArgumentException>(() => VisualBasic.VisualBasicExtensions.GetConversion(operation)); 857Assert.Throws<ArgumentException>(() => CSharp.CSharpExtensions.GetConversion(operation));
Microsoft.CodeAnalysis.UnitTests (417)
AnalyzerAssemblyLoaderTests.cs (4)
343Assert.Throws<ArgumentException>(() => loader.LoadFromPath(analyzerPath)); 355Assert.Throws<ArgumentException>(() => loader.LoadFromPath(testFixture.Beta)); 378var exception = Assert.Throws<TargetInvocationException>( 880Assert.Throws<ArgumentException>(() => loader.GetResolvedAnalyzerPath(testFixture.Delta2));
Analyzers\AnalyzerConfigTests.cs (6)
1481Assert.Throws<ArgumentException>(() => Parse("", "relativeDir/file")); 1482Assert.Throws<ArgumentException>(() => Parse("", "/")); 1483Assert.Throws<ArgumentException>(() => Parse("", "/subdir/")); 1489Assert.Throws<ArgumentException>(() => Parse("", "Z:")); 1490Assert.Throws<ArgumentException>(() => Parse("", "Z:\\")); 1491Assert.Throws<ArgumentException>(() => Parse("", ":\\.editorconfig"));
Collections\BitArrayTests.cs (3)
303Assert.Throws<IndexOutOfRangeException>(() => _ = b[index]); 317Assert.Throws<IndexOutOfRangeException>(() => b[index] = false); 320Assert.Throws<IndexOutOfRangeException>(() => b[index] = true);
Collections\Extensions\ImmutableArrayExtensionsTests.cs (21)
28Assert.Throws<ArgumentNullException>(() => ImmutableArray.CreateRange<int>((IEnumerable<int>)null)); 56Assert.Throws<NullReferenceException>(() => nullOrEmpty.IsEmpty); 142Assert.Throws<NullReferenceException>(() => default(ImmutableArray<int>).Single()); 143Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>().Single()); 145Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>(1, 2).Single()); 149Assert.Throws<NullReferenceException>(() => default(ImmutableArray<int>).Single(isOdd)); 150Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>().Single(isOdd)); 152Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>(1, 2, 3).Single(isOdd)); 158Assert.Throws<NullReferenceException>(() => default(ImmutableArray<int>).Single((_, _) => true, 1)); 159Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>().Single((x, a) => x == a, 1)); 161Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>(1, 1).Single((x, a) => x == a, 1)); 163Assert.Throws<NullReferenceException>(() => default(ImmutableArray<int>).Single((x, a) => x % a == 1, 2)); 164Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>().Single((x, a) => x % a == 1, 2)); 166Assert.Throws<InvalidOperationException>(() => ImmutableArray.Create<int>(1, 2, 3).Single((x, a) => x % a == 1, 2)); 232Assert.Throws<InvalidOperationException>(() => roa.Last()); 234Assert.Throws<InvalidOperationException>(() => roa.Last(i => i < 1)); 256Assert.Throws<InvalidOperationException>(() => roa.SingleOrDefault()); 313Assert.Throws<KeyNotFoundException>(() => dict["One"]); 319Assert.Throws<KeyNotFoundException>(() => dict[""]); 325Assert.Throws<KeyNotFoundException>(() => dict["THREE"]); 331Assert.Throws<KeyNotFoundException>(() => dict["four"]);
Collections\HashSet\ISet_Generic_Tests`1.cs (7)
315Assert.Throws<ArgumentNullException>(() => set.IsProperSubsetOf(null!)); 316Assert.Throws<ArgumentNullException>(() => set.IsProperSupersetOf(null!)); 317Assert.Throws<ArgumentNullException>(() => set.IsSubsetOf(null!)); 318Assert.Throws<ArgumentNullException>(() => set.IsSupersetOf(null!)); 319Assert.Throws<ArgumentNullException>(() => set.Overlaps(null!)); 320Assert.Throws<ArgumentNullException>(() => set.SetEquals(null!)); 330Assert.Throws<NotSupportedException>(() => set.Add(CreateT(0)));
Collections\HashSet\SegmentedHashSet_Generic_Tests`1.cs (3)
121Assert.Throws<ArgumentNullException>(() => new SegmentedHashSet<T>((IEnumerable<T>)null!)); 122Assert.Throws<ArgumentNullException>(() => new SegmentedHashSet<T>((IEnumerable<T>)null!, EqualityComparer<T>.Default)); 179Assert.Throws<ArgumentNullException>(() => set.RemoveWhere(null!));
Collections\IdentifierCollectionTests.cs (1)
82Assert.Throws<NotSupportedException>(() => collection.Remove("x"));
Collections\ImmutableDictionaryBuilderTestBase.cs (1)
74Assert.Throws<KeyNotFoundException>(() => builder["foo"]);
Collections\ImmutableDictionaryTestBase.cs (6)
107Assert.Throws<KeyNotFoundException>(() => this.Empty<int, int>()[3]); 132Assert.Throws<NotSupportedException>(() => dictionary.Remove(new KeyValuePair<string, int>())); 158Assert.Throws<NotSupportedException>(() => dictionary.Remove("a")); 159Assert.Throws<NotSupportedException>(() => dictionary["a"] = 2); 160Assert.Throws<KeyNotFoundException>(() => dictionary["a"]); 170Assert.Throws<NotSupportedException>(() => dictionary["a"] = 2);
Collections\ImmutableDictionaryTestBase.nonnetstandard.cs (2)
50Assert.Throws<NotSupportedException>(() => map.Remove(5)); 64Assert.Throws<NotSupportedException>(() => map[3] = 5);
Collections\ImmutableSegmentedDictionaryBuilderTest.cs (2)
113Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 262TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object?)null));
Collections\ImmutableSegmentedDictionaryTest.cs (2)
262TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object?)null)); 299var exception = Assert.Throws<KeyNotFoundException>(() => map[missingKey]);
Collections\ImmutableSegmentedHashSetBuilderTest.cs (1)
92Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext());
Collections\ImmutableSegmentedHashSetTest.cs (1)
198TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object?)null));
Collections\ImmutableSegmentedListBuilderTest.cs (3)
107Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 372TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object)null!)); 398Assert.Throws<ArgumentOutOfRangeException>(() => builder.ItemRef(5));
Collections\ImmutableSegmentedListTest.cs (9)
623Assert.Throws<ArgumentException>(() => list.RemoveRange(4, 0)); 624Assert.Throws<ArgumentException>(() => list.RemoveRange(0, 4)); 625Assert.Throws<ArgumentException>(() => list.RemoveRange(2, 2)); 748Assert.Throws<NotSupportedException>(() => list.Add(1)); 753Assert.Throws<NotSupportedException>(() => list[0] = 1); 764Assert.Throws<NotSupportedException>(() => list.Remove(1)); 766Assert.Throws<NotSupportedException>(() => list[0] = 1); 787TargetInvocationException tie = Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(proxyType, (object?)null)); 832Assert.Throws<ArgumentOutOfRangeException>(() => list.ItemRef(5));
Collections\ImmutableSetTest.cs (2)
172Assert.Throws<NotSupportedException>(() => set.Add(0)); 185Assert.Throws<NotSupportedException>(() => set.Remove(1));
Collections\IndexOfTests.cs (17)
33Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(emptyCollection, 100, 1, 1, EqualityComparer<int>.Default)); 34Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(emptyCollection, 100, -1, 1, EqualityComparer<int>.Default)); 35Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(collection1256, 100, 1, 20, EqualityComparer<int>.Default)); 36Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(collection1256, 100, 1, -1, EqualityComparer<int>.Default)); 37Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(emptyCollection, 100, 1, 1, new CustomComparer(50))); 38Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(emptyCollection, 100, -1, 1, new CustomComparer(50))); 39Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(collection1256, 100, 1, 20, new CustomComparer(1))); 40Assert.Throws<ArgumentOutOfRangeException>(() => indexOfItemIndexCountEQ(collection1256, 100, 1, -1, new CustomComparer(1))); 102Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(emptyCollection, 100, 1, 1, EqualityComparer<int>.Default)); 103Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(emptyCollection, 100, -1, 1, EqualityComparer<int>.Default)); 104Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(collection1256, 100, 1, 20, EqualityComparer<int>.Default)); 105Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(collection1256, 100, 1, -1, EqualityComparer<int>.Default)); 106Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(emptyCollection, 100, 1, 1, new CustomComparer(50))); 107Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(emptyCollection, 100, -1, 1, new CustomComparer(50))); 108Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(collection1256, 100, 1, 20, new CustomComparer(1))); 109Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndexCountEQ(collection1256, 100, 1, -1, new CustomComparer(1))); 110Assert.Throws<ArgumentOutOfRangeException>(() => lastIndexOfItemIndex(collection1256, 2, 5));
Collections\List\ICollection.Generic.Tests.cs (4)
456Assert.Throws<ArgumentException>(() => collection.Contains(invalidValue)) 560Assert.Throws<NotSupportedException>(() => collection.Remove(CreateT(34543))); 677Assert.Throws<ArgumentException>(() => collection.Remove(value)); 690Assert.Throws<ArgumentNullException>(() => collection.Remove(default(T)!));
Collections\List\ICollection.NonGeneric.Tests.cs (1)
154Assert.Throws<NotSupportedException>(() => collection.SyncRoot);
Collections\List\IEnumerable.Generic.Tests.cs (8)
186Assert.Throws<InvalidOperationException>(() => enumerator.Current); 284Assert.Throws<InvalidOperationException>(() => enumerator.Current); 403Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 449Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 493Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 623Assert.Throws<InvalidOperationException>(() => enumerator.Current); 639Assert.Throws<InvalidOperationException>(() => enumerator.Current); 658Assert.Throws<InvalidOperationException>(() => enumerator.Current);
Collections\List\IEnumerable.NonGeneric.Tests.cs (6)
203Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 229Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 252Assert.Throws<InvalidOperationException>(() => enumerator.MoveNext()); 316Assert.Throws<InvalidOperationException>(() => enumerator.Current); 330Assert.Throws<InvalidOperationException>(() => enumerator.Current); 347Assert.Throws<InvalidOperationException>(() => enumerator.Current);
Collections\List\IList.Generic.Tests.cs (8)
177Assert.Throws<NotSupportedException>(() => list[count / 2] = CreateT(321432)); 209Assert.Throws<ArgumentNullException>(() => list[0] = default(T)!); 244Assert.Throws<ArgumentNullException>(() => list[lastIndex] = default(T)!); 274Assert.Throws<ArgumentException>(() => list[count / 2] = value); 302Assert.Throws<ArgumentNullException>(() => list.IndexOf(default(T)!)); 372Assert.Throws<ArgumentException>(() => list.IndexOf(value)); 628Assert.Throws<InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail 644Assert.Throws<InvalidOperationException>(() => enumerator.Current); // enumerator.Current should fail
Collections\List\IList.NonGeneric.Tests.cs (7)
281Assert.Throws<NotSupportedException>(() => list[count / 2] = CreateT(321432)); 364Assert.Throws<ArgumentException>(() => list[count / 2] = value); 511Assert.Throws<NotSupportedException>(() => collection.Add(CreateT(0))); 620Assert.Throws<ArgumentException>(() => collection.Contains(invalidValue)) 700Assert.Throws<ArgumentException>(() => list.IndexOf(value)); 1097Assert.Throws<InvalidOperationException>(() => enumerator.Current); // Enumerator.Current should fail 1112Assert.Throws<InvalidOperationException>(() => enumerator.Current); // Enumerator.Current should fail
Collections\List\SegmentedList.Generic.Tests.BinarySearch.cs (2)
70Assert.Throws<ArgumentOutOfRangeException>(() => list.BinarySearch(-1, count, element, GetIComparer())); //"ArgumentOutOfRangeException should be thrown on negative index." 71Assert.Throws<ArgumentOutOfRangeException>(() => list.BinarySearch(0, -1, element, GetIComparer())); //"ArgumentOutOfRangeException should be thrown on negative count."
Collections\List\SegmentedList.Generic.Tests.Capacity.cs (1)
44Assert.Throws<ArgumentOutOfRangeException>(() => list.Capacity = initialCapacity - 1);
Collections\List\SegmentedList.Generic.Tests.Constructor.cs (1)
53Assert.Throws<ArgumentOutOfRangeException>(() => new SegmentedList<T>(capacity));
Collections\List\SegmentedList.Generic.Tests.Find.cs (39)
35Assert.Throws<ArgumentNullException>(() => list.Find(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 38Assert.Throws<ArgumentNullException>(() => list.FindLast(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 41Assert.Throws<ArgumentNullException>(() => list.FindLastIndex(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 44Assert.Throws<ArgumentNullException>(() => list.FindAll(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 56Assert.Throws<ArgumentNullException>(() => list.FindLastIndex(0, null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 62Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(int.MinValue, predicate)); //"Err_948ahid Expected index=Int32.MinValue to throw ArgumentOutOfRangeException" 67Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(-1, predicate)); //"Err_328ahuaw Expected index=-1 to throw ArgumentOutOfRangeException" 71Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count + 1, predicate)); //"Err_488ajdi Expected index=list.Count + 1 to throw ArgumentOutOfRangeException" 74Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count, predicate)); //"Err_9689ajis Expected index=list.Count to throw ArgumentOutOfRangeException" 77Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(int.MaxValue, predicate)); //"Err_238ajwisa Expected index=Int32.MaxValue to throw ArgumentOutOfRangeException" 89Assert.Throws<ArgumentNullException>(() => list.FindIndex(0, 0, null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 95Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(int.MinValue, 0, predicate)); //"Err_948ahid Expected index=Int32.MinValue to throw ArgumentOutOfRangeException" 98Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(-1, 0, predicate)); //"Err_328ahuaw Expected index=-1 to throw ArgumentOutOfRangeException" 101Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(list.Count + 1, 0, predicate)); //"Err_488ajdi Expected index=list.Count + 1 to throw ArgumentOutOfRangeException" 104Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(list.Count, 1, predicate)); //"Err_9689ajis Expected index=list.Count to throw ArgumentOutOfRangeException" 107Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(int.MaxValue, 0, predicate)); //"Err_238ajwisa Expected index=Int32.MaxValue to throw ArgumentOutOfRangeException" 113Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(0, int.MinValue, predicate)); //Err_948ahid Expected count=Int32.MinValue to throw ArgumentOutOfRangeException" 116Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(0, -1, predicate)); //"Err_328ahuaw Expected count=-1 to throw ArgumentOutOfRangeException" 119Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(0, list.Count + 1, predicate)); //"Err_488ajdi Expected count=list.Count + 1 to throw ArgumentOutOfRangeException" 122Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(0, int.MaxValue, predicate)); //"Err_238ajwisa Expected count=Int32.MaxValue to throw ArgumentOutOfRangeException" 130Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(1, count, predicate)); //"Err_018188avbiw Expected index=1 count=list.Length to throw ArgumentOutOfRangeException" 133Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(0, count + 1, predicate)); //"Err_6848ajiodxbz Expected index=0 count=list.Length + 1 to throw ArgumentOutOfRangeException" 146Assert.Throws<ArgumentNullException>(() => list.FindLastIndex(0, 0, null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 152Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(int.MinValue, 0, predicate)); //Err_948ahid Expected index=Int32.MinValue to throw ArgumentOutOfRangeException" 157Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(-1, 0, predicate)); //"Err_328ahuaw Expected index=-1 to throw ArgumentOutOfRangeException" 161Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count + 1, 0, predicate)); //"Err_488ajdi Expected index=list.Count + 1 to throw ArgumentOutOfRangeException" 164Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count, 1, predicate)); //"Err_9689ajis Expected index=list.Count to throw ArgumentOutOfRangeException" 167Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(int.MaxValue, 0, predicate)); //"Err_238ajwisa Expected index=Int32.MaxValue to throw ArgumentOutOfRangeException" 173Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count - 1, int.MinValue, predicate)); //"Err_948ahid Expected count=Int32.MinValue to throw ArgumentOutOfRangeException" 176Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count - 1, -1, predicate)); //"Err_328ahuaw Expected count=-1 to throw ArgumentOutOfRangeException" 179Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count - 1, list.Count + 1, predicate)); //"Err_488ajdi Expected count=list.Count + 1 to throw ArgumentOutOfRangeException" 182Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(list.Count - 1, int.MaxValue, predicate)); //"Err_238ajwisa Expected count=Int32.MaxValue to throw ArgumentOutOfRangeException" 190Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(count - 2, count, predicate)); //"Err_018188avbiw Expected index=1 count=list.Length to throw ArgumentOutOfRangeException" 193Assert.Throws<ArgumentOutOfRangeException>(() => list.FindLastIndex(count - 1, count + 1, predicate)); //"Err_6848ajiodxbz Expected index=0 count=list.Length + 1 to throw ArgumentOutOfRangeException" 206Assert.Throws<ArgumentNullException>(() => list.FindIndex(0, null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 212Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(int.MinValue, predicate)); //"Err_948ahid Expected index=Int32.MinValue to throw ArgumentOutOfRangeException" 215Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(-1, predicate)); //"Err_328ahuaw Expected index=-1 to throw ArgumentOutOfRangeException" 218Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(list.Count + 1, predicate)); //"Err_488ajdi Expected index=list.Count + 1 to throw ArgumentOutOfRangeException" 221Assert.Throws<ArgumentOutOfRangeException>(() => list.FindIndex(int.MaxValue, predicate)); //"Err_238ajwisa Expected index=Int32.MaxValue to throw ArgumentOutOfRangeException"
Collections\List\SegmentedList.Generic.Tests.IndexOf.cs (20)
196Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 1)); //"Expect ArgumentOutOfRangeException for index greater than length of list.." 197Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 10)); //"Expect ArgumentOutOfRangeException for index greater than length of list.." 198Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, -1)); //"Expect ArgumentOutOfRangeException for negative index." 199Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, int.MinValue)); //"Expect ArgumentOutOfRangeException for negative index." 208Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, count, 1)); //"ArgumentOutOfRangeException expected on index larger than array." 209Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, count + 1, 1)); //"ArgumentOutOfRangeException expected on index larger than array." 210Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, count + 1)); //"ArgumentOutOfRangeException expected on count larger than array." 211Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, count / 2, count / 2 + 2)); //"ArgumentOutOfRangeException expected.." 212Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, count + 1)); //"ArgumentOutOfRangeException expected on count larger than array." 213Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, 0, -1)); //"ArgumentOutOfRangeException expected on negative count." 214Assert.Throws<ArgumentOutOfRangeException>(() => list.IndexOf(element, -1, 1)); //"ArgumentOutOfRangeException expected on negative index." 223Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count)); //"ArgumentOutOfRangeException expected." 227Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1)); 239Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, count + 1)); //"Expected ArgumentOutOfRangeException." 240Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count / 2, count / 2 + 2)); //"Expected ArgumentOutOfRangeException." 241Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, count + 1)); //"Expected ArgumentOutOfRangeException." 242Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, 0, -1)); //"Expected ArgumentOutOfRangeException." 243Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1, count)); //"Expected ArgumentOutOfRangeException." 244Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, -1, 1)); //"Expected ArgumentOutOfRangeException." Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count, 0)); //"Expected ArgumentOutOfRangeException." 245Assert.Throws<ArgumentOutOfRangeException>(() => list.LastIndexOf(element, count, 1)); //"Expected ArgumentOutOfRangeException."
Collections\List\SegmentedList.Generic.Tests.Misc.cs (3)
332Assert.Throws<ArgumentOutOfRangeException>(() => 360Assert.Throws<ArgumentNullException>(() => list.Exists(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException" 700Assert.Throws<ArgumentNullException>(() => list.TrueForAll(null!)); //"Err_858ahia Expected null match to throw ArgumentNullException"
Collections\RopeTests.cs (4)
122Assert.Throws<InvalidOperationException>(() => r.ToString(-1)); 141Assert.Throws<OverflowException>(() => Rope.Concat(all, waferThinMint)); 142Assert.Throws<OverflowException>(() => Rope.Concat(waferThinMint, all)); 143Assert.Throws<OverflowException>(() => Rope.Concat(all, all));
Collections\SegmentedArrayTests.cs (16)
52Assert.Throws<NullReferenceException>(() => data[0]); 53Assert.Throws<NullReferenceException>(() => ((IReadOnlyList<IntPtr>)data)[0]); 54Assert.Throws<NullReferenceException>(() => ((IList<IntPtr>)data)[0]); 55Assert.Throws<NullReferenceException>(() => ((IList<IntPtr>)data)[0] = IntPtr.Zero); 56Assert.Throws<NullReferenceException>(() => ((IList)data)[0]); 57Assert.Throws<NullReferenceException>(() => ((IList)data)[0] = IntPtr.Zero); 63Assert.Throws<NullReferenceException>(() => data.Clone()); 68Assert.Throws<NullReferenceException>(() => enumerator1.MoveNext()); 71Assert.Throws<NullReferenceException>(() => enumerator1.MoveNext()); 74Assert.Throws<NullReferenceException>(() => enumerator1.MoveNext()); 76Assert.Throws<NotSupportedException>(() => ((IList)data).Add(IntPtr.Zero)); 82Assert.Throws<NotSupportedException>(() => ((ICollection<IntPtr>)data).Remove(IntPtr.Zero)); 87Assert.Throws<NullReferenceException>(() => ((IList)data).Contains(IntPtr.Zero)); 88Assert.Throws<NullReferenceException>(() => ((ICollection<IntPtr>)data).Contains(IntPtr.Zero)); 89Assert.Throws<NullReferenceException>(() => ((IList)data).IndexOf(IntPtr.Zero)); 90Assert.Throws<NullReferenceException>(() => ((IList<IntPtr>)data).IndexOf(IntPtr.Zero));
Collections\SegmentedCollectionsMarshalTests.cs (6)
68Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value = 9); 124Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value = 9); 203Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value); 250Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value = 9); 304Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value = 9); 358Assert.Throws<NullReferenceException>(() => SegmentedCollectionsMarshal.GetValueRefOrNullRef(dict, 3).Value = 9);
Collections\TemporaryArrayTests.cs (7)
23Assert.Throws<IndexOutOfRangeException>(() => TemporaryArray<int>.Empty[-1]); 30Assert.Throws<IndexOutOfRangeException>(() => TemporaryArray<int>.Empty[0]); 69Assert.Throws<IndexOutOfRangeException>(() => array[i]); 70Assert.Throws<IndexOutOfRangeException>(() => array.AsRef()[i] = 1); 281Assert.Throws<IndexOutOfRangeException>(() => array.RemoveLast()); 320Assert.Throws<InvalidOperationException>(() => array.SingleOrDefault(p => p > 1)); 321Assert.Throws<InvalidOperationException>(() => array.SingleOrDefault((p, arg) => p > arg, arg: 1));
Diagnostics\CompilationWithAnalyzersTests.cs (3)
31Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(default(ImmutableArray<Diagnostic>), c)); 32Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(null, c)); 33Assert.Throws<ArgumentNullException>(() => CompilationWithAnalyzers.GetEffectiveDiagnostics(ds, null));
Diagnostics\OperationTests.cs (18)
33Assert.Throws<InvalidOperationException>(() => dynamicExpression.GetArgumentName(0)); 34Assert.Throws<InvalidOperationException>(() => dynamicExpression.GetArgumentRefKind(0)); 63Assert.Throws<ArgumentOutOfRangeException>(() => dynamicExpression.GetArgumentName(-1)); 64Assert.Throws<ArgumentOutOfRangeException>(() => dynamicExpression.GetArgumentRefKind(-1)); 67Assert.Throws<ArgumentOutOfRangeException>(() => dynamicExpression.GetArgumentName(100)); 68Assert.Throws<ArgumentOutOfRangeException>(() => dynamicExpression.GetArgumentRefKind(100)); 77Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentName(0)); 78Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentRefKind(0)); 92Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentName(0)); 93Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentRefKind(0)); 107Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentName(0)); 108Assert.Throws<ArgumentNullException>(() => nullDynamicExpression.GetArgumentRefKind(0)); 120Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IBlockOperation)null)); 121Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IFieldInitializerOperation)null)); 122Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IPropertyInitializerOperation)null)); 123Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IParameterInitializerOperation)null)); 124Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IConstructorBodyOperation)null)); 125Assert.Throws<ArgumentNullException>(() => ControlFlowGraph.Create((IMethodBodyOperation)null));
EmbeddedTextTests.cs (4)
60Assert.Throws<IOException>(() => EmbeddedText.FromStream("path", new HugeStream())); 61Assert.Throws<EndOfStreamException>(() => EmbeddedText.FromStream("path", new TruncatingStream(10))); 62Assert.Throws<EndOfStreamException>(() => EmbeddedText.FromStream("path", new TruncatingStream(1000))); 63Assert.Throws<IOException>(() => EmbeddedText.FromStream("path", new ReadFailsStream()));
Emit\CustomDebugInfoTests.cs (13)
28Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(new byte[0], CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 29Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(new byte[] { 1 }, CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 30Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(new byte[] { 1, 2 }, CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 51Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(cdi, CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 61Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(cdi, CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 80Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.TryGetCustomDebugInfoRecord(cdi, CustomDebugInfoKind.EditAndContinueLocalSlotMap)); 154var e = Assert.Throws<InvalidDataException>(() => EditAndContinueMethodDebugInformation.Create(ImmutableArray.Create(new byte[] { 0x01, 0x68, 0xff }), ImmutableArray<byte>.Empty)); 157e = Assert.Throws<InvalidDataException>(() => EditAndContinueMethodDebugInformation.Create(ImmutableArray.Create(new byte[] { 0x01, 0x68, 0xff, 0xff, 0xff, 0xff }), ImmutableArray<byte>.Empty)); 160e = Assert.Throws<InvalidDataException>(() => EditAndContinueMethodDebugInformation.Create(ImmutableArray.Create(new byte[] { 0xff, 0xff, 0xff, 0xff }), ImmutableArray<byte>.Empty)); 171e = Assert.Throws<InvalidDataException>(() => EditAndContinueMethodDebugInformation.Create(ImmutableArray.Create(largeData), ImmutableArray<byte>.Empty)); 337Assert.Throws<InvalidDataException>(() => EditAndContinueMethodDebugInformation.Create( 725Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.GetCustomDebugInfoRecords(bytes).ToArray()); 751Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.GetCustomDebugInfoRecords(bytes).ToArray());
Emit\EmitBaselineTests.cs (4)
33Assert.Throws<ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(null, peModule, debugInfoProvider, localSigProvider, true)); 34Assert.Throws<ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(compilation, null, debugInfoProvider, localSigProvider, true)); 35Assert.Throws<ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(compilation, peModule, null, localSigProvider, true)); 36Assert.Throws<ArgumentNullException>(() => EmitBaseline.CreateInitialBaseline(compilation, mdModule, debugInfoProvider, null, true));
InternalUtilities\OneOrManyTests.cs (5)
214Assert.Throws<IndexOutOfRangeException>(() => single[1]); 215Assert.Throws<IndexOutOfRangeException>(() => single[-1]); 216Assert.Throws<IndexOutOfRangeException>(() => quad[5]); 217Assert.Throws<IndexOutOfRangeException>(() => quad[-1]); 218Assert.Throws<ArgumentNullException>(() => OneOrMany.Create(default(ImmutableArray<int>)));
InternalUtilities\SpecializedCollectionsTests.cs (2)
41Assert.Throws<NotSupportedException>(() => emptySet.Remove(0)); 59Assert.Throws<NotSupportedException>(() => emptySet.Add(0));
InternalUtilities\StreamExtensionsTests.cs (4)
49Assert.Throws<IOException>(() => stream.TryReadAll(null, 0, 1)); 60Assert.Throws<ArgumentException>(() => stream.TryReadAll(buffer, 0, 100)); 84Assert.Throws<IOException>(() => stream.TryReadAll(destArray, 0, sourceArray.Length)); 109Assert.Throws<IOException>(() => stream.TryReadAll(destArray, 0, sourceArray.Length));
InternalUtilities\WeakListTests.cs (2)
323Assert.Throws<ArgumentOutOfRangeException>(() => list.GetWeakReference(-1)); 324Assert.Throws<ArgumentOutOfRangeException>(() => list.GetWeakReference(0));
IsSymbolAccessibleWithinTests.cs (8)
34Assert.Throws<ArgumentException>(() => csc.IsSymbolAccessibleWithin(Av, Av)); 35Assert.Throws<ArgumentException>(() => csc.IsSymbolAccessibleWithin(Av, Ac)); 36Assert.Throws<ArgumentException>(() => csc.IsSymbolAccessibleWithin(Ac, Av)); 37Assert.Throws<ArgumentException>(() => csc.IsSymbolAccessibleWithin(Ac, Ac, Av)); 39Assert.Throws<ArgumentException>(() => vbc.IsSymbolAccessibleWithin(Ac, Ac)); 40Assert.Throws<ArgumentException>(() => vbc.IsSymbolAccessibleWithin(Ac, Av)); 41Assert.Throws<ArgumentException>(() => vbc.IsSymbolAccessibleWithin(Av, Ac)); 42Assert.Throws<ArgumentException>(() => vbc.IsSymbolAccessibleWithin(Av, Av, Ac));
MetadataReferences\AssemblyIdentityDisplayNameTests.cs (1)
367Assert.Throws<ArgumentNullException>(() => AssemblyIdentity.TryParseDisplayName(null, out id));
MetadataReferences\AssemblyIdentityTests.cs (10)
223Assert.Throws<ArgumentException>(() => new AssemblyIdentity("xx\0xx")); 224Assert.Throws<ArgumentException>(() => new AssemblyIdentity("")); 225Assert.Throws<ArgumentException>(() => new AssemblyIdentity(null)); 227Assert.Throws<ArgumentException>( 230Assert.Throws<ArgumentException>( 244Assert.Throws<ArgumentOutOfRangeException>(() => new AssemblyIdentity("Goo", v)); 247Assert.Throws<ArgumentOutOfRangeException>(() => new AssemblyIdentity("Goo", contentType: (AssemblyContentType)(-1))); 248Assert.Throws<ArgumentOutOfRangeException>(() => new AssemblyIdentity("Goo", contentType: (AssemblyContentType)int.MaxValue)); 250Assert.Throws<ArgumentException>(() => 359Assert.Throws<CultureNotFoundException>(() => ai.ToAssemblyName());
MetadataReferences\AssemblyMetadataTests.cs (22)
20Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.CreateFromImage(default(ImmutableArray<byte>))); 23Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.CreateFromImage(enumerableImage)); 26Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.CreateFromImage(arrayImage)); 28Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.Create((ModuleMetadata)null)); 29Assert.Throws<ArgumentException>(() => AssemblyMetadata.Create(default(ImmutableArray<ModuleMetadata>))); 30Assert.Throws<ArgumentException>(() => AssemblyMetadata.Create(ImmutableArray.Create<ModuleMetadata>())); 36Assert.Throws<ArgumentException>(() => AssemblyMetadata.Create(m1, m2.Copy(), m3)); 37Assert.Throws<ArgumentException>(() => AssemblyMetadata.Create(new List<ModuleMetadata>(new ModuleMetadata[] { m1.Copy(), m2.Copy(), m3.Copy() }))); 38Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.Create(ImmutableArray.Create(m1, m2, null))); 39Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.Create(ImmutableArray.Create((ModuleMetadata)null))); 41Assert.Throws<ArgumentNullException>(() => AssemblyMetadata.CreateFromFile((string)null)); 82Assert.Throws<ObjectDisposedException>(() => m1.Module); 83Assert.Throws<ObjectDisposedException>(() => m2.Module); 84Assert.Throws<ObjectDisposedException>(() => m3.Module); 123Assert.Throws<ObjectDisposedException>(() => copy1.GetModules()[0].Module); 124Assert.Throws<ObjectDisposedException>(() => copy1.GetModules()[1].Module); 125Assert.Throws<ObjectDisposedException>(() => copy1.GetModules()[2].Module); 133Assert.Throws<ObjectDisposedException>(() => a.GetModules()[0].Module); 134Assert.Throws<ObjectDisposedException>(() => a.GetModules()[1].Module); 135Assert.Throws<ObjectDisposedException>(() => a.GetModules()[2].Module); 143Assert.Throws<BadImageFormatException>(() => metadata.GetModules()); 150Assert.Throws<BadImageFormatException>(() => metadata.GetModules());
MetadataReferences\AssemblyPortabilityPolicyTests.cs (7)
80Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 81Assert.Throws<XmlException>(() => AssemblyPortabilityPolicy.LoadFromXml(stream)); 89Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 90Assert.Throws<XmlException>(() => AssemblyPortabilityPolicy.LoadFromXml(stream)); 105Assert.Throws<COMException>(() => FusionAssemblyPortabilityPolicy.LoadFromFile(appConfig.Path)); 106Assert.Throws<XmlException>(() => AssemblyPortabilityPolicy.LoadFromXml(stream)); 128Assert.Throws<XmlException>(() => AssemblyPortabilityPolicy.LoadFromXml(stream));
MetadataReferences\FusionAssemblyIdentityTests.cs (6)
207Assert.Throws<CultureNotFoundException>(() => ToAssemblyName(nameObject)); 211Assert.Throws<CultureNotFoundException>(() => ToAssemblyName(nameObject)); 213Assert.Throws<CultureNotFoundException>(() => new AssemblyName("mscorlib, Version=2.0.0.0, Culture=nonsense")); 214Assert.Throws<CultureNotFoundException>(() => new AssemblyName("mscorlib, Version=2.0.0.0, Culture=null")); 216Assert.Throws<ArgumentException>(() => FusionAssemblyIdentity.ToAssemblyNameObject(new AssemblyName { Name = "x\0x" })); 224Assert.Throws<FileLoadException>(() => name.FullName);
MetadataReferences\MetadataReferencePropertiesTests.cs (8)
42Assert.Throws<ArgumentOutOfRangeException>(() => new MetadataReferenceProperties((MetadataImageKind)byte.MaxValue)); 43Assert.Throws<ArgumentException>(() => new MetadataReferenceProperties(MetadataImageKind.Module, ImmutableArray.Create("blah"))); 44Assert.Throws<ArgumentException>(() => new MetadataReferenceProperties(MetadataImageKind.Module, embedInteropTypes: true)); 45Assert.Throws<ArgumentException>(() => new MetadataReferenceProperties(MetadataImageKind.Module, ImmutableArray.Create(""))); 46Assert.Throws<ArgumentException>(() => new MetadataReferenceProperties(MetadataImageKind.Module, ImmutableArray.Create("x\0x"))); 48Assert.Throws<ArgumentException>(() => MetadataReferenceProperties.Module.WithAliases(ImmutableArray.Create("blah"))); 49Assert.Throws<ArgumentException>(() => MetadataReferenceProperties.Module.WithAliases(new[] { "blah" })); 50Assert.Throws<ArgumentException>(() => MetadataReferenceProperties.Module.WithEmbedInteropTypes(true));
MetadataReferences\MetadataReferenceTests.cs (15)
35Assert.Throws<NotSupportedException>(() => MetadataReference.CreateFromAssemblyInternal(dynamicAssembly)); 39Assert.Throws<NotSupportedException>(() => MetadataReference.CreateFromAssemblyInternal(inMemoryAssembly)); 45Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromImage(null)); 46Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromImage(default)); 47Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromFile(null)); 48Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromFile(null, default(MetadataReferenceProperties))); 49Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromStream(null)); 51Assert.Throws<ArgumentNullException>(() => MetadataReference.CreateFromAssemblyInternal(null)); 52Assert.Throws<ArgumentException>(() => MetadataReference.CreateFromAssemblyInternal(typeof(object).Assembly, new MetadataReferenceProperties(MetadataImageKind.Module))); 55Assert.Throws<NotSupportedException>(() => MetadataReference.CreateFromAssemblyInternal(dynamicAssembly)); 280Assert.Throws<ArgumentException>(() => r.WithAliases(new[] { "bar" })); 281Assert.Throws<ArgumentException>(() => r.WithEmbedInteropTypes(true)); 364Assert.Throws<ArgumentException>(() => r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module))); 395Assert.Throws<ArgumentException>(() => r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module))); 587Assert.Throws<BadImageFormatException>((Func<object>)((AssemblyMetadata)r.GetMetadataNoCopy()).GetAssembly);
MetadataReferences\ModuleMetadataTests.cs (24)
23Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromMetadata(IntPtr.Zero, 0)); 30Assert.Throws<BadImageFormatException>(() => metadata.GetModuleNames()); 89Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromImage(IntPtr.Zero, 0)); 93Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromImage(default(ImmutableArray<byte>))); 96Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromImage(enumerableImage)); 99Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromImage(arrayImage)); 109Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromStream(peStream: null)); 110Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromStream(new TestStream(canRead: false, canSeek: true))); 111Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromStream(new TestStream(canRead: true, canSeek: false))); 117Assert.Throws<ArgumentNullException>(() => ModuleMetadata.CreateFromFile((string)null)); 118Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromFile("")); 119Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromFile(@"c:\*")); 122Assert.Throws<IOException>(() => ModuleMetadata.CreateFromFile(@"http://goo.bar")); 123Assert.Throws<FileNotFoundException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\file_that_does_not_exists.dll")); 124Assert.Throws<FileNotFoundException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\directory_that_does_not_exists\file_that_does_not_exists.dll")); 125Assert.Throws<PathTooLongException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\" + new string('x', 1000))); 126Assert.Throws<IOException>(() => ModuleMetadata.CreateFromFile(Environment.GetFolderPath(Environment.SpecialFolder.Windows))); 134Assert.Throws<ObjectDisposedException>(() => md.Module); 156Assert.Throws<ObjectDisposedException>(() => copy1.Module); 162Assert.Throws<ObjectDisposedException>(() => m.Module); 163Assert.Throws<ObjectDisposedException>(() => copy1.Module); 164Assert.Throws<ObjectDisposedException>(() => copy2.Module); 171Assert.Throws<BadImageFormatException>(() => ModuleMetadata.CreateFromStream(new MemoryStream(), PEStreamOptions.PrefetchMetadata)); 172Assert.Throws<BadImageFormatException>(() => ModuleMetadata.CreateFromStream(new MemoryStream(), PEStreamOptions.PrefetchMetadata | PEStreamOptions.PrefetchEntireImage));
PDB\CustomDebugInfoReaderTests.cs (1)
30Assert.Throws<InvalidOperationException>(() => CustomDebugInfoReader.DecodeForwardIteratorRecord(bytes.ToImmutableArray()));
ResourceDescriptionTests.cs (17)
28Assert.Throws<ArgumentNullException>(() => new ResourceDescription(null, "file", data, isPublic: true)); 29Assert.Throws<ArgumentNullException>(() => new ResourceDescription("res", null, data, isPublic: true)); 30Assert.Throws<ArgumentNullException>(() => new ResourceDescription("res", "file", null, isPublic: true)); 31Assert.Throws<ArgumentNullException>(() => new ResourceDescription(null, data, isPublic: true)); 32Assert.Throws<ArgumentNullException>(() => new ResourceDescription("res", null, isPublic: true)); 35Assert.Throws<ArgumentException>(() => new ResourceDescription("", "file", data, isPublic: true)); 36Assert.Throws<ArgumentException>(() => new ResourceDescription("res", "", data, isPublic: true)); 37Assert.Throws<ArgumentException>(() => new ResourceDescription("res", "", data, isPublic: true)); 38Assert.Throws<ArgumentException>(() => new ResourceDescription("", "file", data, isPublic: true)); 41Assert.Throws<ArgumentException>(() => new ResourceDescription("x", "x/x", data, isPublic: true)); 42Assert.Throws<ArgumentException>(() => new ResourceDescription("x", "x\\x", data, isPublic: true)); 43Assert.Throws<ArgumentException>(() => new ResourceDescription("x", "x:x", data, isPublic: true)); 44Assert.Throws<ArgumentException>(() => new ResourceDescription("x", "\0", data, isPublic: true)); 45Assert.Throws<ArgumentException>(() => new ResourceDescription("", "x", data, isPublic: true)); 46Assert.Throws<ArgumentException>(() => new ResourceDescription("xxx\0xxxx", "", data, isPublic: true)); 47Assert.Throws<ArgumentException>(() => new ResourceDescription("xxx\uD800asdas", "", data, isPublic: true)); 48Assert.Throws<ArgumentException>(() => new ResourceDescription("xxx", "xxx\uD800asdas", data, isPublic: true));
Text\LargeTextTests.cs (2)
65Assert.Throws<IndexOutOfRangeException>(() => text[-1]); 66Assert.Throws<IndexOutOfRangeException>(() => text[HelloWorld.Length]);
Text\SourceTextStreamTests.cs (1)
35Assert.Throws<ArgumentException>(() => stream.Read(buffer, 0, local));
Text\SourceTextTests.cs (2)
343Assert.Throws<InvalidDataException>(() => SourceText.From(bytes, bytes.Length, throwIfBinaryDetected: true)); 346Assert.Throws<InvalidDataException>(() => SourceText.From(stream, throwIfBinaryDetected: true));
Text\StringText_LineTest.cs (7)
62Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(0, 0))); 69Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(0, 3))); 76Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(1, 5))); 107Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(1, 10))); 114Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(-1, 2))); 121Assert.Throws<ArgumentOutOfRangeException>(() => TextLine.FromSpan(text, new TextSpan(7, 0))); 128Assert.Throws<ArgumentNullException>(() => TextLine.FromSpan(null, new TextSpan(0, 2)));
Text\StringTextTest.cs (4)
69Assert.Throws<ArgumentNullException>(() => SourceText.From((string)null, Encoding.UTF8)); 75Assert.Throws<ArgumentNullException>(() => SourceText.From((Stream)null, Encoding.UTF8)); 76Assert.Throws<ArgumentException>(() => SourceText.From(new TestStream(canRead: false, canSeek: true), Encoding.UTF8)); 77Assert.Throws<NotImplementedException>(() => SourceText.From(new TestStream(canRead: true, canSeek: false), Encoding.UTF8));
Text\TextChangeTests.cs (1)
127Assert.Throws<ArgumentException>(() => text.WithChanges(changes));
Text\TextLineCollectionTests.cs (2)
19Assert.Throws<NotSupportedException>(() => default(TextLineCollection.Enumerator).Equals(default(TextLineCollection.Enumerator))); 20Assert.Throws<NotSupportedException>(() => default(TextLineCollection.Enumerator).GetHashCode());
Microsoft.CodeAnalysis.Workspaces.UnitTests (173)
Differencing\MatchTests.cs (2)
29Assert.Throws<ArgumentException>(() => TestTreeComparer.Instance.ComputeMatch(oldRoot, newRoot, [KeyValuePair.Create(x1, x1)])); 31Assert.Throws<ArgumentException>(() => TestTreeComparer.Instance.ComputeMatch(oldRoot, newRoot, [KeyValuePair.Create(x1, x2), KeyValuePair.Create(x1, new TestNode(0, 0))]));
Options\OptionKeyTests.cs (13)
23Assert.Throws<ArgumentNullException>(() => new Option<bool>("Test Feature", null!, false)); 24Assert.Throws<ArgumentNullException>(() => new Option<bool>(null!, "Test Name", false)); 25Assert.Throws<ArgumentNullException>(() => new Option<bool>("X", "Test Name", false, storageLocations: null!)); 26Assert.Throws<ArgumentNullException>(() => new Option<bool>("X", "Test Name", false, storageLocations: [null!])); 32Assert.Throws<ArgumentNullException>(() => new PerLanguageOption<bool>("Test Feature", null!, false)); 33Assert.Throws<ArgumentNullException>(() => new PerLanguageOption<bool>(null!, "Test Name", false)); 34Assert.Throws<ArgumentNullException>(() => new PerLanguageOption<bool>("X", "Test Name", false, storageLocations: null!)); 35Assert.Throws<ArgumentNullException>(() => new PerLanguageOption<bool>("X", "Test Name", false, storageLocations: [null!])); 70Assert.Throws<ArgumentNullException>(() => new OptionKey(null!)); 71Assert.Throws<ArgumentNullException>(() => new OptionKey(null!, null!)); 72Assert.Throws<ArgumentNullException>(() => new OptionKey(null!, "lang")); 73Assert.Throws<ArgumentNullException>(() => new OptionKey(new TestOption() { IsPerLanguage = true })); 74Assert.Throws<ArgumentException>(() => new OptionKey(new TestOption() { IsPerLanguage = false }, language: "lang"));
Remote\ServiceDescriptorTests.cs (1)
191Assert.Throws<NotImplementedException>(() => original.GetBytes("\u1234"));
SolutionTests\DocumentInfoTests.cs (3)
24Assert.Throws<ArgumentNullException>(() => DocumentInfo.Create(id: null, "doc")); 25Assert.Throws<ArgumentNullException>(() => DocumentInfo.Create(documentId, name: null)); 27Assert.Throws<ArgumentNullException>(() => DocumentInfo.Create(documentId, "doc", folders: ["folder", null]));
SolutionTests\ProjectInfoTests.cs (8)
24Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(id: null, version: VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#")); 25Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: null, assemblyName: "Bar", language: "C#")); 26Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: null, language: "C#")); 27Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: null)); 29Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#", 42Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#", 48Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#", 62Assert.Throws<ArgumentNullException>(() => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#",
SolutionTests\SolutionInfoTests.cs (2)
23Assert.Throws<ArgumentNullException>(() => SolutionInfo.Create(null, version)); 24Assert.Throws<ArgumentNullException>(() => SolutionInfo.Create(solutionId, version, projects: [projectInfo, null]));
SolutionTests\SolutionTestHelpers.cs (3)
38Assert.Throws<ArgumentNullException>(() => factory(instance, default)); 71Assert.Throws<ArgumentNullException>(() => factory(instanceWithNoItem, new TValue[] { item, default })); 81Assert.Throws<ArgumentException>(() => factory(instanceWithNoItem, new TValue[] { item, item }));
SolutionTests\SolutionTests.cs (116)
116Assert.Throws<ArgumentNullException>(() => solution.RemoveDocument(null!)); 117Assert.Throws<InvalidOperationException>(() => solution.RemoveDocument(s_unrelatedDocumentId)); 125Assert.Throws<ArgumentNullException>(() => solution.RemoveDocuments(default)); 126Assert.Throws<InvalidOperationException>(() => solution.RemoveDocuments(ImmutableArray.Create(s_unrelatedDocumentId))); 127Assert.Throws<ArgumentNullException>(() => solution.RemoveDocuments(ImmutableArray.Create((DocumentId)null!))); 135Assert.Throws<ArgumentNullException>(() => solution.RemoveAdditionalDocument(null!)); 136Assert.Throws<InvalidOperationException>(() => solution.RemoveAdditionalDocument(s_unrelatedDocumentId)); 144Assert.Throws<ArgumentNullException>(() => solution.RemoveAdditionalDocuments(default)); 145Assert.Throws<InvalidOperationException>(() => solution.RemoveAdditionalDocuments(ImmutableArray.Create(s_unrelatedDocumentId))); 146Assert.Throws<ArgumentNullException>(() => solution.RemoveAdditionalDocuments(ImmutableArray.Create((DocumentId)null!))); 154Assert.Throws<ArgumentNullException>(() => solution.RemoveAnalyzerConfigDocument(null!)); 155Assert.Throws<InvalidOperationException>(() => solution.RemoveAnalyzerConfigDocument(s_unrelatedDocumentId)); 163Assert.Throws<ArgumentNullException>(() => solution.RemoveAnalyzerConfigDocuments(default)); 164Assert.Throws<InvalidOperationException>(() => solution.RemoveAnalyzerConfigDocuments(ImmutableArray.Create(s_unrelatedDocumentId))); 165Assert.Throws<ArgumentNullException>(() => solution.RemoveAnalyzerConfigDocuments(ImmutableArray.Create((DocumentId)null!))); 182Assert.Throws<ArgumentNullException>(() => solution.WithDocumentName(documentId, name: null!)); 184Assert.Throws<ArgumentNullException>(() => solution.WithDocumentName(null!, name)); 185Assert.Throws<InvalidOperationException>(() => solution.WithDocumentName(s_unrelatedDocumentId, name)); 212Assert.Throws<ArgumentNullException>(() => solution.WithDocumentFolders(documentId, folders: [null!])); 214Assert.Throws<ArgumentNullException>(() => solution.WithDocumentFolders(null!, folders)); 215Assert.Throws<InvalidOperationException>(() => solution.WithDocumentFolders(s_unrelatedDocumentId, folders)); 242Assert.Throws<ArgumentNullException>(() => solution.WithDocumentFilePath(null!, path)); 243Assert.Throws<InvalidOperationException>(() => solution.WithDocumentFilePath(s_unrelatedDocumentId, path)); 258Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentSourceCodeKind(documentId, (SourceCodeKind)(-1))); 260Assert.Throws<ArgumentNullException>(() => solution.WithDocumentSourceCodeKind(null!, SourceCodeKind.Script)); 261Assert.Throws<InvalidOperationException>(() => solution.WithDocumentSourceCodeKind(s_unrelatedDocumentId, SourceCodeKind.Script)); 317Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentSyntaxRoot(documentId, root, (PreservationMode)(-1))); 319Assert.Throws<ArgumentNullException>(() => solution.WithDocumentSyntaxRoot(null!, root)); 320Assert.Throws<InvalidOperationException>(() => solution.WithDocumentSyntaxRoot(s_unrelatedDocumentId, root)); 338Assert.Throws<ArgumentException>(() => provider.TryGetDiagnosticValue(tree, "CA1234", CancellationToken.None, out _)); 359Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 360Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentText(documentId, text, (PreservationMode)(-1))); 362Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText((DocumentId)null!, text, PreservationMode.PreserveIdentity)); 363Assert.Throws<InvalidOperationException>(() => solution.WithDocumentText(s_unrelatedDocumentId, text, PreservationMode.PreserveIdentity)); 383Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 384Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentText(documentId, textAndVersion, (PreservationMode)(-1))); 386Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText((DocumentId)null!, textAndVersion, PreservationMode.PreserveIdentity)); 387Assert.Throws<InvalidOperationException>(() => solution.WithDocumentText(s_unrelatedDocumentId, textAndVersion, PreservationMode.PreserveIdentity)); 409Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText((DocumentId[])null!, text, PreservationMode.PreserveIdentity)); 410Assert.Throws<ArgumentNullException>(() => solution.WithDocumentText([documentId], null!, PreservationMode.PreserveIdentity)); 411Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentText([documentId], text, (PreservationMode)(-1))); 927Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 928Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAdditionalDocumentText(documentId, text, (PreservationMode)(-1))); 930Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText((DocumentId)null!, text, PreservationMode.PreserveIdentity)); 931Assert.Throws<InvalidOperationException>(() => solution.WithAdditionalDocumentText(s_unrelatedDocumentId, text, PreservationMode.PreserveIdentity)); 951Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 952Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAdditionalDocumentText(documentId, textAndVersion, (PreservationMode)(-1))); 954Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentText((DocumentId)null!, textAndVersion, PreservationMode.PreserveIdentity)); 955Assert.Throws<InvalidOperationException>(() => solution.WithAdditionalDocumentText(s_unrelatedDocumentId, textAndVersion, PreservationMode.PreserveIdentity)); 973Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 974Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAnalyzerConfigDocumentText(documentId, text, (PreservationMode)(-1))); 976Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText((DocumentId)null!, text, PreservationMode.PreserveIdentity)); 977Assert.Throws<InvalidOperationException>(() => solution.WithAnalyzerConfigDocumentText(s_unrelatedDocumentId, text, PreservationMode.PreserveIdentity)); 997Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText(documentId, (SourceText)null!, PreservationMode.PreserveIdentity)); 998Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAnalyzerConfigDocumentText(documentId, textAndVersion, (PreservationMode)(-1))); 1000Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentText((DocumentId)null!, textAndVersion, PreservationMode.PreserveIdentity)); 1001Assert.Throws<InvalidOperationException>(() => solution.WithAnalyzerConfigDocumentText(s_unrelatedDocumentId, textAndVersion, PreservationMode.PreserveIdentity)); 1019Assert.Throws<ArgumentNullException>(() => solution.WithDocumentTextLoader(documentId, null!, PreservationMode.PreserveIdentity)); 1020Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithDocumentTextLoader(documentId, loader, (PreservationMode)(-1))); 1022Assert.Throws<ArgumentNullException>(() => solution.WithDocumentTextLoader(null!, loader, PreservationMode.PreserveIdentity)); 1023Assert.Throws<InvalidOperationException>(() => solution.WithDocumentTextLoader(s_unrelatedDocumentId, loader, PreservationMode.PreserveIdentity)); 1041Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentTextLoader(documentId, null!, PreservationMode.PreserveIdentity)); 1042Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAdditionalDocumentTextLoader(documentId, loader, (PreservationMode)(-1))); 1044Assert.Throws<ArgumentNullException>(() => solution.WithAdditionalDocumentTextLoader(null!, loader, PreservationMode.PreserveIdentity)); 1045Assert.Throws<InvalidOperationException>(() => solution.WithAdditionalDocumentTextLoader(s_unrelatedDocumentId, loader, PreservationMode.PreserveIdentity)); 1063Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentTextLoader(documentId, null!, PreservationMode.PreserveIdentity)); 1064Assert.Throws<ArgumentOutOfRangeException>(() => solution.WithAnalyzerConfigDocumentTextLoader(documentId, loader, (PreservationMode)(-1))); 1066Assert.Throws<ArgumentNullException>(() => solution.WithAnalyzerConfigDocumentTextLoader(null!, loader, PreservationMode.PreserveIdentity)); 1067Assert.Throws<InvalidOperationException>(() => solution.WithAnalyzerConfigDocumentTextLoader(s_unrelatedDocumentId, loader, PreservationMode.PreserveIdentity)); 1322Assert.Throws<NotSupportedException>(() => solution.WithProjectInfo(newInfo)); 1357Assert.Throws<NotSupportedException>(() => solution.WithProjectInfo(newInfo)); 1392Assert.Throws<NotSupportedException>(() => solution.WithProjectInfo(newInfo)); 1427Assert.Throws<NotSupportedException>(() => solution.WithProjectInfo(newInfo)); 1449Assert.Throws<InvalidOperationException>(() => solution.WithProjectAssemblyName(ProjectId.CreateNewId(), "x.dll")); 1473Assert.Throws<InvalidOperationException>(() => solution.WithProjectOutputFilePath(ProjectId.CreateNewId(), "x.dll")); 1527Assert.Throws<InvalidOperationException>(() => solution.WithProjectOutputRefFilePath(ProjectId.CreateNewId(), "x.dll")); 1550Assert.Throws<InvalidOperationException>(() => solution.WithProjectCompilationOutputInfo(ProjectId.CreateNewId(), info)); 1573Assert.Throws<InvalidOperationException>(() => solution.WithProjectDefaultNamespace(ProjectId.CreateNewId(), "x")); 1686Assert.Throws<InvalidOperationException>(() => solution.WithProjectName(ProjectId.CreateNewId(), "x")); 1709Assert.Throws<InvalidOperationException>(() => solution.WithProjectFilePath(ProjectId.CreateNewId(), "x")); 1725Assert.Throws<InvalidOperationException>(() => solution.WithProjectCompilationOptions(ProjectId.CreateNewId(), options)); 1774Assert.Throws<InvalidOperationException>(() => solution.WithProjectParseOptions(ProjectId.CreateNewId(), options)); 1936Assert.Throws<InvalidOperationException>(() => solution.WithProjectReferences(ProjectId.CreateNewId(), [projectRef])); 1939Assert.Throws<InvalidOperationException>(() => solution2.WithProjectReferences(projectId2, [new ProjectReference(projectId)])); 1940Assert.Throws<InvalidOperationException>(() => solution.WithProjectReferences(projectId, [new ProjectReference(projectId)])); 1994Assert.Throws<InvalidOperationException>(() => solution.AddProjectReferences(projectId3, [projectRef2])); 1997Assert.Throws<InvalidOperationException>(() => solution3.AddProjectReferences(projectId2, [projectRef3])); 1998Assert.Throws<InvalidOperationException>(() => solution3.AddProjectReferences(projectId, [new ProjectReference(projectId)])); 2033Assert.Throws<InvalidOperationException>(() => solution.RemoveProjectReference(ProjectId.CreateNewId(), projectRef2)); 2064Assert.Throws<InvalidOperationException>(() => solution.AddProjectReferences(submissionId2, [new ProjectReference(submissionId3)])); 2065Assert.Throws<InvalidOperationException>(() => solution.WithProjectReferences(submissionId1, [new ProjectReference(submissionId2), new ProjectReference(submissionId3)])); 2068Assert.Throws<InvalidOperationException>(() => solution.AddProjectReferences(projectId0, [new ProjectReference(submissionId1)])); 2069Assert.Throws<InvalidOperationException>(() => solution.WithProjectReferences(projectId0, [new ProjectReference(submissionId1)])); 2087Assert.Throws<InvalidOperationException>(() => solution.WithProjectMetadataReferences(ProjectId.CreateNewId(), [metadataRef])); 2112Assert.Throws<InvalidOperationException>(() => solution3.AddMetadataReferences(projectId, [metadataRef1])); 2136Assert.Throws<InvalidOperationException>(() => solution.RemoveMetadataReference(projectId, new TestMetadataReference())); 2139Assert.Throws<InvalidOperationException>(() => solution.RemoveMetadataReference(ProjectId.CreateNewId(), metadataRef1)); 2157Assert.Throws<InvalidOperationException>(() => solution.WithProjectAnalyzerReferences(ProjectId.CreateNewId(), [analyzerRef])); 2185Assert.Throws<InvalidOperationException>(() => solution3.AddAnalyzerReferences(projectId, [analyzerRef1])); 2209Assert.Throws<InvalidOperationException>(() => solution.RemoveAnalyzerReference(projectId, new TestAnalyzerReference())); 2212Assert.Throws<InvalidOperationException>(() => solution.RemoveAnalyzerReference(ProjectId.CreateNewId(), analyzerRef1)); 2252Assert.Throws<InvalidOperationException>(() => solution3.AddAnalyzerReferences([analyzerRef1])); 2274Assert.Throws<InvalidOperationException>(() => solution.RemoveAnalyzerReference(new TestAnalyzerReference())); 2379Assert.Throws<InvalidOperationException>(() => solution.AddDocument(documentId: DocumentId.CreateNewId(ProjectId.CreateNewId()), "name", loader)); 2410Assert.Throws<InvalidOperationException>(() => solution.AddDocument(documentId: DocumentId.CreateNewId(ProjectId.CreateNewId()), "name", "text")); 2438Assert.Throws<InvalidOperationException>(() => solution.AddDocument(documentId: DocumentId.CreateNewId(ProjectId.CreateNewId()), "name", sourceText)); 2490Assert.Throws<InvalidOperationException>(() => solution.AddDocument(documentId: DocumentId.CreateNewId(ProjectId.CreateNewId()), "name", syntaxRoot: root)); 2767Assert.Throws<ArgumentException>(() => solution.GetProject(projectId2).RemoveDocuments(ImmutableArray.Create(documentInfo1.Id))); 2786Assert.Throws<ArgumentException>(() => solution.GetProject(projectId2).RemoveAdditionalDocuments(ImmutableArray.Create(documentInfo1.Id))); 2805Assert.Throws<ArgumentException>(() => solution.GetProject(projectId2).RemoveAnalyzerConfigDocuments(ImmutableArray.Create(documentInfo1.Id))); 4690Assert.Throws<ArgumentException>(() => solution = solution.WithProjectDocumentsOrder(pid, ImmutableList.Create<DocumentId>())); 4691Assert.Throws<ArgumentNullException>(() => solution = solution.WithProjectDocumentsOrder(pid, null)); 4692Assert.Throws<InvalidOperationException>(() => solution = solution.WithProjectDocumentsOrder(pid, ImmutableList.CreateRange([did5, did3, did2, did1]))); 4693Assert.Throws<ArgumentException>(() => solution = solution.WithProjectDocumentsOrder(pid, ImmutableList.CreateRange([did3, did2, did1]))); 5173Assert.Throws<InvalidOperationException>(() => solution.AddProjects(projects)); 5287Assert.Throws<InvalidOperationException>(() => solution.RemoveProjects(projectsToRemove));
SolutionTests\TryApplyChangesTests.cs (2)
106var exception = Assert.Throws<NotSupportedException>( 153var exception = Assert.Throws<NotSupportedException>(
UtilityTest\AsyncLazyTests.cs (1)
296: Assert.Throws<ArgumentException>(() => lazy.GetValue(CancellationToken.None));
UtilityTest\CancellationSeriesTests.cs (2)
57Assert.Throws<ObjectDisposedException>(() => series.CreateNext()); 126var aggregateException = Assert.Throws<AggregateException>(() => series.CreateNext());
UtilityTest\SpecializedTasksTests.cs (10)
30Assert.Throws<ArgumentNullException>(() => SpecializedTasks.WhenAll<int>((IEnumerable<ValueTask<int>>)null!)); 119var exception = Assert.Throws<TaskCanceledException>(() => task.Result); 196var exception = Assert.Throws<TaskCanceledException>(() => task.Result); 253var exception = Assert.Throws<TaskCanceledException>(() => task.Result); 320var exception = Assert.Throws<TaskCanceledException>(() => task.Result); 378var exception = Assert.Throws<InvalidOperationException>(() => SpecializedTasks.TransformWithoutIntermediateCancellationExceptionAsync(func, transform, arg, cancellationToken)); 401var exception = Assert.Throws<InvalidOperationException>(() => task.Result); 455var exception = Assert.Throws<InvalidOperationException>(() => SpecializedTasks.TransformWithoutIntermediateCancellationExceptionAsync(func, transform, arg, cancellationToken)); 481var exception = Assert.Throws<TaskCanceledException>(() => task.Result); 530var exception = Assert.Throws<InvalidOperationException>(() => SpecializedTasks.TransformWithoutIntermediateCancellationExceptionAsync(func, transform, arg, cancellationToken));
UtilityTest\TaskExtensionsTests.cs (3)
20Assert.Throws<TaskCanceledException>(() => Task.FromCanceled<int>(new CancellationToken(canceled: true)).WaitAndGetResult_CanCallOnBackground(CancellationToken.None)); 21Assert.Throws<OperationCanceledException>(() => new TaskCompletionSource<int>().Task.WaitAndGetResult_CanCallOnBackground(new CancellationToken(canceled: true))); 22var ex = Assert.Throws<TestException>(() => Task.Run(() => ThrowTestException()).WaitAndGetResult_CanCallOnBackground(CancellationToken.None));
WorkspaceServiceTests\ReferenceCountedDisposableTests.cs (1)
39Assert.Throws<ObjectDisposedException>(() => reference.Target);
WorkspaceTests\WorkspaceTests.cs (6)
30Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(changedDoc.Project.Solution)).Message); 46Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(changedDoc.Project.Solution)).Message); 64Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(changedDoc.Project.Solution)).Message); 81Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(changedDoc.Project.Solution)).Message); 97Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(changedDoc.Project.Solution)).Message); 109Assert.Throws<NotSupportedException>(() => ws.TryApplyChanges(newSolution)).Message);
Microsoft.CommonLanguageServerProtocol.Framework.UnitTests (3)
ExampleTests.cs (1)
22var ex = Assert.Throws<InvalidOperationException>(() => TestExampleLanguageServer.CreateBadLanguageServer(logger));
HandlerProviderTests.cs (2)
55Assert.Throws<InvalidOperationException>(() => handlerProvider.GetMethodHandler("UndefinedMethod", TestMethodHandler.RequestType, TestMethodHandler.ResponseType, LanguageServerConstants.DefaultLanguageName)); 63Assert.Throws<InvalidOperationException>(() => handlerProvider.GetMethodHandler(TestMethodHandler.Name, TestMethodHandler.RequestType, responseTypeRef: TypeRef.Of<long>(), LanguageServerConstants.DefaultLanguageName));
Microsoft.Data.Analysis.Tests (141)
DataFrame.IOTests.cs (4)
232Assert.Throws<System.ArgumentException>(() => DataFrame.LoadCsv(GetStream(data))); 752Assert.Throws<IndexOutOfRangeException>(() => DataFrame.LoadCsv(GetStream(data))); 753Assert.Throws<IndexOutOfRangeException>(() => DataFrame.LoadCsvFromString(data)); 1752Assert.Throws<FormatException>(() => DataFrame.LoadCsvFromString(csvString));
DataFrameGroupByTests.cs (1)
106Assert.Throws<InvalidCastException>(() => df.GroupBy<double>("Tens"));
DataFrameTests.BinaryOperations.cs (10)
162Assert.Throws<NotSupportedException>(() => df.Add(true)); 167Assert.Throws<NotSupportedException>(() => df.And(true)); 180Assert.Throws<NotSupportedException>(() => df.Add(5)); 182Assert.Throws<NotSupportedException>(() => df.LeftShift(5)); 214Assert.Throws<NotSupportedException>(() => df.Add(5)); 216Assert.Throws<NotSupportedException>(() => df.LeftShift(5)); 218Assert.Throws<NotSupportedException>(() => df.RightShift(5)); 221Assert.Throws<NotSupportedException>(() => df.And(true)); 223Assert.Throws<NotSupportedException>(() => df.Or(true)); 225Assert.Throws<NotSupportedException>(() => df.Xor(true));
DataFrameTests.Computations.cs (92)
31Assert.Throws<NotSupportedException>(() => df.Columns["Byte"].All()); 32Assert.Throws<NotSupportedException>(() => df.Columns["Byte"].Any()); 33Assert.Throws<NotSupportedException>(() => df.Columns["Char"].All()); 34Assert.Throws<NotSupportedException>(() => df.Columns["Char"].Any()); 35Assert.Throws<NotSupportedException>(() => df.Columns["DateTime"].All()); 36Assert.Throws<NotSupportedException>(() => df.Columns["DateTime"].Any()); 37Assert.Throws<NotSupportedException>(() => df.Columns["Decimal"].All()); 38Assert.Throws<NotSupportedException>(() => df.Columns["Decimal"].Any()); 39Assert.Throws<NotSupportedException>(() => df.Columns["Double"].All()); 40Assert.Throws<NotSupportedException>(() => df.Columns["Double"].Any()); 41Assert.Throws<NotSupportedException>(() => df.Columns["Float"].All()); 42Assert.Throws<NotSupportedException>(() => df.Columns["Float"].Any()); 43Assert.Throws<NotSupportedException>(() => df.Columns["Int"].All()); 44Assert.Throws<NotSupportedException>(() => df.Columns["Int"].Any()); 45Assert.Throws<NotSupportedException>(() => df.Columns["Long"].All()); 46Assert.Throws<NotSupportedException>(() => df.Columns["Long"].Any()); 47Assert.Throws<NotSupportedException>(() => df.Columns["Sbyte"].All()); 48Assert.Throws<NotSupportedException>(() => df.Columns["Sbyte"].Any()); 49Assert.Throws<NotSupportedException>(() => df.Columns["Short"].All()); 50Assert.Throws<NotSupportedException>(() => df.Columns["Short"].Any()); 51Assert.Throws<NotSupportedException>(() => df.Columns["Uint"].All()); 52Assert.Throws<NotSupportedException>(() => df.Columns["Uint"].Any()); 53Assert.Throws<NotSupportedException>(() => df.Columns["Ulong"].All()); 54Assert.Throws<NotSupportedException>(() => df.Columns["Ulong"].Any()); 55Assert.Throws<NotSupportedException>(() => df.Columns["Ushort"].All()); 56Assert.Throws<NotSupportedException>(() => df.Columns["Ushort"].Any()); 133Assert.Throws<NotSupportedException>(() => column.CumulativeMax()); 134Assert.Throws<NotSupportedException>(() => column.CumulativeMin()); 135Assert.Throws<NotSupportedException>(() => column.CumulativeProduct()); 136Assert.Throws<NotSupportedException>(() => column.CumulativeSum()); 137Assert.Throws<NotSupportedException>(() => column.Max()); 138Assert.Throws<NotSupportedException>(() => column.Min()); 139Assert.Throws<NotSupportedException>(() => column.Product()); 140Assert.Throws<NotSupportedException>(() => column.Sum()); 145Assert.Throws<NotImplementedException>(() => column.CumulativeMax()); 146Assert.Throws<NotImplementedException>(() => column.CumulativeMin()); 147Assert.Throws<NotImplementedException>(() => column.CumulativeProduct()); 148Assert.Throws<NotImplementedException>(() => column.CumulativeSum()); 149Assert.Throws<NotImplementedException>(() => column.Max()); 150Assert.Throws<NotImplementedException>(() => column.Min()); 151Assert.Throws<NotImplementedException>(() => column.Product()); 152Assert.Throws<NotImplementedException>(() => column.Sum()); 162Assert.Throws<NotSupportedException>(() => column.CumulativeProduct()); 163Assert.Throws<NotSupportedException>(() => column.CumulativeSum()); 164Assert.Throws<NotSupportedException>(() => column.Product()); 165Assert.Throws<NotSupportedException>(() => column.Sum()); 193Assert.Throws<NotSupportedException>(() => df.Columns["Byte"].All()); 194Assert.Throws<NotSupportedException>(() => df.Columns["Byte"].Any()); 195Assert.Throws<NotSupportedException>(() => df.Columns["Char"].All()); 196Assert.Throws<NotSupportedException>(() => df.Columns["Char"].Any()); 197Assert.Throws<NotSupportedException>(() => df.Columns["Decimal"].All()); 198Assert.Throws<NotSupportedException>(() => df.Columns["Decimal"].Any()); 199Assert.Throws<NotSupportedException>(() => df.Columns["Double"].All()); 200Assert.Throws<NotSupportedException>(() => df.Columns["Double"].Any()); 201Assert.Throws<NotSupportedException>(() => df.Columns["Float"].All()); 202Assert.Throws<NotSupportedException>(() => df.Columns["Float"].Any()); 203Assert.Throws<NotSupportedException>(() => df.Columns["Int"].All()); 204Assert.Throws<NotSupportedException>(() => df.Columns["Int"].Any()); 205Assert.Throws<NotSupportedException>(() => df.Columns["Long"].All()); 206Assert.Throws<NotSupportedException>(() => df.Columns["Long"].Any()); 207Assert.Throws<NotSupportedException>(() => df.Columns["Sbyte"].All()); 208Assert.Throws<NotSupportedException>(() => df.Columns["Sbyte"].Any()); 209Assert.Throws<NotSupportedException>(() => df.Columns["Short"].All()); 210Assert.Throws<NotSupportedException>(() => df.Columns["Short"].Any()); 211Assert.Throws<NotSupportedException>(() => df.Columns["Uint"].All()); 212Assert.Throws<NotSupportedException>(() => df.Columns["Uint"].Any()); 213Assert.Throws<NotSupportedException>(() => df.Columns["Ulong"].All()); 214Assert.Throws<NotSupportedException>(() => df.Columns["Ulong"].Any()); 215Assert.Throws<NotSupportedException>(() => df.Columns["Ushort"].All()); 216Assert.Throws<NotSupportedException>(() => df.Columns["Ushort"].Any()); 217Assert.Throws<NotSupportedException>(() => df.Columns["DateTime"].All()); 218Assert.Throws<NotSupportedException>(() => df.Columns["DateTime"].Any()); 302Assert.Throws<NotSupportedException>(() => column.CumulativeMax()); 303Assert.Throws<NotSupportedException>(() => column.CumulativeMin()); 304Assert.Throws<NotSupportedException>(() => column.CumulativeProduct()); 305Assert.Throws<NotSupportedException>(() => column.CumulativeSum()); 306Assert.Throws<NotSupportedException>(() => column.Max()); 307Assert.Throws<NotSupportedException>(() => column.Min()); 308Assert.Throws<NotSupportedException>(() => column.Product()); 309Assert.Throws<NotSupportedException>(() => column.Sum()); 314Assert.Throws<NotImplementedException>(() => column.CumulativeMax()); 315Assert.Throws<NotImplementedException>(() => column.CumulativeMin()); 316Assert.Throws<NotImplementedException>(() => column.CumulativeProduct()); 317Assert.Throws<NotImplementedException>(() => column.CumulativeSum()); 318Assert.Throws<NotImplementedException>(() => column.Max()); 319Assert.Throws<NotImplementedException>(() => column.Min()); 320Assert.Throws<NotImplementedException>(() => column.Product()); 321Assert.Throws<NotImplementedException>(() => column.Sum()); 326Assert.Throws<NotSupportedException>(() => column.CumulativeProduct()); 327Assert.Throws<NotSupportedException>(() => column.CumulativeSum()); 328Assert.Throws<NotSupportedException>(() => column.Product()); 329Assert.Throws<NotSupportedException>(() => column.Sum());
DataFrameTests.cs (25)
44Assert.Throws<ArgumentException>(() => dataFrame["Int5"]); 45Assert.Throws<ArgumentException>(() => dataFrame[(string)null]); 97Assert.Throws<ArgumentException>(() => dataFrame.Columns[1] = intColumnCopy); 191Assert.Throws<ArgumentException>(() => dataframe["City"]); 210Assert.Throws<ArgumentException>(() => dataframe["City"]); 720Assert.Throws<ArgumentException>(() => df.Sample(13)); 1171Assert.Throws<FormatException>(() => df.Append(new List<object> { 5, "str" }, inPlace: true)); 1172Assert.Throws<FormatException>(() => df.Append(new Dictionary<string, object> { { "Column2", "str" } }, inPlace: true)); 1173Assert.Throws<ArgumentException>(() => df.Append(new List<object> { 5, true, true }, inPlace: true)); 1282Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetPrimitiveColumn<float>("Int")); 1286Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetStringColumn("ArrowString")); 1290Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetArrowStringColumn("String")); 1294Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Byte")); 1298Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Int")); 1302Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Bool")); 1306Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Char")); 1310Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Decimal")); 1314Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Double")); 1318Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetDoubleColumn("Float")); 1322Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Long")); 1326Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Sbyte")); 1330Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Short")); 1334Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Uint")); 1338Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Ulong")); 1342Assert.Throws<ArgumentException>(() => dataFrame.Columns.GetSingleColumn("Ushort"));
PrimitiveDataFrameColumnTests.cs (1)
470Assert.Throws<IndexOutOfRangeException>(() => column.Clone(indicesMap));
TextFieldParserTests.cs (8)
36Assert.Throws<ObjectDisposedException>(() => stream.ReadByte()); 54Assert.Throws<ObjectDisposedException>(() => reader.ReadToEnd()); 193Assert.Throws<Exception>(() => parser.ReadFields()); 254Assert.Throws<ArgumentException>(() => parser.PeekChars(0)); 291Assert.Throws<InvalidOperationException>(() => parser.ReadFields()); 318Assert.Throws<Exception>(() => parser.ReadFields()); 367Assert.Throws<Exception>(() => parser.ReadFields()); 383Assert.Throws<Exception>(() => parser.ReadFields());
Microsoft.DotNet.Build.Tasks.VisualStudio.Tests (2)
OptProf\FindLatestDropTests.cs (1)
46Assert.Throws<ApplicationException>(() => FindLatestDrop.GetLatestDropName(json));
OptProf\GetRunSettingsSessionConfigurationTests.cs (1)
409Assert.Throws<InvalidDataException>(() => GetRunSettingsSessionConfiguration.GetTestsDropName(jsonString));
Microsoft.DotNet.Helix.JobSender.Tests (2)
Payloads\AdHocPayloadTests.cs (2)
16var exception = Assert.Throws<ArgumentException>(() => new AdhocPayload(new[] { "a/b.txt", "a/c.txt", "d/b.txt" })); 24var exception = Assert.Throws<ArgumentException>(() => new AdhocPayload(new[] { "a/B.txt", "a/c.txt", "d/b.txt" }));
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.AI.Abstractions.Tests (31)
ChatCompletion\ChatClientExtensionsTests.cs (5)
65Assert.Throws<InvalidOperationException>(() => client.GetRequiredService(typeof(object))); 66Assert.Throws<InvalidOperationException>(() => client.GetRequiredService<object>()); 67Assert.Throws<InvalidOperationException>(() => client.GetRequiredService(typeof(object), "key")); 68Assert.Throws<InvalidOperationException>(() => client.GetRequiredService<object>("key")); 69Assert.Throws<InvalidOperationException>(() => client.GetRequiredService<IChatClient>());
Contents\HostedFileContentTests.cs (6)
14Assert.Throws<ArgumentNullException>(() => new HostedFileContent(null!)); 15Assert.Throws<ArgumentException>(() => new HostedFileContent(string.Empty)); 16Assert.Throws<ArgumentException>(() => new HostedFileContent(" ")); 38Assert.Throws<ArgumentNullException>(() => c.FileId = null!); 39Assert.Throws<ArgumentException>(() => c.FileId = string.Empty); 40Assert.Throws<ArgumentException>(() => c.FileId = " ");
Contents\HostedVectorStoreContentTests.cs (6)
14Assert.Throws<ArgumentNullException>(() => new HostedVectorStoreContent(null!)); 15Assert.Throws<ArgumentException>(() => new HostedVectorStoreContent(string.Empty)); 16Assert.Throws<ArgumentException>(() => new HostedVectorStoreContent(" ")); 37Assert.Throws<ArgumentNullException>(() => c.VectorStoreId = null!); 38Assert.Throws<ArgumentException>(() => c.VectorStoreId = string.Empty); 39Assert.Throws<ArgumentException>(() => c.VectorStoreId = " ");
Contents\UriContentTests.cs (1)
17Assert.Throws<UriFormatException>(() => new UriContent("notauri", "image/png"));
Embeddings\EmbeddingGeneratorExtensionsTests.cs (5)
69Assert.Throws<InvalidOperationException>(() => generator.GetRequiredService(typeof(object))); 70Assert.Throws<InvalidOperationException>(() => generator.GetRequiredService<object>()); 72Assert.Throws<InvalidOperationException>(() => generator.GetRequiredService(typeof(object), "key")); 73Assert.Throws<InvalidOperationException>(() => generator.GetRequiredService<object>("key")); 75Assert.Throws<InvalidOperationException>(() => generator.GetRequiredService<int?>());
Utilities\AIJsonSchemaTransformCacheTests.cs (4)
15Assert.Throws<ArgumentNullException>(() => new AIJsonSchemaTransformCache(transformOptions: null!)); 21Assert.Throws<ArgumentException>(() => new AIJsonSchemaTransformCache(transformOptions: new())); 36Assert.Throws<ArgumentNullException>(() => cache.GetOrCreateTransformedSchema(function: null!)); 43Assert.Throws<ArgumentNullException>(() => cache.GetOrCreateTransformedSchema(responseFormat: null!));
Utilities\AIJsonUtilitiesTests.cs (4)
1025Assert.Throws<InvalidOperationException>(() => JsonSerializer.Serialize(c, options)); 1337Assert.Throws<ArgumentNullException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: null!)); 1338Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: new())); 1351Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions));
Microsoft.Extensions.AI.Tests (8)
ChatCompletion\ChatClientBuilderTest.cs (2)
77var ex = Assert.Throws<InvalidOperationException>(() => builder.Build()); 92Assert.Throws<InvalidOperationException>(() => keyedServiceProvider.GetRequiredKeyedService(typeof(object), "key"));
ChatCompletion\ReducingChatClientTests.cs (1)
128var exception = Assert.Throws<InvalidOperationException>(() =>
ChatReduction\MessageCountingChatReducerTests.cs (1)
21Assert.Throws<ArgumentOutOfRangeException>(() => new MessageCountingChatReducer(targetCount));
ChatReduction\SummarizingChatReducerTests.cs (3)
20Assert.Throws<ArgumentNullException>(() => new SummarizingChatReducer(null!, targetCount: 5, threshold: 2)); 30Assert.Throws<ArgumentOutOfRangeException>(() => new SummarizingChatReducer(chatClient, targetCount, threshold: 2)); 39Assert.Throws<ArgumentOutOfRangeException>(() => new SummarizingChatReducer(chatClient, targetCount: 5, thresholdCount));
Embeddings\EmbeddingGeneratorBuilderTests.cs (1)
77var ex = Assert.Throws<InvalidOperationException>(() => builder.Build());
Microsoft.Extensions.AmbientMetadata.Application.Tests (7)
ApplicationMetadataExtensionsTests.cs (7)
38Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddApplicationMetadata(config.GetSection(string.Empty))); 39Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddApplicationMetadata(_ => { })); 40Assert.Throws<ArgumentNullException>(() => serviceCollection.AddApplicationMetadata((Action<ApplicationMetadata>)null!)); 41Assert.Throws<ArgumentNullException>(() => serviceCollection.AddApplicationMetadata((IConfigurationSection)null!)); 42Assert.Throws<ArgumentNullException>(() => ((IHostBuilder)null!).UseApplicationMetadata(_fixture.Create<string>())); 43Assert.Throws<ArgumentNullException>(() => new ConfigurationBuilder().AddApplicationMetadata(null!)); 44Assert.Throws<ArgumentNullException>(() => ((IConfigurationBuilder)null!).AddApplicationMetadata(null!));
Microsoft.Extensions.AsyncState.Tests (1)
AsyncContextServiceCollectionExtensionsTests.cs (1)
16Assert.Throws<ArgumentNullException>(() => AsyncStateExtensions.AddAsyncState(null!));
Microsoft.Extensions.Caching.Hybrid.Tests (2)
StampedeTests.cs (2)
225var ex = Assert.Throws<OperationCanceledException>(() => result.GetAwaiter().GetResult()); 308var ex = Assert.Throws<OperationCanceledException>(() => result.GetAwaiter().GetResult());
Microsoft.Extensions.Compliance.Abstractions.Tests (3)
Redaction\NullRedactorTest.cs (1)
44Assert.Throws<ArgumentException>(() => r.Redact("ABCD".AsSpan(), new char[1].AsSpan()));
Redaction\RedactionAbstractionsExtensionsTest.cs (2)
17Assert.Throws<ArgumentNullException>(() => RedactionStringBuilderExtensions.AppendRedacted(null!, NullRedactor.Instance, s)); 18Assert.Throws<ArgumentNullException>(() => RedactionStringBuilderExtensions.AppendRedacted(new StringBuilder(), null!, ""));
Microsoft.Extensions.Compliance.Redaction.Tests (3)
HmacRedactorTest.cs (1)
87Assert.Throws<ArgumentException>(() => new HmacRedactor(Microsoft.Extensions.Options.Options.Create<HmacRedactorOptions>(null!)));
RedactionAcceptanceTests.cs (2)
56Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddRedaction(_ => { })); 57Assert.Throws<ArgumentNullException>(() => new ServiceCollection().AddRedaction(null!));
Microsoft.Extensions.Compliance.Testing.Tests (12)
FakeRedactorTests.cs (1)
36Assert.Throws<ArgumentException>(() => FakeRedactor.Create(new FakeRedactorOptions { RedactionFormat = "{{{{{23123{}}" }));
RedactionFakesAcceptanceTests.cs (8)
231Assert.Throws<ArgumentNullException>(() => ((IRedactionBuilder)null!).SetFakeRedactor(dc)); 232Assert.Throws<ArgumentNullException>(() => ((IRedactionBuilder)null!).SetFakeRedactor(Setup.GetFakesConfiguration(), dc)); 233Assert.Throws<ArgumentNullException>(() => ((IRedactionBuilder)null!).SetFakeRedactor(x => x.RedactionFormat = "2", dc)); 234Assert.Throws<ArgumentNullException>(() => new ServiceCollection().AddRedaction(x => x.SetFakeRedactor((Action<FakeRedactorOptions>)null!, dc))); 236Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddRedaction(x => x.SetFakeRedactor((Action<FakeRedactorOptions>)null!, dc))); 237Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddFakeRedaction()); 238Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddFakeRedaction(_ => { })); 239Assert.Throws<ArgumentNullException>(() => new ServiceCollection().AddFakeRedaction(null!));
RedactionFakesEventCollectorTests.cs (3)
18Assert.Throws<InvalidOperationException>(() => c.LastRedactorRequested); 19Assert.Throws<InvalidOperationException>(() => c.LastRedactedData); 27Assert.Throws<InvalidOperationException>(() => sp.GetFakeRedactionCollector());
Microsoft.Extensions.Configuration.KeyPerFile.Tests (1)
KeyPerFileTests.cs (1)
35var e = Assert.Throws<ArgumentException>(() => new ConfigurationBuilder().AddKeyPerFile("nonexistent", false).Build());
Microsoft.Extensions.Diagnostics.HealthChecks.Common.Tests (4)
ApplicationLifecycleHealthChecksExtensionsTests.cs (2)
49Assert.Throws<ArgumentNullException>(() => ((IHealthChecksBuilder)null!).AddApplicationLifecycleHealthCheck()); 50Assert.Throws<ArgumentNullException>(() => ((IHealthChecksBuilder)null!).AddApplicationLifecycleHealthCheck(null!));
ManualHealthCheckExtensionsTests.cs (2)
44Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddHealthChecks().AddManualHealthCheck()); 45Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddHealthChecks().AddManualHealthCheck(null!));
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (1)
DefaultHealthCheckServiceTest.cs (1)
47var exception = Assert.Throws<ArgumentException>(() => new DefaultHealthCheckService(scopeFactory, options, logger));
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (9)
ResourceMonitoringExtensionsTests.cs (4)
27Assert.Throws<ArgumentNullException>(() => ((IResourceMonitorBuilder)null!).ConfigureMonitor(_ => { })); 28Assert.Throws<ArgumentNullException>(() => ((IResourceMonitorBuilder)null!).ConfigureMonitor((IConfigurationSection)null!)); 29Assert.Throws<ArgumentNullException>(() => services.AddResourceMonitoring((b) => b.ConfigureMonitor((IConfigurationSection)null!))); 30Assert.Throws<ArgumentNullException>(() => services.AddResourceMonitoring((b) => b.ConfigureMonitor((Action<ResourceMonitoringOptions>)null!)));
ResourceUtilizationTests.cs (1)
33Assert.Throws<ArgumentOutOfRangeException>(() => new ResourceUtilization(-50.0, 500, _systemResources));
SystemResourcesTests.cs (4)
29Assert.Throws<ArgumentOutOfRangeException>(() => new SystemResources(0.0, 1.0, 1000UL, 1000UL)); 31Assert.Throws<ArgumentOutOfRangeException>(() => new SystemResources(1.0, 0.0, 1000UL, 1000UL)); 34Assert.Throws<ArgumentOutOfRangeException>(() => new SystemResources(1.0, 1.0, 0UL, 1000UL)); 36Assert.Throws<ArgumentOutOfRangeException>(() => new SystemResources(1.0, 1.0, 1000UL, 0UL));
Microsoft.Extensions.Diagnostics.Testing.Tests (16)
Logging\FakeLogCollectorTests.cs (2)
113Assert.Throws<ArgumentNullException>(() => new FakeLogCollector(null!)); 114Assert.Throws<ArgumentException>(() => new FakeLogCollector(Microsoft.Extensions.Options.Options.Create((FakeLogCollectorOptions)null!)));
Logging\FakeLoggerExtensionsTests.cs (1)
85Assert.Throws<InvalidOperationException>(() => serviceProvider.GetFakeLogCollector());
Logging\FakeLoggerTests.cs (1)
62Assert.Throws<InvalidOperationException>(() => logger.LatestRecord.Level);
Metrics\MetricCollectorTests.cs (12)
19Assert.Throws<ArgumentNullException>(() => new MetricCollector<long>((Instrument<long>)null!)); 20Assert.Throws<ArgumentNullException>(() => new MetricCollector<long>((ObservableInstrument<long>)null!)); 21Assert.Throws<ArgumentNullException>(() => new MetricCollector<long>(new Meter(Guid.NewGuid().ToString()), null!)); 22Assert.Throws<ArgumentNullException>(() => new MetricCollector<long>(null!, "Hello")); 23Assert.Throws<ArgumentNullException>(() => new MetricCollector<long>(null, null!, "Hello")); 25Assert.Throws<ArgumentException>(() => new MetricCollector<long>(new Meter(Guid.NewGuid().ToString()), string.Empty)); 26Assert.Throws<ArgumentException>(() => new MetricCollector<long>(null, string.Empty, "Hello")); 27Assert.Throws<ArgumentException>(() => new MetricCollector<long>(null, "Hello", string.Empty)); 36Assert.Throws<InvalidOperationException>(() => new MetricCollector<Guid>(meter, "Counter")); 37Assert.Throws<InvalidOperationException>(() => new MetricCollector<Guid>(null, meter.Name, "Counter")); 361Assert.Throws<ObjectDisposedException>(() => collector.GetMeasurementSnapshot()); 363Assert.Throws<ObjectDisposedException>(() => collector.LastMeasurement);
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 (3)
EmbeddedFileProviderTests.cs (1)
19Assert.Throws<ArgumentNullException>(() => new EmbeddedFileProvider(null));
Manifest\ManifestParserTests.cs (2)
52Assert.Throws<InvalidOperationException>(() => ManifestParser.Parse(assembly)); 63Assert.Throws<InvalidOperationException>(() => ManifestParser.Parse(assembly));
Microsoft.Extensions.Hosting.Testing.Tests (3)
FakeHostTests.cs (1)
36Assert.Throws<ObjectDisposedException>(() => host.Services.GetService<IHost>());
HostingFakesExtensionsTests.cs (2)
301Assert.Throws<ArgumentNullException>(() => FakeHost.CreateBuilder().AddFakeLoggingOutputSink(null!)); 307Assert.Throws<ArgumentNullException>(() => ((IHostBuilder)null!).AddFakeLoggingOutputSink(_ => { }));
Microsoft.Extensions.Http.Resilience.Tests (18)
Hedging\StandardHedgingTests.cs (5)
49Assert.Throws<OptionsValidationException>(CreateClientWithHandler); 57Assert.Throws<OptionsValidationException>(CreateClientWithHandler); 139Assert.Throws<InvalidOperationException>(() => 157Assert.Throws<ArgumentException>(() => 166Assert.Throws<ArgumentException>(() =>
Resilience\HttpClientBuilderExtensionsTests.BySelector.cs (1)
55Assert.Throws<InvalidOperationException>(() => provider(request));
Resilience\HttpClientBuilderExtensionsTests.Resilience.cs (9)
32Assert.Throws<ArgumentNullException>(() => builder.AddResilienceHandler(null!, _ => { })); 33Assert.Throws<ArgumentException>(() => builder.AddResilienceHandler(string.Empty, _ => { })); 34Assert.Throws<ArgumentNullException>(() => builder.AddResilienceHandler(null!, (_, _) => { })); 35Assert.Throws<ArgumentException>(() => builder.AddResilienceHandler(string.Empty, (_, _) => { })); 36Assert.Throws<ArgumentNullException>(() => builder.AddResilienceHandler("dummy", (Action<ResiliencePipelineBuilder<HttpResponseMessage>>)null!)); 37Assert.Throws<ArgumentNullException>(() => builder.AddResilienceHandler("dummy", (Action<ResiliencePipelineBuilder<HttpResponseMessage>, ResilienceHandlerContext>)null!)); 40Assert.Throws<ArgumentNullException>(() => builder!.AddResilienceHandler("pipeline-name", _ => { })); 41Assert.Throws<ArgumentNullException>(() => builder!.AddResilienceHandler("pipeline-name", (_, _) => { })); 295Assert.Throws<ArgumentNullException>(() => builder!.RemoveAllResilienceHandlers());
Resilience\HttpClientBuilderExtensionsTests.Standard.cs (2)
150Assert.Throws<InvalidOperationException>(() => HttpClientBuilderExtensionsTests.GetPipeline(builder.Services, "test-standard")); 197Assert.Throws<OptionsValidationException>(() => GetPipeline(builder.Services, "test-standard"));
Resilience\HttpResilienceContextExtensionsTests.cs (1)
18Assert.Throws<ArgumentNullException>(context.GetRequestMessage);
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.ML.Tests (4)
FileLoaderTests.cs (2)
35Assert.Throws<InvalidOperationException>(() => loaderUnderTest.GetModel()); 36Assert.Throws<InvalidOperationException>(() => loaderUnderTest.GetReloadToken());
UriLoaderTests.cs (2)
35Assert.Throws<InvalidOperationException>(() => loaderUnderTest.GetModel()); 36Assert.Throws<InvalidOperationException>(() => loaderUnderTest.GetReloadToken());
Microsoft.Extensions.ObjectPool.DependencyInjection.Tests (5)
DependencyInjectionExtensionsTests.cs (5)
19Assert.Throws<ArgumentNullException>(() => ObjectPoolServiceCollectionExtensions.AddPooled<TestClass>(null!)); 20Assert.Throws<ArgumentNullException>(() => ObjectPoolServiceCollectionExtensions.AddPooled<ITestClass, TestClass>(null!)); 33var exception = Assert.Throws<ArgumentException>( 81Assert.Throws<ArgumentNullException>(() => new ServiceCollection().ConfigurePools(null!)); 217Assert.Throws<InvalidOperationException>(() => provider.GetRequiredService<ObjectPool<ITestClass>>().Get());
Microsoft.Extensions.ObjectPool.Tests (1)
DisposableObjectPoolTest.cs (1)
107Assert.Throws<ObjectDisposedException>(() => pool.Get());
Microsoft.Extensions.Options.Contextual.Tests (1)
ContextualOptionsServiceCollectionExtensionsTests.cs (1)
20Assert.Throws<ArgumentNullException>(() => ((IServiceCollection)null!).AddContextualOptions());
Microsoft.Extensions.SecretManager.Tools.Tests (5)
MsBuildProjectFinderTest.cs (5)
36Assert.Throws<FileNotFoundException>(() => finder.FindMsBuildProject(null)); 48Assert.Throws<FileNotFoundException>(() => finder.FindMsBuildProject(null)); 61Assert.Throws<FileNotFoundException>(() => finder.FindMsBuildProject(null)); 72Assert.Throws<FileNotFoundException>(() => finder.FindMsBuildProject("test.csproj")); 82Assert.Throws<FileNotFoundException>(() => finder.FindMsBuildProject(null));
Microsoft.Extensions.Telemetry.Abstractions.Tests (18)
Enrichment\EnricherExtensionsTests.cs (3)
16Assert.Throws<ArgumentNullException>(() => new ServiceCollection().AddLogEnricher(null!)); 26Assert.Throws<ArgumentNullException>(() => 29Assert.Throws<ArgumentNullException>(() =>
Latency\LatencyRegistryExtensionsTests.cs (9)
16Assert.Throws<ArgumentNullException>( 18Assert.Throws<ArgumentNullException>( 20Assert.Throws<ArgumentNullException>( 22Assert.Throws<ArgumentNullException>( 24Assert.Throws<ArgumentNullException>( 26Assert.Throws<ArgumentNullException>( 33Assert.Throws<ArgumentException>(() => LatencyRegistryServiceCollectionExtensions.RegisterCheckpointNames(new ServiceCollection(), "")); 34Assert.Throws<ArgumentException>(() => LatencyRegistryServiceCollectionExtensions.RegisterMeasureNames(new ServiceCollection(), "")); 35Assert.Throws<ArgumentException>(() => LatencyRegistryServiceCollectionExtensions.RegisterTagNames(new ServiceCollection(), ""));
Latency\NoopLatencyContextTests.cs (1)
15Assert.Throws<ArgumentNullException>(() =>
Logging\TagNameAttributeTests.cs (1)
17Assert.Throws<ArgumentNullException>(() => new TagNameAttribute(null!));
Logging\TagProviderAttributeTests.cs (4)
26Assert.Throws<ArgumentNullException>(() => new TagProviderAttribute(null!, "test")); 27Assert.Throws<ArgumentNullException>(() => new TagProviderAttribute(typeof(object), null!)); 33Assert.Throws<ArgumentException>(() => new TagProviderAttribute(typeof(object), string.Empty)); 34Assert.Throws<ArgumentException>(() => new TagProviderAttribute(typeof(object), new string(' ', 3)));
Microsoft.Extensions.Telemetry.Tests (27)
Buffering\GlobalBufferLoggerBuilderExtensionsTests.cs (2)
39Assert.Throws<ArgumentNullException>(() => builder!.AddGlobalBuffer(LogLevel.Warning)); 40Assert.Throws<ArgumentNullException>(() => builder!.AddGlobalBuffer(configuration!));
Enrichment\ApplicationEnricherExtensionsTests.cs (4)
20Assert.Throws<ArgumentNullException>(() => 23Assert.Throws<ArgumentNullException>(() => 26Assert.Throws<ArgumentNullException>(() => 29Assert.Throws<ArgumentNullException>(() =>
Enrichment\ProcessEnricherExtensionsTests.cs (5)
20Assert.Throws<ArgumentNullException>(() => 23Assert.Throws<ArgumentNullException>(() => 26Assert.Throws<ArgumentNullException>(() => 29Assert.Throws<ArgumentNullException>(() => 32Assert.Throws<ArgumentNullException>(() =>
Latency\Internal\LatencyContextProviderTests.cs (3)
87Assert.Throws<ArgumentException>(() => tokenissuer.GetCheckpointToken("ca1")); 88Assert.Throws<ArgumentException>(() => tokenissuer.GetMeasureToken("ma1")); 89Assert.Throws<ArgumentException>(() => tokenissuer.GetTagToken("ta1"));
Latency\LatencyConsoleExtensionsTests.cs (3)
20Assert.Throws<ArgumentNullException>(() => LatencyConsoleExtensions.AddConsoleLatencyDataExporter(null!)); 21Assert.Throws<ArgumentNullException>(() => LatencyConsoleExtensions.AddConsoleLatencyDataExporter(s, configure: null!)); 22Assert.Throws<ArgumentNullException>(() => LatencyConsoleExtensions.AddConsoleLatencyDataExporter(s, section: null!));
Latency\LatencyContextExtensionTests.cs (1)
20Assert.Throws<ArgumentNullException>(() =>
Logging\ExtendedLoggerFactoryTests.cs (2)
42Assert.Throws<ObjectDisposedException>(() => factory.CreateLogger("d")); 238Assert.Throws<ArgumentException>(() =>
Sampling\SamplingLoggerBuilderExtensionsTests.cs (7)
166Assert.Throws<OptionsValidationException>(() => options?.CurrentValue.Rules); 183Assert.Throws<OptionsValidationException>(() => options?.CurrentValue.Rules); 206Assert.Throws<OptionsValidationException>(() => options?.CurrentValue.Rules); 270Assert.Throws<ArgumentNullException>(action); 273Assert.Throws<ArgumentNullException>(action); 276Assert.Throws<ArgumentNullException>(action); 279Assert.Throws<ArgumentNullException>(action);
Microsoft.Extensions.Validation.Tests (1)
RuntimeValidatableParameterInfoResolverTests.cs (1)
29var exception = Assert.Throws<InvalidOperationException>(() =>
Microsoft.JSInterop.Tests (26)
DotNetObjectReferenceTest.cs (2)
57var ex = Assert.Throws<InvalidOperationException>(() => jsRuntime2.TrackObjectReference(objRef)); 79Assert.Throws<ArgumentException>(() => jsRuntime.GetObjectReference(objectId));
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 (7)
170var ex = Assert.Throws<InvalidOperationException>(() => 239var ex = Assert.Throws<ArgumentException>( 258var ex = Assert.Throws<ArgumentException>( 543var ex = Assert.Throws<ArgumentException>(() => DotNetDispatcher.Invoke(jsRuntime, new DotNetInvocationInfo(thisAssemblyName, methodIdentifier, 0, default), "[7]")); 558var ex = Assert.Throws<ArgumentException>(() => DotNetDispatcher.Invoke(jsRuntime, new DotNetInvocationInfo(null, methodIdentifier, 1, default), argsJson)); 572Assert.Throws<JsonException>(() => 868var ex = Assert.Throws<InvalidOperationException>(() => DotNetDispatcher.ParseArguments(new TestJSRuntime(), method, arguments, new[] { typeof(int), typeof(TestDTO), }));
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)
66Assert.Throws<ObjectDisposedException>(() => jsObject.Invoke<object>("test", "arg1", "arg2"));
Microsoft.ML.AutoML.Tests (1)
ColumnInferenceTests.cs (1)
54Assert.Throws<ArgumentOutOfRangeException>(() => new MLContext(1).Auto().InferColumns(DatasetUtil.GetUciAdultDataset(), 100));
Microsoft.ML.OnnxTransformerTest (1)
OnnxTransformTests.cs (1)
417Assert.Throws<InvalidOperationException>(() => ML.Transforms.ApplyOnnxModel("softmaxout_1", "data_0", modelFile, gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu));
Microsoft.ML.Tests (23)
AnomalyDetectionTests.cs (1)
50Assert.Throws<ArgumentOutOfRangeException>(() => ML.AnomalyDetection.Evaluate(transformedData));
ImagesTests.cs (16)
1264Assert.Throws<ArgumentNullException>(() => MLImage.CreateFromFile(null)); 1265Assert.Throws<ArgumentException>(() => MLImage.CreateFromFile("This is Invalid Path")); 1266Assert.Throws<ArgumentNullException>(() => MLImage.CreateFromStream(null)); 1267Assert.Throws<ArgumentException>(() => MLImage.CreateFromStream(new MemoryStream(new byte[10]))); 1268Assert.Throws<ArgumentException>(() => MLImage.CreateFromPixels(10, 10, MLPixelFormat.Unknown, Array.Empty<byte>())); 1269Assert.Throws<ArgumentException>(() => MLImage.CreateFromPixels(10, 10, MLPixelFormat.Bgra32, Array.Empty<byte>())); 1270Assert.Throws<ArgumentException>(() => MLImage.CreateFromPixels(0, 10, MLPixelFormat.Bgra32, new byte[10])); 1271Assert.Throws<ArgumentException>(() => MLImage.CreateFromPixels(10, 0, MLPixelFormat.Bgra32, new byte[10])); 1272Assert.Throws<ArgumentException>(() => MLImage.CreateFromPixels(10, 10, MLPixelFormat.Bgra32, new byte[401])); 1319Assert.Throws<InvalidOperationException>(() => image.Tag); 1320Assert.Throws<InvalidOperationException>(() => image.Tag = "Something"); 1321Assert.Throws<InvalidOperationException>(() => image.Width); 1322Assert.Throws<InvalidOperationException>(() => image.Height); 1323Assert.Throws<InvalidOperationException>(() => image.PixelFormat); 1324Assert.Throws<InvalidOperationException>(() => image.BitsPerPixel); 1325Assert.Throws<InvalidOperationException>(() => image.Pixels[0]);
Scenarios\Api\TestApi.cs (1)
240Assert.Throws<ArgumentOutOfRangeException>(() => idv.Schema[1].Annotations.Schema[kindFloat]);
SvmLightTests.cs (3)
406ex = Assert.Throws<InvalidOperationException>(() => ML.Data.LoadFromSvmLightFile(path)); 443var ex = Assert.Throws<InvalidOperationException>(() => ML.Data.CreateSvmLightLoader()); 445ex = Assert.Throws<InvalidOperationException>(() => ML.Data.CreateSvmLightLoaderWithFeatureNames());
TextLoaderTests.cs (1)
584var ex = Assert.Throws<ArgumentOutOfRangeException>(() => mlContext.Data.LoadFromTextFile<ModelWithoutColumnAttribute>("fakefile.txt"));
Transformers\SelectColumnsTests.cs (1)
125Assert.Throws<ArgumentOutOfRangeException>(() => est.Fit(dataView));
Microsoft.ML.Tokenizers.Tests (13)
LlamaTests.cs (1)
347Assert.Throws<ArgumentNullException>(() => llamaTokenizer.Decode(null!));
TiktokenTests.cs (7)
523Assert.Throws<ArgumentNullException>(() => TiktokenTokenizer.CreateForEncoding(null!)); 524Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("r50k_base_")); 525Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("p50k_base_")); 526Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("p50k_edit_")); 527Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("cl100k_base_")); 528Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("o200k_base_")); 529Assert.Throws<ArgumentException>(() => TiktokenTokenizer.CreateForEncoding("o200k_harmony_"));
TokenizerTests.cs (5)
28Assert.Throws<InvalidOperationException>(() => tokenizer.Decode([26, 27, 28, 29])); 221Assert.Throws<ArgumentOutOfRangeException>(() => tokenizer.GetIndexByTokenCount(input, maxTokenCount: 0, out _, out _)); 222Assert.Throws<ArgumentOutOfRangeException>(() => tokenizer.GetIndexByTokenCount(input, maxTokenCount: -1, out _, out _)); 223Assert.Throws<ArgumentOutOfRangeException>(() => tokenizer.GetIndexByTokenCountFromEnd(input, maxTokenCount: 0, out _, out _)); 224Assert.Throws<ArgumentOutOfRangeException>(() => tokenizer.GetIndexByTokenCountFromEnd(input, maxTokenCount: -1, out _, out _));
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)
166Assert.Throws<ArgumentNullException>(() => new CookieHeaderValue(null, "value")); 173Assert.Throws<ArgumentException>(() => new CookieHeaderValue(name, "value")); 180Assert.Throws<ArgumentException>(() => new CookieHeaderValue("name", value)); 243Assert.Throws<FormatException>(() => CookieHeaderValue.Parse(value)); 317Assert.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));
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (70)
CodeModel\FileCodeClassTests.cs (11)
110Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributes)); 139Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 157Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 164Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartName)); 182Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartWhole)); 200Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributes)); 229Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 237Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeader)); 244Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 251Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartName)); 269Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartWhole));
CodeModel\FileCodeFunctionTests.cs (14)
265Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributes)); 272Assert.Throws<COMException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 290Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 308Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 315Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartName)); 344Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartWhole)); 362Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributes)); 369Assert.Throws<COMException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 387Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 394Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeader)); 401Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 408Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartName)); 426Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartWhole)); 508Assert.Throws<COMException>(() =>
CodeModel\FileCodeImportTests.cs (16)
75Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartAttributes)); 82Assert.Throws<COMException>(() => import.GetStartPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 89Assert.Throws<COMException>(() => import.GetStartPoint(vsCMPart.vsCMPartBody)); 96Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 103Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartHeader)); 110Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 117Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartName)); 134Assert.Throws<NotImplementedException>(() => import.GetStartPoint(vsCMPart.vsCMPartWhole)); 151Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartAttributes)); 158Assert.Throws<COMException>(() => import.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 165Assert.Throws<COMException>(() => import.GetEndPoint(vsCMPart.vsCMPartBody)); 172Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 179Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartHeader)); 186Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 193Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartName)); 211Assert.Throws<NotImplementedException>(() => import.GetEndPoint(vsCMPart.vsCMPartWhole));
CodeModel\FileCodeNamespaceTests.cs (14)
110Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributes)); 117Assert.Throws<COMException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 135Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 142Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeader)); 149Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 156Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartName)); 174Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartWhole)); 191Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributes)); 198Assert.Throws<COMException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributesWithDelimiter)); 216Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 223Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeader)); 230Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 237Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartName)); 255Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartWhole));
CodeModel\FileCodeVariableTests.cs (14)
194Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartAttributes)); 212Assert.Throws<COMException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBody)); 219Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 226Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeader)); 233Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 240Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartName)); 258Assert.Throws<NotImplementedException>(() => testObject.GetStartPoint(vsCMPart.vsCMPartWhole)); 276Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartAttributes)); 294Assert.Throws<COMException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartBody)); 301Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartBodyWithDelimiter)); 308Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeader)); 315Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartHeaderWithAttributes)); 322Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartName)); 340Assert.Throws<NotImplementedException>(() => testObject.GetEndPoint(vsCMPart.vsCMPartWhole));
ProjectSystemShim\VisualStudioCompilationOutputFilesTests.cs (1)
22=> Assert.Throws<ArgumentException>(() => new CompilationOutputFilesWithImplicitPdbPath(@"a.dll"));
Shared.Tests (17)
Data.Validation\LengthAttributeTests.cs (5)
343Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options0, context, results, true)); 348Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options1, context, results, true)); 353Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options2, context, results, true)); 358Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options3, context, results, true)); 363Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options4, context, results, true));
Data.Validation\TimeSpanAttributeTests.cs (3)
230Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options0, context, results, true)); 235Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options1, context, results, true)); 240Assert.Throws<InvalidOperationException>(() => _ = Validator.TryValidateObject(options3, context, results, true));
EmptyCollections\EmptyReadonlyDictionaryTests.cs (2)
46Assert.Throws<KeyNotFoundException>(() => dict[1]); 47Assert.Throws<NotSupportedException>(() => dict[1] = "One");
EmptyCollections\EmptyReadOnlyListTests.cs (1)
49Assert.Throws<InvalidOperationException>(() => ((IEnumerator)enumerator).Current);
JsonSchemaExporter\JsonSchemaExporterTests.cs (6)
141Assert.Throws<ArgumentNullException>(() => ((JsonSerializerOptions)null!).GetJsonSchemaAsNode(typeof(int))); 142Assert.Throws<ArgumentNullException>(() => Options.GetJsonSchemaAsNode(type: null!)); 143Assert.Throws<ArgumentNullException>(() => ((JsonTypeInfo)null!).GetJsonSchemaAsNode()); 150Assert.Throws<InvalidOperationException>(() => options.GetJsonSchemaAsNode(typeof(int))); 157var ex = Assert.Throws<InvalidOperationException>(() => options.GetJsonSchemaAsNode(typeof(TestTypes.SimplePoco))); 167var ex = Assert.Throws<NotSupportedException>(() => options.GetJsonSchemaAsNode(typeof(TestTypes.SimplePoco)));
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)
782Assert.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)
79Assert.Throws<PlatformNotSupportedException>(() => channel.Echo("hello")); 109Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferPoolSize = value); 129Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxBufferSize = value); 149Assert.Throws<ArgumentOutOfRangeException>(() => binding.MaxReceivedMessageSize = value); 167Assert.Throws<ArgumentException>(() => binding.Name = value); 186Assert.Throws<ArgumentNullException>(() => binding.Namespace = value); 207Assert.Throws<ArgumentNullException>(() => binding.ReaderQuotas = null); 224Assert.Throws<ArgumentOutOfRangeException>(() => binding.CloseTimeout = timeSpan); 241Assert.Throws<ArgumentOutOfRangeException>(() => binding.OpenTimeout = timeSpan); 258Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 275Assert.Throws<ArgumentOutOfRangeException>(() => binding.SendTimeout = timeSpan); 292Assert.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);
xunit.assert (1)
ExceptionAsserts.cs (1)
166 var ex = Throws<T>(testCode);