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));
ValidationProblemResultTests.cs (2)
83Assert.Throws<ArgumentNullException>("problemDetails", () => new ValidationProblem(null)); 89Assert.Throws<ArgumentException>("problemDetails", () => new ValidationProblem(
Microsoft.AspNetCore.Http.Tests (1)
HttpServiceCollectionExtensionsTests.cs (1)
28Assert.Throws<ArgumentNullException>("services", () => HttpServiceCollectionExtensions.AddHttpContextAccessor(null));
Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test (1)
UserStoreTest.cs (1)
99Assert.Throws<ArgumentNullException>("context", () => new UserStore(null));
Microsoft.AspNetCore.Identity.Test (6)
RoleManagerTest.cs (1)
123Assert.Throws<ArgumentNullException>("store",
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));
UserClaimsPrincipalFactoryTest.cs (1)
18Assert.Throws<ArgumentException>("optionsAccessor",
UserManagerTest.cs (1)
1350Assert.Throws<ArgumentNullException>("store",
Microsoft.AspNetCore.Mvc.Core.Test (4)
Formatters\FormatterMappingsTest.cs (1)
20Assert.Throws<ArgumentException>("format", () => options.GetMediaTypeMappingForFormat(format));
Formatters\MediaTypeTest.cs (3)
108Assert.Throws<ArgumentNullException>("mediaType", () => new MediaType(null, 0, 2)); 117Assert.Throws<ArgumentOutOfRangeException>("offset", () => new MediaType("media", offset, 5)); 124Assert.Throws<ArgumentOutOfRangeException>("length", () => new MediaType("media", 0, -1));
Microsoft.AspNetCore.Razor.Test (2)
TagHelpers\ReadOnlyTagHelperAttributeListTest.cs (1)
115var exception = Assert.Throws<ArgumentOutOfRangeException>("index", () => attributes[index]);
TagHelpers\TagHelperAttributeListTest.cs (1)
86var exception = Assert.Throws<ArgumentOutOfRangeException>("index", () => attributes[index]);
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)
QueryHelpersTests.cs (1)
107Assert.Throws<ArgumentNullException>("value", () => QueryHelpers.AddQueryString("http://contoso.com/", "hello", null!));
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (2)
IOperation\IOperationTests_ICompoundAssignmentOperation.cs (2)
24Assert.Throws<ArgumentNullException>("compoundAssignment", () => nullAssignment.GetInConversion()); 25Assert.Throws<ArgumentNullException>("compoundAssignment", () => nullAssignment.GetOutConversion());
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)
Compilation\TestOperationVisitor.cs (4)
1179Assert.Throws<ArgumentException>("compoundAssignment", () => VisualBasic.VisualBasicExtensions.GetInConversion(operation)); 1180Assert.Throws<ArgumentException>("compoundAssignment", () => VisualBasic.VisualBasicExtensions.GetOutConversion(operation)); 1186Assert.Throws<ArgumentException>("compoundAssignment", () => CSharp.CSharpExtensions.GetInConversion(operation)); 1187Assert.Throws<ArgumentException>("compoundAssignment", () => CSharp.CSharpExtensions.GetOutConversion(operation));
Microsoft.CodeAnalysis.UnitTests (93)
Analyzers\AnalyzerFileReferenceTests.cs (3)
47Assert.Throws<ArgumentNullException>("fullPath", () => new AnalyzerFileReference(null!, s_analyzerLoader)); 48Assert.Throws<ArgumentNullException>("assemblyLoader", () => new AnalyzerFileReference(TempRoot.Root, null!)); 51Assert.Throws<ArgumentException>("fullPath", () => new AnalyzerFileReference("a.dll", s_analyzerLoader));
Collections\HashSet\SegmentedHashSet_Generic_Tests`1.cs (5)
399Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new SegmentedHashSet<T>(-1)); 400Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new SegmentedHashSet<T>(int.MinValue)); 434Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new SegmentedHashSet<T>(-1, comparer)); 435Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new SegmentedHashSet<T>(int.MinValue, comparer)); 520Assert.Throws<ArgumentOutOfRangeException>("capacity", () => set.EnsureCapacity(-1));
Collections\ImmutableDictionaryTestBase.cs (2)
288Assert.Throws<ArgumentException>(null, () => map1.Add(key, value2)); 289Assert.Throws<ArgumentException>(null, () => map2.Add(key, value1));
Collections\ImmutableListTestBase.cs (1)
396Assert.Throws<ArgumentNullException>("comparison", () => this.SortTestHelper(ImmutableSegmentedList<int>.Empty, (Comparison<int>)null!));
Collections\ImmutableSegmentedDictionaryBuilderTest.cs (2)
219Assert.Throws<ArgumentException>(null, () => builder.KeyComparer = StringComparer.OrdinalIgnoreCase); 288Assert.Throws<ArgumentNullException>("builder", () => nullBuilder!.ToImmutableSegmentedDictionary());
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\ImmutableSegmentedHashSetBuilderTest.cs (7)
212Assert.Throws<ArgumentNullException>("other", () => builder.IsProperSubsetOf(null!)); 221Assert.Throws<ArgumentNullException>("other", () => builder.IsProperSupersetOf(null!)); 230Assert.Throws<ArgumentNullException>("other", () => builder.IsSubsetOf(null!)); 240Assert.Throws<ArgumentNullException>("other", () => builder.IsSupersetOf(null!)); 250Assert.Throws<ArgumentNullException>("other", () => builder.Overlaps(null!)); 267Assert.Throws<ArgumentNullException>("other", () => builder.SetEquals(null!)); 340Assert.Throws<ArgumentNullException>("builder", () => nullBuilder!.ToImmutableSegmentedHashSet());
Collections\ImmutableSegmentedListBuilderTest.cs (5)
264Assert.Throws<ArgumentOutOfRangeException>("index", () => mutable[3] = 4); 265Assert.Throws<ArgumentOutOfRangeException>("index", () => mutable[-1] = 4); 266Assert.Throws<ArgumentOutOfRangeException>("index", () => mutable[3]); 267Assert.Throws<ArgumentOutOfRangeException>("index", () => mutable[-1]); 423Assert.Throws<ArgumentNullException>("builder", () => nullBuilder!.ToImmutableSegmentedList());
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]);
Collections\List\ICollection.Generic.Tests.cs (1)
468Assert.Throws<ArgumentNullException>("item", () => collection.Contains(default(T)!));
Collections\List\SegmentedList.Generic.Tests.BinarySearch.cs (2)
69Assert.Throws<ArgumentException>(null, () => list.BinarySearch(0, count + 1, element, GetIComparer())); //"Finding items longer than array should throw ArgumentException" 72Assert.Throws<ArgumentException>(null, () => list.BinarySearch(count + 1, count, element, GetIComparer())); //"ArgumentException should be thrown on index greater than length of array."
Collections\List\SegmentedList.Generic.Tests.Misc.cs (1)
305Assert.Throws<ArgumentException>(null, () =>
Collections\List\SegmentedList.Generic.Tests.Remove.cs (1)
63Assert.Throws<ArgumentNullException>("match", () => new SegmentedList<T>().RemoveAll(null!));
Collections\SegmentedArrayTests.cs (1)
96Assert.Throws<ArgumentOutOfRangeException>("length", () => new SegmentedArray<byte>(-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\ProjectDependencyGraphTests.cs (2)
117Assert.Throws<ArgumentNullException>("projectId", 339Assert.Throws<ArgumentNullException>("projectId",
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));
WorkspaceServiceTests\ReferenceCountedDisposableTests.cs (2)
20=> Assert.Throws<ArgumentNullException>("instance", () => new ReferenceCountedDisposable<IDisposable>(null)); 125=> Assert.Throws<ArgumentNullException>("reference", () => new ReferenceCountedDisposable<IDisposable>.WeakReference(null));
XxHash128Tests.cs (3)
22Assert.Throws<ArgumentNullException>("source", () => XxHash128.Hash(null)); 23Assert.Throws<ArgumentNullException>("source", () => XxHash128.Hash(null, 42)); 25Assert.Throws<ArgumentException>("destination", () => XxHash128.Hash(new byte[] { 1, 2, 3 }, new byte[7]));
Microsoft.DotNet.XUnitAssert.Tests (22)
AsyncCollectionAssertsTests.cs (3)
1384 Assert.Throws<ArgumentNullException>("collection", () => Assert.Single(default(IAsyncEnumerable<object>)!)); 1469 Assert.Throws<ArgumentNullException>("collection", () => Assert.Single(default(IAsyncEnumerable<object>)!, _ => true)); 1470 Assert.Throws<ArgumentNullException>("predicate", () => Assert.Single(new object[0].ToAsyncEnumerable(), null!));
CollectionAssertsTests.cs (4)
2281 Assert.Throws<ArgumentNullException>("collection", () => Assert.Single(null!)); 2416 Assert.Throws<ArgumentNullException>("collection", () => Assert.Single(default(IEnumerable<object>)!)); 2501 Assert.Throws<ArgumentNullException>("collection", () => Assert.Single(default(IEnumerable<object>)!, _ => true)); 2502 Assert.Throws<ArgumentNullException>("predicate", () => Assert.Single(new object[0], null!));
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)
ChatCompletion\ChatClientExtensionsTests.cs (4)
17Assert.Throws<ArgumentNullException>("client", () => ChatClientExtensions.GetService<object>(null!)); 23Assert.Throws<ArgumentNullException>("client", () => ChatClientExtensions.GetRequiredService(null!, typeof(string))); 24Assert.Throws<ArgumentNullException>("client", () => ChatClientExtensions.GetRequiredService<object>(null!)); 27Assert.Throws<ArgumentNullException>("serviceType", () => client.GetRequiredService(null!));
ChatCompletion\ChatFinishReasonTests.cs (2)
21Assert.Throws<ArgumentNullException>("value", () => new ChatFinishReason(null!)); 22Assert.Throws<ArgumentException>("value", () => new ChatFinishReason(" "));
ChatCompletion\ChatResponseFormatTests.cs (3)
24Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name")); 25Assert.Throws<ArgumentException>("schemaDescription", () => new ChatResponseFormatJson(null, null, "description")); 26Assert.Throws<ArgumentException>("schemaName", () => new ChatResponseFormatJson(null, "name", "description"));
ChatCompletion\ChatResponseTests.cs (1)
27Assert.Throws<ArgumentNullException>("message", () => new ChatResponse((ChatMessage)null!));
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (1)
21Assert.Throws<ArgumentNullException>("updates", () => ((List<ChatResponseUpdate>)null!).ToChatResponse());
ChatCompletion\ChatRoleTests.cs (2)
21Assert.Throws<ArgumentNullException>("value", () => new ChatRole(null!)); 22Assert.Throws<ArgumentException>("value", () => new ChatRole(" "));
ChatCompletion\DelegatingChatClientTests.cs (2)
17Assert.Throws<ArgumentNullException>("innerClient", () => new NoOpDelegatingChatClient(null!)); 95Assert.Throws<ArgumentNullException>("serviceType", () => delegating.GetService(null!));
Contents\DataContentTests.cs (1)
58Assert.Throws<ArgumentException>("mediaType", () => new DataContent("data:image/png;base64,aGVsbG8=", type));
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!);
Contents\UsageContentTests.cs (2)
14Assert.Throws<ArgumentNullException>("details", () => new UsageContent(null!)); 56Assert.Throws<ArgumentNullException>("value", () => c.Details = null!);
Embeddings\DelegatingEmbeddingGeneratorTests.cs (2)
17Assert.Throws<ArgumentNullException>("innerGenerator", () => new NoOpDelegatingEmbeddingGenerator(null!)); 56Assert.Throws<ArgumentNullException>("serviceType", () => delegating.GetService(null!));
Embeddings\EmbeddingGenerationOptionsTests.cs (2)
30Assert.Throws<ArgumentOutOfRangeException>("value", () => options.Dimensions = 0); 31Assert.Throws<ArgumentOutOfRangeException>("value", () => options.Dimensions = -1);
Embeddings\EmbeddingGeneratorExtensionsTests.cs (3)
16Assert.Throws<ArgumentNullException>("generator", () => EmbeddingGeneratorExtensions.GetService<object>(null!)); 22Assert.Throws<ArgumentNullException>("generator", () => EmbeddingGeneratorExtensions.GetRequiredService<object>(null!)); 25Assert.Throws<ArgumentNullException>("serviceType", () => generator.GetRequiredService(null!));
Embeddings\GeneratedEmbeddingsTests.cs (8)
20Assert.Throws<ArgumentNullException>("embeddings", () => new GeneratedEmbeddings<Embedding<float>>(null!)); 21Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new GeneratedEmbeddings<Embedding<float>>(-1)); 50Assert.Throws<ArgumentOutOfRangeException>("index", () => instance[0]); 51Assert.Throws<ArgumentOutOfRangeException>("index", () => instance[-1]); 81Assert.Throws<ArgumentOutOfRangeException>("index", () => generatedEmbeddings[-1]); 82Assert.Throws<ArgumentOutOfRangeException>("index", () => generatedEmbeddings[2]); 244Assert.Throws<ArgumentOutOfRangeException>("index", () => embeddings[-1]); 245Assert.Throws<ArgumentOutOfRangeException>("index", () => embeddings[2]);
Functions\DelegatingAIFunctionTests.cs (1)
17Assert.Throws<ArgumentNullException>("innerFunction", () => new DerivedFunction(null!));
Image\DelegatingImageGeneratorTests.cs (2)
16Assert.Throws<ArgumentNullException>("innerGenerator", () => new NoOpDelegatingImageGenerator(null!)); 56Assert.Throws<ArgumentNullException>("serviceType", () => delegating.GetService(null!));
SpeechToText\DelegatingSpeechToTextClientTests.cs (2)
18Assert.Throws<ArgumentNullException>("innerClient", () => new NoOpDelegatingSpeechToTextClient(null!)); 96Assert.Throws<ArgumentNullException>("serviceType", () => delegating.GetService(null!));
SpeechToText\SpeechToTextResponseTests.cs (2)
17Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!)); 64Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!));
SpeechToText\SpeechToTextResponseUpdateExtensionsTests.cs (1)
38Assert.Throws<ArgumentNullException>("updates", () => ((List<SpeechToTextResponseUpdate>)null!).ToSpeechToTextResponse());
SpeechToText\SpeechToTextResponseUpdateKindTests.cs (2)
21Assert.Throws<ArgumentNullException>("value", () => new SpeechToTextResponseUpdateKind(null!)); 22Assert.Throws<ArgumentException>("value", () => new SpeechToTextResponseUpdateKind(" "));
Microsoft.Extensions.AI.AzureAIInference.Tests (6)
AzureAIInferenceChatClientTests.cs (2)
30Assert.Throws<ArgumentNullException>("chatCompletionsClient", () => ((ChatCompletionsClient)null!).AsIChatClient("model")); 33Assert.Throws<ArgumentException>("defaultModelId", () => client.AsIChatClient(" "));
AzureAIInferenceEmbeddingGeneratorTests.cs (2)
23Assert.Throws<ArgumentNullException>("embeddingsClient", () => ((EmbeddingsClient)null!).AsIEmbeddingGenerator()); 26Assert.Throws<ArgumentException>("defaultModelId", () => client.AsIEmbeddingGenerator(" "));
AzureAIInferenceImageEmbeddingGeneratorTests.cs (2)
23Assert.Throws<ArgumentNullException>("imageEmbeddingsClient", () => ((ImageEmbeddingsClient)null!).AsIEmbeddingGenerator()); 26Assert.Throws<ArgumentException>("defaultModelId", () => client.AsIEmbeddingGenerator(" "));
Microsoft.Extensions.AI.OpenAI.Tests (18)
OpenAIAssistantChatClientTests.cs (3)
21Assert.Throws<ArgumentNullException>("assistantClient", () => ((AssistantClient)null!).AsIChatClient("assistantId")); 22Assert.Throws<ArgumentNullException>("assistantId", () => new AssistantClient("ignored").AsIChatClient((string)null!)); 23Assert.Throws<ArgumentNullException>("assistant", () => new AssistantClient("ignored").AsIChatClient((Assistant)null!));
OpenAIChatClientTests.cs (1)
29Assert.Throws<ArgumentNullException>("chatClient", () => ((ChatClient)null!).AsIChatClient());
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());
OpenAIEmbeddingGeneratorTests.cs (1)
24Assert.Throws<ArgumentNullException>("embeddingClient", () => ((EmbeddingClient)null!).AsIEmbeddingGenerator());
OpenAIImageGeneratorTests.cs (1)
17Assert.Throws<ArgumentNullException>("imageClient", () => ((ImageClient)null!).AsIImageGenerator());
OpenAIResponseClientTests.cs (1)
28Assert.Throws<ArgumentNullException>("responseClient", () => ((OpenAIResponseClient)null!).AsIChatClient());
OpenAISpeechToTextClientTests.cs (1)
25Assert.Throws<ArgumentNullException>("audioClient", () => ((AudioClient)null!).AsISpeechToTextClient());
Microsoft.Extensions.AI.Tests (42)
ChatCompletion\ChatClientBuilderTest.cs (3)
61Assert.Throws<ArgumentNullException>("innerClient", () => new ChatClientBuilder((IChatClient)null!)); 62Assert.Throws<ArgumentNullException>("innerClient", () => ((IChatClient)null!).AsBuilder()); 68Assert.Throws<ArgumentNullException>("innerClientFactory", () => new ChatClientBuilder((Func<IServiceProvider, IChatClient>)null!));
ChatCompletion\ConfigureOptionsChatClientTests.cs (3)
18Assert.Throws<ArgumentNullException>("innerClient", () => new ConfigureOptionsChatClient(null!, _ => { })); 19Assert.Throws<ArgumentNullException>("configure", () => new ConfigureOptionsChatClient(new TestChatClient(), null!)); 27Assert.Throws<ArgumentNullException>("configure", () => builder.ConfigureOptions(null!));
ChatCompletion\FunctionInvocationContextTests.cs (3)
37Assert.Throws<ArgumentNullException>("value", () => ctx.CallContent = null!); 38Assert.Throws<ArgumentNullException>("value", () => ctx.Messages = null!); 39Assert.Throws<ArgumentNullException>("value", () => ctx.Function = null!);
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
27Assert.Throws<ArgumentNullException>("innerClient", () => new FunctionInvokingChatClient(null!)); 28Assert.Throws<ArgumentNullException>("builder", () => ((ChatClientBuilder)null!).UseFunctionInvocation());
ChatCompletion\LoggingChatClientTests.cs (2)
20Assert.Throws<ArgumentNullException>("innerClient", () => new LoggingChatClient(null!, NullLogger.Instance)); 21Assert.Throws<ArgumentNullException>("logger", () => new LoggingChatClient(new TestChatClient(), null!));
ChatCompletion\ReducingChatClientTests.cs (2)
18Assert.Throws<ArgumentNullException>("innerClient", () => new ReducingChatClient(null!, new TestReducer())); 26Assert.Throws<ArgumentNullException>("builder", () => ReducingChatClientBuilderExtensions.UseChatReducer(null!, new TestReducer()));
ChatCompletion\UseDelegateChatClientTests.cs (1)
22Assert.Throws<ArgumentNullException>("getResponseFunc", () => builder.Use(null!, null!));
Embeddings\ConfigureOptionsEmbeddingGeneratorTests.cs (3)
16Assert.Throws<ArgumentNullException>("innerGenerator", () => new ConfigureOptionsEmbeddingGenerator<string, Embedding<float>>(null!, _ => { })); 17Assert.Throws<ArgumentNullException>("configure", () => new ConfigureOptionsEmbeddingGenerator<string, Embedding<float>>(new TestEmbeddingGenerator(), null!)); 25Assert.Throws<ArgumentNullException>("configure", () => builder.ConfigureOptions(null!));
Embeddings\EmbeddingGeneratorBuilderTests.cs (3)
60Assert.Throws<ArgumentNullException>("innerGenerator", () => new EmbeddingGeneratorBuilder<string, Embedding<float>>((IEmbeddingGenerator<string, Embedding<float>>)null!)); 61Assert.Throws<ArgumentNullException>("innerGenerator", () => ((IEmbeddingGenerator<string, Embedding<float>>)null!).AsBuilder()); 67Assert.Throws<ArgumentNullException>("innerGeneratorFactory",
Embeddings\LoggingEmbeddingGeneratorTests.cs (2)
19Assert.Throws<ArgumentNullException>("innerGenerator", () => new LoggingEmbeddingGenerator<string, Embedding<float>>(null!, NullLogger.Instance)); 20Assert.Throws<ArgumentNullException>("logger", () => new LoggingEmbeddingGenerator<string, Embedding<float>>(new TestEmbeddingGenerator(), null!));
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (1)
20Assert.Throws<ArgumentNullException>("generateFunc", () =>
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(
Image\ConfigureOptionsImageGeneratorTests.cs (3)
16Assert.Throws<ArgumentNullException>("innerGenerator", () => new ConfigureOptionsImageGenerator(null!, _ => { })); 17Assert.Throws<ArgumentNullException>("configure", () => new ConfigureOptionsImageGenerator(new TestImageGenerator(), null!)); 25Assert.Throws<ArgumentNullException>("configure", () => builder.ConfigureOptions(null!));
Image\LoggingImageGeneratorTests.cs (2)
21Assert.Throws<ArgumentNullException>("innerGenerator", () => new LoggingImageGenerator(null!, NullLogger.Instance)); 22Assert.Throws<ArgumentNullException>("logger", () => new LoggingImageGenerator(new TestImageGenerator(), null!));
SpeechToText\ConfigureOptionsSpeechToTextClientTests.cs (3)
19Assert.Throws<ArgumentNullException>("innerClient", () => new ConfigureOptionsSpeechToTextClient(null!, _ => { })); 20Assert.Throws<ArgumentNullException>("configure", () => new ConfigureOptionsSpeechToTextClient(new TestSpeechToTextClient(), null!)); 28Assert.Throws<ArgumentNullException>("configure", () => builder.ConfigureOptions(null!));
SpeechToText\LoggingSpeechToTextClientTests.cs (2)
22Assert.Throws<ArgumentNullException>("innerClient", () => new LoggingSpeechToTextClient(null!, NullLogger.Instance)); 23Assert.Throws<ArgumentNullException>("logger", () => new LoggingSpeechToTextClient(new TestSpeechToTextClient(), null!));
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)));