/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ using System; using System.Linq.Expressions; using System.Reflection; using OpenSearch.OpenSearch.Xunit.XunitPlumbing; using FluentAssertions; using OpenSearch.Client; using Tests.Domain; namespace Tests.ClientConcepts.HighLevel.Inference { public class ImplicitConversionTests { private static T Implicit(T i) => i; [U] public void Ids() { Implicit(null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(",, ,,").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new string[] { null, null }).Should().BeNull(); } [U] public void LongId() => Implicit(null).Should().BeNull(); [U] public void DocumentPath() { Implicit>((Project)null).Should().BeNull(); Implicit>((Id)null).Should().BeNull(); Implicit>((string)null).Should().BeNull(); Implicit>("").Should().BeNull(); Implicit>(" ").Should().BeNull(); } [U] public void Field() { Implicit((string)null).Should().BeNull(); Implicit((Expression)null).Should().BeNull(); Implicit((PropertyInfo)null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void Fields() { Implicit((Expression)null).Should().BeNull(); Implicit((Field)null).Should().BeNull(); Implicit((string)null).Should().BeNull(); Implicit((PropertyInfo)null).Should().BeNull(); Implicit((string[])null).Should().BeNull(); Implicit((Expression[])null).Should().BeNull(); Implicit((PropertyInfo[])null).Should().BeNull(); Implicit((Field[])null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new Expression[] { }).Should().BeNull(); Implicit(new PropertyInfo[] { }).Should().BeNull(); Implicit(new Field[] { }).Should().BeNull(); Implicit(new Expression[] { null, null }).Should().BeNull(); Implicit(new PropertyInfo[] { null, null }).Should().BeNull(); Implicit(new Field[] { null, null }).Should().BeNull(); } [U] public void Id() { Implicit(null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void IndexName() { Implicit((string)null).Should().BeNull(); Implicit((Type)null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void Indices() { Implicit((string)null).Should().BeNull(); Implicit((OpenSearch.Client.Indices.ManyIndices)null).Should().BeNull(); Implicit((string[])null).Should().BeNull(); Implicit((IndexName)null).Should().BeNull(); Implicit((IndexName[])null).Should().BeNull(); Implicit((IndexName)null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(",, ,, ").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new IndexName[] { }).Should().BeNull(); Implicit(new string[] { null, null }).Should().BeNull(); Implicit(new IndexName[] { null, null }).Should().BeNull(); } [U] public void Names() { Implicit((string)null).Should().BeNull(); Implicit((string[])null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(",,").Should().BeNull(); Implicit(", ,").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new string[] { null, null }).Should().BeNull(); } [U] public void Routing() { Implicit((string)null).Should().BeNull(); Implicit((string[])null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(",,").Should().BeNull(); Implicit(", ,").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new string[] { null, null }).Should().BeNull(); } [U] public void Metrics() => Implicit(null).Should().BeNull(); [U] public void IndexMetrics() => Implicit(null).Should().BeNull(); [U] public void Name() { Implicit(null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void NodeId() { Implicit((string)null).Should().BeNull(); Implicit((string[])null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit(" ,, , ,,").Should().BeNull(); Implicit(new string[] { }).Should().BeNull(); Implicit(new string[] { null, null }).Should().BeNull(); } [U] public void PropertyName() { Implicit((Expression)null).Should().BeNull(); Implicit((PropertyInfo)null).Should().BeNull(); Implicit((string)null).Should().BeNull(); Implicit("").Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void RelationName() { Implicit((string)null).Should().BeNull(); Implicit((Type)null).Should().BeNull(); Implicit(" ").Should().BeNull(); } [U] public void TaskId() { Implicit((string)null).Should().BeNull(); Implicit(" ").Should().BeNull(); Implicit("").Should().BeNull(); } } }