459 references to Throws
Microsoft.AspNetCore.Http.Results.Tests (40)
ResultsTests.cs (17)
344Assert.Throws<ArgumentNullException>("contents", () => Results.Bytes(null));
350Assert.Throws<ArgumentNullException>("fileContents", () => Results.File(default(byte[])));
356Assert.Throws<ArgumentNullException>("fileStream", () => Results.File(default(Stream)));
362Assert.Throws<ArgumentNullException>("stream", () => Results.Stream(default(Stream)));
368Assert.Throws<ArgumentNullException>("pipeReader", () => Results.Stream(default(PipeReader)));
374Assert.Throws<ArgumentNullException>("streamWriterCallback", () => TypedResults.Stream(default(Func<Stream, Task>)));
478Assert.Throws<ArgumentNullException>("principal", () => Results.SignIn(null));
1039Assert.Throws<ArgumentNullException>("context", () => Results.Json<object>(null, context: null));
1045Assert.Throws<ArgumentNullException>("context", () => Results.Json(null, type: typeof(object), context: null));
1065Assert.Throws<ArgumentNullException>("jsonTypeInfo", () => Results.Json(null, jsonTypeInfo: null));
1071Assert.Throws<ArgumentNullException>("jsonTypeInfo", () => Results.Json<object>(null, jsonTypeInfo: null));
1077Assert.Throws<ArgumentNullException>("localUrl", () => Results.LocalRedirect(default(string)));
1083Assert.Throws<ArgumentException>("localUrl", () => Results.LocalRedirect(string.Empty));
1244Assert.Throws<ArgumentNullException>("problemDetails", () => Results.Problem(default(ProblemDetails)));
1392Assert.Throws<ArgumentNullException>("errors", () => Results.ValidationProblem(default(IDictionary<string, string[]>)));
1460Assert.Throws<ArgumentNullException>("url", () => Results.Redirect(default(string)));
1466Assert.Throws<ArgumentException>("url", () => Results.Redirect(string.Empty));
TypedResultsTests.cs (21)
99Assert.Throws<ArgumentNullException>("uri", () => TypedResults.Accepted(default(Uri)));
105Assert.Throws<ArgumentNullException>("uri", () => TypedResults.Accepted(default(Uri), default(object)));
318Assert.Throws<ArgumentNullException>("contents", () => TypedResults.Bytes(null));
324Assert.Throws<ArgumentNullException>("fileContents", () => TypedResults.File(default(byte[])));
330Assert.Throws<ArgumentNullException>("fileStream", () => TypedResults.File(default(Stream)));
336Assert.Throws<ArgumentNullException>("stream", () => TypedResults.Stream(default(Stream)));
342Assert.Throws<ArgumentNullException>("pipeReader", () => TypedResults.Stream(default(PipeReader)));
348Assert.Throws<ArgumentNullException>("streamWriterCallback", () => TypedResults.Stream(default(Func<Stream, Task>)));
354Assert.Throws<ArgumentNullException>("path", () => TypedResults.PhysicalFile(default(string)));
360Assert.Throws<ArgumentException>("path", () => TypedResults.PhysicalFile(string.Empty));
366Assert.Throws<ArgumentNullException>("path", () => TypedResults.VirtualFile(default(string)));
372Assert.Throws<ArgumentException>("path", () => TypedResults.VirtualFile(string.Empty));
488Assert.Throws<ArgumentNullException>("principal", () => TypedResults.SignIn(null));
899Assert.Throws<ArgumentNullException>("context", () => TypedResults.Json(data, context: null));
915Assert.Throws<ArgumentNullException>("jsonTypeInfo", () => TypedResults.Json(data, jsonTypeInfo: null));
921Assert.Throws<ArgumentNullException>("localUrl", () => TypedResults.LocalRedirect(default(string)));
927Assert.Throws<ArgumentException>("localUrl", () => TypedResults.LocalRedirect(string.Empty));
1060Assert.Throws<ArgumentNullException>("problemDetails", () => TypedResults.Problem(default(ProblemDetails)));
1184Assert.Throws<ArgumentNullException>("errors", () => TypedResults.ValidationProblem(default(IDictionary<string, string[]>)));
1242Assert.Throws<ArgumentNullException>("url", () => TypedResults.Redirect(default(string)));
1248Assert.Throws<ArgumentException>("url", () => TypedResults.Redirect(string.Empty));
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
Microsoft.AspNetCore.Identity.Test (6)
SignInManagerTest.cs (3)
28Assert.Throws<ArgumentNullException>("userManager", () => new SignInManager<PocoUser>(null, null, null, null, null, null, null));
30Assert.Throws<ArgumentNullException>("contextAccessor", () => new SignInManager<PocoUser>(userManager, null, null, null, null, null, null));
34Assert.Throws<ArgumentNullException>("claimsFactory", () => new SignInManager<PocoUser>(userManager, contextAccessor.Object, null, null, null, null, null));
Microsoft.AspNetCore.Mvc.Core.Test (4)
Microsoft.AspNetCore.Razor.Test (2)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (6)
RequestBodyTests.cs (6)
129Assert.Throws<ArgumentNullException>("buffer", () => httpContext.Request.Body.Read(null, 0, 1));
130Assert.Throws<ArgumentOutOfRangeException>("offset", () => httpContext.Request.Body.Read(input, -1, 1));
131Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, input.Length + 1, 1));
132Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 10, -1));
133Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 1, input.Length));
134Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 0, input.Length + 1));
Microsoft.AspNetCore.WebUtilities.Tests (1)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (32)
Compilation\CompilationAPITests.cs (27)
445Assert.Throws<ArgumentNullException>("peStream", () => comp.Emit(peStream: null));
446Assert.Throws<ArgumentException>("peStream", () => comp.Emit(peStream: new TestStream(canRead: true, canWrite: false, canSeek: true)));
447Assert.Throws<ArgumentException>("pdbStream", () => comp.Emit(peStream: new MemoryStream(), pdbStream: new TestStream(canRead: true, canWrite: false, canSeek: true)));
448Assert.Throws<ArgumentException>("pdbStream", () => comp.Emit(peStream: new MemoryStream(), pdbStream: new MemoryStream(), options: EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded)));
450Assert.Throws<ArgumentException>("sourceLinkStream", () => comp.Emit(
456Assert.Throws<ArgumentException>("embeddedTexts", () => comp.Emit(
462Assert.Throws<ArgumentException>("embeddedTexts", () => comp.Emit(
468Assert.Throws<ArgumentException>("win32Resources", () => comp.Emit(
472Assert.Throws<ArgumentException>("win32Resources", () => comp.Emit(
2792Assert.Throws<ArgumentException>("name", () =>
2796Assert.Throws<ArgumentException>("name", () =>
2800Assert.Throws<ArgumentException>(null, () =>
2804Assert.Throws<ArgumentException>(null, () =>
2808Assert.Throws<ArgumentException>(null, () =>
2817Assert.Throws<ArgumentNullException>("returnType", () => compilation.CreateBuiltinOperator(
2819Assert.Throws<ArgumentNullException>("leftType", () => compilation.CreateBuiltinOperator(
2821Assert.Throws<ArgumentNullException>("rightType", () => compilation.CreateBuiltinOperator(
2960Assert.Throws<ArgumentException>(null, () => compilation.CreateBuiltinOperator(
2982Assert.Throws<ArgumentException>("name", () =>
2986Assert.Throws<ArgumentException>(null, () =>
2990Assert.Throws<ArgumentException>(null, () =>
2994Assert.Throws<ArgumentException>("name", () =>
2998Assert.Throws<ArgumentException>("name", () =>
3002Assert.Throws<ArgumentException>("name", () =>
3006Assert.Throws<ArgumentException>("name", () =>
3015Assert.Throws<ArgumentNullException>("returnType", () => compilation.CreateBuiltinOperator(
3017Assert.Throws<ArgumentNullException>("operandType", () => compilation.CreateBuiltinOperator(
Symbols\FunctionPointerTypeSymbolTests.cs (5)
1534Assert.Throws<ArgumentNullException>("returnType", () => comp.CreateFunctionPointerTypeSymbol(returnType: null!, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1535Assert.Throws<ArgumentNullException>("parameterTypes", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: default, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1536Assert.Throws<ArgumentNullException>("parameterTypes[0]", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray.Create((ITypeSymbol?)null)!, parameterRefKinds: ImmutableArray.Create(RefKind.None)));
1537Assert.Throws<ArgumentNullException>("parameterRefKinds", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: default));
1538Assert.Throws<ArgumentNullException>("callingConventionTypes[0]", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Unmanaged, ImmutableArray.Create((INamedTypeSymbol)null!)));
Microsoft.CodeAnalysis.Scripting.UnitTests (39)
ScriptOptionsTests.cs (39)
41Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((MetadataReference[])null));
42Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences(new MetadataReference[] { null }));
44Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((IEnumerable<MetadataReference>)null));
45Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences((IEnumerable<MetadataReference>)new MetadataReference[] { null }));
47Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((Assembly[])null));
48Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences(new Assembly[] { null }));
50Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((IEnumerable<Assembly>)null));
51Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences((IEnumerable<Assembly>)new Assembly[] { null }));
53Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((string[])null));
54Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences(new string[] { null }));
56Assert.Throws<ArgumentNullException>("references", () => options.AddReferences((IEnumerable<string>)null));
57Assert.Throws<ArgumentNullException>("references[0]", () => options.AddReferences((IEnumerable<string>)new string[] { null }));
83Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((MetadataReference[])null));
84Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((IEnumerable<MetadataReference>)null));
85Assert.Throws<ArgumentNullException>("references", () => options.WithReferences(default(ImmutableArray<MetadataReference>)));
86Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(new MetadataReference[] { null }));
87Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(ImmutableArray.Create((MetadataReference)null)));
89Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((Assembly[])null));
90Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((IEnumerable<Assembly>)null));
91Assert.Throws<ArgumentNullException>("references", () => options.WithReferences(default(ImmutableArray<Assembly>)));
92Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(new Assembly[] { null }));
93Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(ImmutableArray.Create((Assembly)null)));
95Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((string[])null));
96Assert.Throws<ArgumentNullException>("references", () => options.WithReferences((IEnumerable<string>)null));
97Assert.Throws<ArgumentNullException>("references", () => options.WithReferences(default(ImmutableArray<string>)));
98Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(new string[] { null }));
99Assert.Throws<ArgumentNullException>("references[0]", () => options.WithReferences(ImmutableArray.Create((string)null)));
122Assert.Throws<ArgumentNullException>("imports", () => options.AddImports((string[])null));
123Assert.Throws<ArgumentNullException>("imports[0]", () => options.AddImports([null]));
125Assert.Throws<ArgumentNullException>("imports", () => options.AddImports((IEnumerable<string>)null));
126Assert.Throws<ArgumentNullException>("imports[0]", () => options.AddImports((IEnumerable<string>)new string[] { null }));
128Assert.Throws<ArgumentNullException>("imports", () => options.AddImports(default(ImmutableArray<string>)));
129Assert.Throws<ArgumentNullException>("imports[0]", () => options.AddImports(ImmutableArray.Create((string)null)));
143Assert.Throws<ArgumentNullException>("imports", () => options.WithImports((string[])null));
144Assert.Throws<ArgumentNullException>("imports[0]", () => options.WithImports([null]));
146Assert.Throws<ArgumentNullException>("imports", () => options.WithImports((IEnumerable<string>)null));
147Assert.Throws<ArgumentNullException>("imports[0]", () => options.WithImports((IEnumerable<string>)new string[] { null }));
149Assert.Throws<ArgumentNullException>("imports", () => options.WithImports(default(ImmutableArray<string>)));
150Assert.Throws<ArgumentNullException>("imports[0]", () => options.WithImports(ImmutableArray.Create((string)null)));
Microsoft.CodeAnalysis.Test.Utilities (4)
Microsoft.CodeAnalysis.UnitTests (93)
Collections\ImmutableSegmentedDictionaryTest.cs (5)
150Assert.Throws<ArgumentNullException>("keySelector", () => list.ToImmutableSegmentedDictionary<int, int>(null!));
151Assert.Throws<ArgumentNullException>("keySelector", () => list.ToImmutableSegmentedDictionary<int, int, int>(null!, v => v));
152Assert.Throws<ArgumentNullException>("elementSelector", () => list.ToImmutableSegmentedDictionary<int, int, int>(k => k, null!));
201Assert.Throws<ArgumentException>(null, () => map.WithComparer(StringComparer.OrdinalIgnoreCase));
209var exception = Assert.Throws<ArgumentException>(null, () => map.Add("firstKey", "3"));
Collections\ImmutableSegmentedListTest.cs (28)
246Assert.Throws<ArgumentOutOfRangeException>("index", () => list.Insert(1, 5));
247Assert.Throws<ArgumentOutOfRangeException>("index", () => list.Insert(-1, 5));
262Assert.Throws<ArgumentOutOfRangeException>("index", () => list.Insert(7, 5));
263Assert.Throws<ArgumentOutOfRangeException>("index", () => list.Insert(-1, 5));
279Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(1, new[] { 1 }));
280Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(-1, new[] { 1 }));
287Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(6, new[] { 1 }));
288Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(-1, new[] { 1 }));
296Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(1, nonEmptyList));
297Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(-1, nonEmptyList));
305Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(106, nonEmptyList));
306Assert.Throws<ArgumentOutOfRangeException>("index", () => list.InsertRange(-1, nonEmptyList));
423Assert.Throws<ArgumentOutOfRangeException>("index", () => list.RemoveAt(0));
424Assert.Throws<ArgumentOutOfRangeException>("index", () => list.RemoveAt(-1));
425Assert.Throws<ArgumentOutOfRangeException>("index", () => list.RemoveAt(1));
478Assert.Throws<ArgumentOutOfRangeException>("index", () => list[3]);
479Assert.Throws<ArgumentOutOfRangeException>("index", () => list[-1]);
562Assert.Throws<ArgumentException>("oldValue", () => ImmutableSegmentedList<int>.Empty.Replace(5, 3));
612Assert.Throws<ArgumentNullException>("match", () => ImmutableSegmentedList<int>.Empty.RemoveAll(null!));
621Assert.Throws<ArgumentOutOfRangeException>("index", () => list.RemoveRange(-1, 0));
622Assert.Throws<ArgumentOutOfRangeException>("count", () => list.RemoveRange(0, -1));
642Assert.Throws<ArgumentNullException>("items", () => list.RemoveRange(null!));
660Assert.Throws<ArgumentNullException>("items", () => System.Collections.Immutable.ImmutableList.RemoveRange((System.Collections.Immutable.IImmutableList<int>)ImmutableSegmentedList.Create(1, 2, 3), null!));
725Assert.Throws<ArgumentOutOfRangeException>("index", () => emptyList[-1]);
726Assert.Throws<ArgumentOutOfRangeException>("index", () => emptyList[0]);
727Assert.Throws<ArgumentOutOfRangeException>("index", () => emptyList[1]);
730Assert.Throws<ArgumentOutOfRangeException>("index", () => listOfOne[-1]);
732Assert.Throws<ArgumentOutOfRangeException>("index", () => listOfOne[1]);
EmbeddedTextTests.cs (16)
25Assert.Throws<ArgumentNullException>("filePath", () => EmbeddedText.FromBytes(null, default(ArraySegment<byte>)));
26Assert.Throws<ArgumentException>("filePath", () => EmbeddedText.FromBytes("", default(ArraySegment<byte>)));
27Assert.Throws<ArgumentNullException>("bytes", () => EmbeddedText.FromBytes("path", default(ArraySegment<byte>)));
28Assert.Throws<ArgumentException>("checksumAlgorithm", () => EmbeddedText.FromBytes("path", new ArraySegment<byte>(new byte[0], 0, 0), SourceHashAlgorithm.None));
34Assert.Throws<ArgumentNullException>("filePath", () => EmbeddedText.FromSource(null, null));
35Assert.Throws<ArgumentException>("filePath", () => EmbeddedText.FromSource("", null));
36Assert.Throws<ArgumentNullException>("text", () => EmbeddedText.FromSource("path", null));
39Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From("source")));
42Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new byte[0], 0, Encoding.UTF8, canBeEmbedded: false)));
43Assert.Throws<ArgumentException>("text", () => EmbeddedText.FromSource("path", SourceText.From(new MemoryStream(new byte[0]), Encoding.UTF8, canBeEmbedded: false)));
49Assert.Throws<ArgumentNullException>("filePath", () => EmbeddedText.FromStream(null, null));
50Assert.Throws<ArgumentException>("filePath", () => EmbeddedText.FromStream("", null));
51Assert.Throws<ArgumentNullException>("stream", () => EmbeddedText.FromStream("path", null));
52Assert.Throws<ArgumentException>("stream", () => EmbeddedText.FromStream("path", new CannotReadStream()));
53Assert.Throws<ArgumentException>("stream", () => EmbeddedText.FromStream("path", new CannotSeekStream()));
54Assert.Throws<ArgumentException>("checksumAlgorithm", () => EmbeddedText.FromStream("path", new MemoryStream(), SourceHashAlgorithm.None));
Emit\SemanticEditTests.cs (13)
29Assert.Throws<ArgumentOutOfRangeException>("kind", () => new SemanticEdit(SemanticEditKind.None, oldSymbol: null, newSymbol: null));
31Assert.Throws<ArgumentNullException>("oldSymbol", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: null, newSymbol: type));
32Assert.Throws<ArgumentNullException>("oldSymbol", () => new SemanticEdit(SemanticEditKind.Delete, oldSymbol: null, newSymbol: type));
34Assert.Throws<ArgumentNullException>("newSymbol", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: type, newSymbol: null));
35Assert.Throws<ArgumentNullException>("newSymbol", () => new SemanticEdit(SemanticEditKind.Insert, oldSymbol: type, newSymbol: null));
36Assert.Throws<ArgumentNullException>("newSymbol", () => new SemanticEdit(SemanticEditKind.Replace, oldSymbol: type, newSymbol: null));
39Assert.Throws<ArgumentOutOfRangeException>("kind", () => new SemanticEdit(SemanticEditKind.Replace, oldSymbol: method, newSymbol: method, instrumentation: instrumentation));
40Assert.Throws<ArgumentOutOfRangeException>("kind", () => new SemanticEdit(SemanticEditKind.Insert, oldSymbol: method, newSymbol: method, instrumentation: instrumentation));
41Assert.Throws<ArgumentOutOfRangeException>("kind", () => new SemanticEdit(SemanticEditKind.Delete, oldSymbol: method, newSymbol: method, instrumentation: instrumentation));
43Assert.Throws<ArgumentException>("oldSymbol", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: type, newSymbol: method, instrumentation: instrumentation));
44Assert.Throws<ArgumentException>("newSymbol", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: method, newSymbol: type, instrumentation: instrumentation));
46Assert.Throws<ArgumentOutOfRangeException>("Kinds", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: method, newSymbol: method,
49Assert.Throws<ArgumentOutOfRangeException>("Kinds", () => new SemanticEdit(SemanticEditKind.Update, oldSymbol: method, newSymbol: method,
Microsoft.CodeAnalysis.Workspaces.UnitTests (73)
Simplifier\SimplifierTests.cs (6)
49Assert.Throws<ArgumentNullException>("node", () => Simplifier.Expand<SyntaxNode>(node: null!, semanticModel: null!, services: null!));
50Assert.Throws<ArgumentNullException>("semanticModel", () => Simplifier.Expand(node, semanticModel: null!, services: null!));
51Assert.Throws<ArgumentNullException>("services", () => Simplifier.Expand(node, semanticModel, services: null!));
52Assert.Throws<ArgumentNullException>("workspace", () => Simplifier.Expand(node, semanticModel, workspace: null!));
53Assert.Throws<ArgumentNullException>("workspace", () => Simplifier.Expand(token: default, semanticModel: null!, workspace: null!));
54Assert.Throws<ArgumentNullException>("workspace", () => Simplifier.Expand(token: default, semanticModel, workspace: null!));
SolutionTests\ProjectInfoTests.cs (6)
39Assert.Throws<ArgumentException>("documents[1]",
45Assert.Throws<ArgumentException>("additionalDocuments[1]",
52Assert.Throws<ArgumentException>("projectReferences[1]",
55Assert.Throws<ArgumentNullException>("analyzerReferences[0]", () => ProjectInfo.Create(pid, VersionStamp.Default, name: "Goo", assemblyName: "Bar", language: "C#",
59Assert.Throws<ArgumentException>("analyzerReferences[1]",
66Assert.Throws<ArgumentException>("metadataReferences[1]",
SolutionTests\SolutionTests.cs (52)
1447Assert.Throws<ArgumentNullException>("assemblyName", () => solution.WithProjectAssemblyName(projectId, null!));
1448Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectAssemblyName(null!, "x.dll"));
1471Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectOutputFilePath(null!, "x.dll"));
1472Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectOutputFilePath(null!, "x.dll"));
1526Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectOutputRefFilePath(null!, "x.dll"));
1549Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectCompilationOutputInfo(null!, info));
1572Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectDefaultNamespace(null!, "x"));
1685Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectName(null!, "x"));
1708Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectFilePath(null!, "x"));
1723Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectCompilationOptions(null!, options));
1724Assert.Throws<ArgumentNullException>("options", () => solution.WithProjectCompilationOptions(projectId, options: null!));
1772Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectParseOptions(null!, options));
1773Assert.Throws<ArgumentNullException>("options", () => solution.WithProjectParseOptions(projectId, options: null!));
1935Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectReferences(null!, [projectRef]));
1987Assert.Throws<ArgumentNullException>("projectId", () => solution.AddProjectReferences(null!, [projectRef2]));
1988Assert.Throws<ArgumentNullException>("projectReferences", () => solution.AddProjectReferences(projectId, null!));
1989Assert.Throws<ArgumentNullException>("projectReferences[0]", () => solution.AddProjectReferences(projectId, [null!]));
1990Assert.Throws<ArgumentException>("projectReferences[1]", () => solution.AddProjectReferences(projectId, [projectRef2, projectRef2]));
1991Assert.Throws<ArgumentException>("projectReferences[1]", () => solution.AddProjectReferences(projectId, [new ProjectReference(projectId2), new ProjectReference(projectId2)]));
2026Assert.Throws<ArgumentNullException>("projectId", () => solution.RemoveProjectReference(null!, projectRef2));
2027Assert.Throws<ArgumentNullException>("projectReference", () => solution.RemoveProjectReference(projectId, null!));
2030Assert.Throws<ArgumentException>("projectReference", () => solution.RemoveProjectReference(projectId, new ProjectReference(ProjectId.CreateNewId())));
2086Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectMetadataReferences(null!, [metadataRef]));
2106Assert.Throws<ArgumentNullException>("projectId", () => solution.AddMetadataReferences(null!, [metadataRef1]));
2107Assert.Throws<ArgumentNullException>("metadataReferences", () => solution.AddMetadataReferences(projectId, null!));
2108Assert.Throws<ArgumentNullException>("metadataReferences[0]", () => solution.AddMetadataReferences(projectId, [null!]));
2109Assert.Throws<ArgumentException>("metadataReferences[1]", () => solution.AddMetadataReferences(projectId, [metadataRef1, metadataRef1]));
2132Assert.Throws<ArgumentNullException>("projectId", () => solution.RemoveMetadataReference(null!, metadataRef1));
2133Assert.Throws<ArgumentNullException>("metadataReference", () => solution.RemoveMetadataReference(projectId, null!));
2156Assert.Throws<ArgumentNullException>("projectId", () => solution.WithProjectAnalyzerReferences(null!, [analyzerRef]));
2179Assert.Throws<ArgumentNullException>("projectId", () => solution.AddAnalyzerReferences(null!, [analyzerRef1]));
2180Assert.Throws<ArgumentNullException>("analyzerReferences", () => solution.AddAnalyzerReferences(projectId, null!));
2181Assert.Throws<ArgumentNullException>("analyzerReferences[0]", () => solution.AddAnalyzerReferences(projectId, [null!]));
2182Assert.Throws<ArgumentException>("analyzerReferences[1]", () => solution.AddAnalyzerReferences(projectId, [analyzerRef1, analyzerRef1]));
2205Assert.Throws<ArgumentNullException>("projectId", () => solution.RemoveAnalyzerReference(null!, analyzerRef1));
2206Assert.Throws<ArgumentNullException>("analyzerReference", () => solution.RemoveAnalyzerReference(projectId, null!));
2247Assert.Throws<ArgumentNullException>("analyzerReferences", () => solution.AddAnalyzerReferences(null!));
2248Assert.Throws<ArgumentNullException>("analyzerReferences[0]", () => solution.AddAnalyzerReferences([null!]));
2249Assert.Throws<ArgumentException>("analyzerReferences[1]", () => solution.AddAnalyzerReferences([analyzerRef1, analyzerRef1]));
2271Assert.Throws<ArgumentNullException>("analyzerReference", () => solution.RemoveAnalyzerReference(null!));
2376Assert.Throws<ArgumentNullException>("documentId", () => solution.AddDocument(documentId: null!, "name", loader));
2377Assert.Throws<ArgumentNullException>("name", () => solution.AddDocument(documentId, name: null!, loader));
2378Assert.Throws<ArgumentNullException>("loader", () => solution.AddDocument(documentId, "name", loader: null!));
2407Assert.Throws<ArgumentNullException>("documentId", () => solution.AddDocument(documentId: null!, "name", "text"));
2408Assert.Throws<ArgumentNullException>("name", () => solution.AddDocument(documentId, name: null!, "text"));
2409Assert.Throws<ArgumentNullException>("text", () => solution.AddDocument(documentId, "name", text: (string)null!));
2435Assert.Throws<ArgumentNullException>("documentId", () => solution.AddDocument(documentId: null!, "name", sourceText));
2436Assert.Throws<ArgumentNullException>("name", () => solution.AddDocument(documentId, name: null!, sourceText));
2437Assert.Throws<ArgumentNullException>("text", () => solution.AddDocument(documentId, "name", text: (SourceText)null!));
2487Assert.Throws<ArgumentNullException>("documentId", () => solution.AddDocument(documentId: null!, "name", root));
2488Assert.Throws<ArgumentNullException>("name", () => solution.AddDocument(documentId, name: null!, root));
2489Assert.Throws<ArgumentNullException>("syntaxRoot", () => solution.AddDocument(documentId, "name", syntaxRoot: null!));
UtilityTest\SpecializedTasksTests.cs (2)
82Assert.Throws<ArgumentNullException>("func", () => SpecializedTasks.TransformWithoutIntermediateCancellationExceptionAsync(null!, transform, arg, cancellationToken));
83Assert.Throws<ArgumentNullException>("transform", () => SpecializedTasks.TransformWithoutIntermediateCancellationExceptionAsync<StateType, IntermediateType, ResultType>(func, null!, arg, cancellationToken));
Microsoft.DotNet.XUnitAssert.Tests (22)
ExceptionAssertsTests.cs (15)
18 Assert.Throws<ArgumentNullException>("exceptionType", () => Assert.Throws(null!, testCode));
19 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws(typeof(Exception), default(Action)!));
90 Assert.Throws<ArgumentNullException>("exceptionType", () => Assert.Throws(null!, testCode));
91 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws(typeof(Exception), default(Func<object>)!));
175 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Action)!));
244 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Func<object>)!));
327 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Action)!));
413 Assert.Throws<ArgumentNullException>("testCode", () => Assert.Throws<ArgumentException>(default(Func<object>)!));
421 var ex = Record.Exception(() => Assert.Throws<ArgumentException>("paramName", testCode));
437 Assert.Throws<ArgumentException>("paramName", testCode);
445 var ex = Record.Exception(() => Assert.Throws<ArgumentException>("paramName2", testCode));
463 var ex = Record.Exception(() => Assert.Throws<ArgumentException>("paramName", testCode));
481 var ex = Record.Exception(() => Assert.Throws<ArgumentException>("paramName", testCode));
502 Assert.Throws<ArgumentNullException>("testCode", () => Assert.ThrowsAny<ArgumentException>(default(Action)!));
561 Assert.Throws<ArgumentNullException>("testCode", () => Assert.ThrowsAny<ArgumentException>(default(Func<object>)!));
Microsoft.Extensions.AI.Abstractions.Tests (59)
Contents\FunctionCallContentTests..cs (4)
320Assert.Throws<ArgumentNullException>("encodedArguments", () => FunctionCallContent.CreateFromParsedArguments((string)null!, "callId", "functionName", _ => null));
321Assert.Throws<ArgumentNullException>("callId", () => FunctionCallContent.CreateFromParsedArguments("{}", null!, "functionName", _ => null));
322Assert.Throws<ArgumentNullException>("name", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", null!, _ => null));
323Assert.Throws<ArgumentNullException>("argumentParser", () => FunctionCallContent.CreateFromParsedArguments("{}", "callId", "functionName", null!));
Contents\UriContentTests.cs (12)
15Assert.Throws<ArgumentNullException>("uri", () => new UriContent((string)null!, "image/png"));
16Assert.Throws<ArgumentNullException>("uri", () => new UriContent((Uri)null!, "image/png"));
19Assert.Throws<ArgumentNullException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", null!));
20Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", ""));
21Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", "image"));
23Assert.Throws<ArgumentNullException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), null!));
24Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), ""));
25Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), "audio"));
28Assert.Throws<ArgumentNullException>("value", () => c.Uri = null!);
40Assert.Throws<ArgumentException>("mediaType", () => new UriContent("http://localhost/something", type));
43Assert.Throws<ArgumentException>("value", () => c.MediaType = type);
44Assert.Throws<ArgumentNullException>("value", () => c.MediaType = null!);
Microsoft.Extensions.AI.AzureAIInference.Tests (6)
Microsoft.Extensions.AI.OpenAI.Tests (18)
OpenAIConversionTests.cs (10)
86Assert.Throws<ArgumentNullException>("messages", () => ((IEnumerable<ChatMessage>)null!).AsOpenAIChatMessages());
152Assert.Throws<ArgumentNullException>("messages", () => ((IEnumerable<ChatMessage>)null!).AsOpenAIResponseItems());
207Assert.Throws<ArgumentNullException>("chatCompletion", () => ((ChatCompletion)null!).AsChatResponse());
240Assert.Throws<ArgumentNullException>("chatCompletionUpdates", () => ((IAsyncEnumerable<StreamingChatCompletionUpdate>)null!).AsChatResponseUpdatesAsync());
286Assert.Throws<ArgumentNullException>("response", () => ((OpenAIResponse)null!).AsChatResponse());
295Assert.Throws<ArgumentNullException>("responseUpdates", () => ((IAsyncEnumerable<StreamingResponseUpdate>)null!).AsChatResponseUpdatesAsync());
304Assert.Throws<ArgumentNullException>("messages", () => ((IEnumerable<OpenAI.Chat.ChatMessage>)null!).AsChatMessages().ToArray());
327Assert.Throws<ArgumentNullException>("items", () => ((IEnumerable<ResponseItem>)null!).AsChatMessages());
391Assert.Throws<ArgumentNullException>("response", () => ((ChatResponse)null!).AsOpenAIChatCompletion());
853Assert.Throws<ArgumentNullException>("response", () => ((ChatResponse)null!).AsOpenAIResponse());
Microsoft.Extensions.AI.Tests (42)
Functions\AIFunctionFactoryTest.cs (7)
30Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.Create(method: null!));
31Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.Create(method: null!, target: new object()));
32Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.Create(method: null!, target: new object(), name: "myAiFunk"));
33Assert.Throws<ArgumentNullException>("target", () => AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (object?)null));
34Assert.Throws<ArgumentNullException>("createInstanceFunc", () =>
36Assert.Throws<ArgumentException>("method", () => AIFunctionFactory.Create(typeof(List<>).GetMethod("Add")!, new List<int>()));
444Assert.Throws<ArgumentException>("method", () => AIFunctionFactory.Create(
Microsoft.Extensions.TimeProvider.Testing.Tests (8)
TimerTests.cs (8)
141Assert.Throws<ArgumentOutOfRangeException>("dueTime", () => t.Change(TimeSpan.FromMilliseconds(-2), TimeSpan.FromMilliseconds(1)));
142Assert.Throws<ArgumentOutOfRangeException>("dueTime", () => t.Change(TimeSpan.FromMilliseconds(-2), TimeSpan.FromSeconds(1)));
143Assert.Throws<ArgumentOutOfRangeException>("dueTime", () => t.Change(TimeSpan.FromMilliseconds(0xFFFFFFFFL), TimeSpan.FromMilliseconds(1)));
144Assert.Throws<ArgumentOutOfRangeException>("dueTime", () => t.Change(TimeSpan.FromMilliseconds(0xFFFFFFFFL), TimeSpan.FromSeconds(1)));
153Assert.Throws<ArgumentOutOfRangeException>("period", () => t.Change(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(-2)));
154Assert.Throws<ArgumentOutOfRangeException>("period", () => t.Change(TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(-2)));
155Assert.Throws<ArgumentOutOfRangeException>("period", () => t.Change(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(0xFFFFFFFFL)));
156Assert.Throws<ArgumentOutOfRangeException>("period", () => t.Change(TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(0xFFFFFFFFL)));