diff --git a/tests/generator/Asserts.cs b/tests/bgen/Asserts.cs similarity index 100% rename from tests/generator/Asserts.cs rename to tests/bgen/Asserts.cs diff --git a/tests/generator/AttributeFactoryTests.cs b/tests/bgen/AttributeFactoryTests.cs similarity index 73% rename from tests/generator/AttributeFactoryTests.cs rename to tests/bgen/AttributeFactoryTests.cs index 096f3bc60e98..ebc3b2a4ff06 100644 --- a/tests/generator/AttributeFactoryTests.cs +++ b/tests/bgen/AttributeFactoryTests.cs @@ -13,11 +13,11 @@ static void AssertAttributeCreation (Func { var typeName = typeof (T).Name; var attr = callback (platform, major, minor, message) as T; - Assert.IsNotNull (attr, $"{typeName} attribute type"); - Assert.AreEqual (platform, attr.Platform, $"{typeName} Platform"); - Assert.AreEqual (major, attr.Version!.Major, $"{typeName} Major"); - Assert.AreEqual (minor, attr.Version!.Minor, $"{typeName} Minor"); - Assert.AreEqual (message, attr.Message); + Assert.That (attr, Is.Not.Null, $"{typeName} attribute type"); + Assert.That (attr.Platform, Is.EqualTo (platform), $"{typeName} Platform"); + Assert.That (attr.Version!.Major, Is.EqualTo (major), $"{typeName} Major"); + Assert.That (attr.Version!.Minor, Is.EqualTo (minor), $"{typeName} Minor"); + Assert.That (attr.Message, Is.EqualTo (message)); } static void AssertAttributeCreationNotVersion (Func callback, PlatformName platform, @@ -25,9 +25,9 @@ static void AssertAttributeCreationNotVersion (Func { var typeName = typeof (T).Name; var attr = callback (platform, message) as T; - Assert.IsNotNull (attr, $"{typeName} attribute type"); - Assert.AreEqual (platform, attr.Platform, $"{typeName} Platform"); - Assert.AreEqual (message, attr.Message); + Assert.That (attr, Is.Not.Null, $"{typeName} attribute type"); + Assert.That (attr.Platform, Is.EqualTo (platform), $"{typeName} Platform"); + Assert.That (attr.Message, Is.EqualTo (message)); } @@ -58,14 +58,14 @@ public void CreateAttributeNoVersionTest (PlatformName platform, string? message [TestCase (PlatformName.MacOSX)] [TestCase (PlatformName.TvOS)] public void CreateNoVersionSupportedAttributeTest (PlatformName platform) - => Assert.AreEqual (platform, AttributeFactory.CreateNoVersionSupportedAttribute (platform).Platform); + => Assert.That (AttributeFactory.CreateNoVersionSupportedAttribute (platform).Platform, Is.EqualTo (platform)); [TestCase (PlatformName.iOS)] [TestCase (PlatformName.MacCatalyst)] [TestCase (PlatformName.MacOSX)] [TestCase (PlatformName.TvOS)] public void CreateUnsupportedAttributeTest (PlatformName platform) - => Assert.AreEqual (platform, AttributeFactory.CreateUnsupportedAttribute (platform).Platform); + => Assert.That (AttributeFactory.CreateUnsupportedAttribute (platform).Platform, Is.EqualTo (platform)); class CloneCasesNoVersionClass : IEnumerable { public IEnumerator GetEnumerator () @@ -90,9 +90,9 @@ public IEnumerator GetEnumerator () public void CloneNoVersionTest (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform) { var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform); - Assert.AreEqual (targetPlatform, clone.Platform, "platform"); - Assert.AreEqual (attributeToClone.Message, clone.Message, "message"); - Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type"); + Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform"); + Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message"); + Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type"); } class CloneCasesMinVersionClass : IEnumerable { @@ -113,13 +113,13 @@ public IEnumerator GetEnumerator () public void CloneMinVersion (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform) { var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform); - Assert.AreEqual (targetPlatform, clone.Platform, "platform"); - Assert.AreEqual (attributeToClone.Message, clone.Message, "message"); - Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type"); + Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform"); + Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message"); + Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type"); if (clone.AvailabilityKind == AvailabilityKind.Introduced) { - Assert.Null (clone.Version, "Version"); + Assert.That (clone.Version, Is.Null, "Version"); } else { - Assert.AreEqual (Xamarin.SdkVersions.GetMinVersion (targetPlatform.AsApplePlatform ()), clone.Version, "Version"); + Assert.That (clone.Version, Is.EqualTo (Xamarin.SdkVersions.GetMinVersion (targetPlatform.AsApplePlatform ())), "Version"); } } @@ -145,10 +145,10 @@ public IEnumerator GetEnumerator () public void CloneBuildVersion (AvailabilityBaseAttribute attributeToClone, PlatformName targetPlatform) { var clone = AttributeFactory.CloneFromOtherPlatform (attributeToClone, targetPlatform); - Assert.AreEqual (targetPlatform, clone.Platform, "platform"); - Assert.AreEqual (attributeToClone.Message, clone.Message, "message"); - Assert.AreEqual (attributeToClone.GetType (), clone.GetType (), "type"); - Assert.AreEqual (attributeToClone.Version, clone.Version); + Assert.That (clone.Platform, Is.EqualTo (targetPlatform), "platform"); + Assert.That (clone.Message, Is.EqualTo (attributeToClone.Message), "message"); + Assert.That (clone.GetType (), Is.EqualTo (attributeToClone.GetType ()), "type"); + Assert.That (clone.Version, Is.EqualTo (attributeToClone.Version)); } } diff --git a/tests/generator/BGenBase.cs b/tests/bgen/BGenBase.cs similarity index 97% rename from tests/generator/BGenBase.cs rename to tests/bgen/BGenBase.cs index ac409d15a36b..04e3730f99d5 100644 --- a/tests/generator/BGenBase.cs +++ b/tests/bgen/BGenBase.cs @@ -43,7 +43,7 @@ internal BGenTool BuildFile (Profile profile, bool nowarnings, Action TestContext.Out.WriteLine (TestContext.CurrentContext.Test.FullName); foreach (var filename in filenames) TestContext.Out.WriteLine ($"\t{filename}"); - bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", filename))).ToArray ()); + bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", filename))).ToArray ()); bgen.AssertExecute ("build"); if (nowarnings) bgen.AssertNoWarnings (); diff --git a/tests/generator/BGenTests.cs b/tests/bgen/BGenTests.cs similarity index 85% rename from tests/generator/BGenTests.cs rename to tests/bgen/BGenTests.cs index b5e34b284c22..7a7ad37fb471 100644 --- a/tests/generator/BGenTests.cs +++ b/tests/bgen/BGenTests.cs @@ -104,7 +104,7 @@ public void Bug27986 () .Union (allTypes.SelectMany ((type) => type.Properties)); var preserves = allMembers.Count ((v) => v.HasCustomAttributes && v.CustomAttributes.Any ((ca) => ca.AttributeType.Name == "PreserveAttribute")); - Assert.AreEqual (35, preserves, "Preserve attribute count"); // If you modified code that generates PreserveAttributes please update the preserve count + Assert.That (preserves, Is.EqualTo (35), "Preserve attribute count"); // If you modified code that generates PreserveAttributes please update the preserve count } [Test] @@ -140,7 +140,7 @@ public void Bug31788 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bug31788.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bug31788.cs"))); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); @@ -158,7 +158,7 @@ public void Bug34042 () [TestCase (Profile.iOS)] public void NSCopyingNullability (Profile profile) { - var bgen = BuildFile (profile, "tests/nscopying-nullability.cs"); + var bgen = BuildFile (profile, "nscopying-nullability.cs"); bgen.AssertNoWarnings (); } @@ -166,7 +166,7 @@ public void NSCopyingNullability (Profile profile) [TestCase (Profile.iOS)] public void EditorBrowsable (Profile profile) { - var bgen = BuildFile (profile, false, true, "tests/editor-browsable.cs"); + var bgen = BuildFile (profile, false, true, "editor-browsable.cs"); var types = bgen.ApiAssembly.MainModule.Types; var hasEditorBrowsableAttribute = new Func ((ICustomAttributeProvider provider) => { @@ -174,9 +174,9 @@ public void EditorBrowsable (Profile profile) }); var strongEnumType = types.Single (v => v.Name == "StrongEnum"); - Assert.IsTrue (hasEditorBrowsableAttribute (strongEnumType), "StrongEnumType"); + Assert.That (hasEditorBrowsableAttribute (strongEnumType), Is.True, "StrongEnumType"); var objcClassType = types.Single (v => v.Name == "ObjCClass"); - Assert.IsTrue (hasEditorBrowsableAttribute (objcClassType), "ObjCClass"); + Assert.That (hasEditorBrowsableAttribute (objcClassType), Is.True, "ObjCClass"); } static string RenderArgument (CustomAttributeArgument arg) @@ -294,7 +294,7 @@ public void Bug35176 () Console.WriteLine (renderedAttributes); } - Assert.AreEqual (expectedAttributes, renderedAttributes, "Introduced attributes"); + Assert.That (renderedAttributes, Is.EqualTo (expectedAttributes), "Introduced attributes"); } [Test] @@ -305,8 +305,8 @@ public void INativeObjectsInBlocks (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile); - bgen.AddTestApiDefinition ("tests/inativeobjects-in-blocks.cs"); - bgen.AddExtraSourcesRelativeToGeneratorDirectory ("tests/inativeobjects-in-blocks-sources.cs"); + bgen.AddTestApiDefinition ("inativeobjects-in-blocks.cs"); + bgen.AddExtraSourcesRelativeToGeneratorDirectory ("inativeobjects-in-blocks-sources.cs"); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); @@ -361,7 +361,7 @@ public void Bug42742 () .Union (allTypes.SelectMany ((type) => type.Properties)); var preserves = allMembers.Sum ((v) => v.CustomAttributes.Count ((ca) => ca.AttributeType.Name == "AdviceAttribute")); - Assert.AreEqual (33, preserves, "Advice attribute count"); // If you modified code that generates AdviceAttributes please update the attribute count + Assert.That (preserves, Is.EqualTo (33), "Advice attribute count"); // If you modified code that generates AdviceAttributes please update the attribute count } [Test] @@ -389,7 +389,7 @@ public void Bug46292 (Profile profile) .Union (allTypes.SelectMany ((type) => type.Properties)); var attribCount = allMembers.Count ((v) => v.HasCustomAttributes && v.CustomAttributes.Any ((ca) => ca.AttributeType.Name == "ObsoleteAttribute")); - Assert.AreEqual (2, attribCount, "attribute count"); + Assert.That (attribCount, Is.EqualTo (2), "attribute count"); } [Test] @@ -402,7 +402,7 @@ public void Bug53076 () // Count all *Async methods whose first parameter is 'IMyFooProtocol'. var methodCount = allMethods.Count ((v) => v.Name.EndsWith ("Async", StringComparison.Ordinal) && v.Parameters.Count > 0 && v.Parameters [0].ParameterType.Name == "IMyFooProtocol"); - Assert.AreEqual (10, methodCount, "Async method count"); + Assert.That (methodCount, Is.EqualTo (10), "Async method count"); } [Test] @@ -415,7 +415,7 @@ public void Bug53076WithModel () // Count all *Async methods whose first parameter is 'IMyFooProtocol'. var methodCount = allMethods.Count ((v) => v.Name.EndsWith ("Async", StringComparison.Ordinal) && v.Parameters.Count > 0 && v.Parameters [0].ParameterType.Name == "IMyFooProtocol"); - Assert.AreEqual (10, methodCount, "Async method count"); + Assert.That (methodCount, Is.EqualTo (10), "Async method count"); } [Test] @@ -430,7 +430,7 @@ public void StackOverflow20696157 () [TestCase (Profile.iOS)] public void TypesInMultipleNamespaces (Profile profile) { - BuildFile (profile, "tests/types-in-multiple-namespaces.cs"); + BuildFile (profile, "types-in-multiple-namespaces.cs"); } [Test] @@ -516,7 +516,7 @@ public void MultipleApiDefinitions2 () [TestCase (Profile.iOS)] public void INativeObjectArraysInBlocks (Profile profile) { - BuildFile (profile, "tests/inativeobject-arrays-in-blocks.cs"); + BuildFile (profile, "inativeobject-arrays-in-blocks.cs"); } [Test] @@ -527,8 +527,8 @@ public void ClassNameCollision (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile); - bgen.Sources.Add (Path.Combine (Configuration.SourceRoot, "tests", "generator", "classNameCollision-enum.cs")); - bgen.ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "generator", "classNameCollision.cs")); + bgen.Sources.Add (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "classNameCollision-enum.cs")); + bgen.ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "classNameCollision.cs")); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); @@ -576,7 +576,7 @@ public void NoAsyncInternalWrapper (Profile profile) .Union (allTypes.SelectMany ((type) => type.Fields)) .Union (allTypes.SelectMany ((type) => type.Properties)); - Assert.AreEqual (2, allMembers.Count ((member) => member.Name == "RequiredMethodAsync"), "Expected 2 RequiredMethodAsync members in generated code. If you modified code that generates RequiredMethodAsync (AsyncAttribute) please update the RequiredMethodAsync count."); + Assert.That (allMembers.Count ((member) => member.Name == "RequiredMethodAsync"), Is.EqualTo (2), "Expected 2 RequiredMethodAsync members in generated code. If you modified code that generates RequiredMethodAsync (AsyncAttribute) please update the RequiredMethodAsync count."); var attribs = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig; bgen.AssertMethod ("NoAsyncInternalWrapperTests.MyFooDelegate_Extensions", "RequiredMethodAsync", attribs, "System.Threading.Tasks.Task", "NoAsyncInternalWrapperTests.IMyFooDelegate", "System.Int32"); @@ -644,13 +644,13 @@ public void ForcedType () }); }); - Assert.AreEqual (12, getINativeObjectCalls, "Preserve attribute count"); // If you modified code that generates PreserveAttributes please update the preserve count + Assert.That (getINativeObjectCalls, Is.EqualTo (12), "Preserve attribute count"); // If you modified code that generates PreserveAttributes please update the preserve count } [Test] public void IsDirectBinding () { - var bgen = BuildFile (Profile.iOS, "tests/is-direct-binding.cs"); + var bgen = BuildFile (Profile.iOS, "is-direct-binding.cs"); var callsMethod = new Func ((method, name) => { return method.Body.Instructions.Any ((ins) => { @@ -658,7 +658,7 @@ public void IsDirectBinding () case Code.Call: case Code.Calli: case Code.Callvirt: - var mr = ins.Operand as MethodReference; + var mr = (MethodReference) ins.Operand; return mr.Name == name; default: return false; @@ -705,7 +705,7 @@ public void Issue3875 (string file, string modelName) { var bgen = BuildFile (Profile.iOS, file); var attrib = bgen.ApiAssembly.MainModule.GetType ("Issue3875", "AProtocol").CustomAttributes.Where ((v) => v.AttributeType.Name == "RegisterAttribute").First (); - Assert.AreEqual (modelName, attrib.ConstructorArguments [0].Value, "Custom ObjC name"); + Assert.That (attrib.ConstructorArguments [0].Value, Is.EqualTo (modelName), "Custom ObjC name"); } [Test] @@ -746,13 +746,13 @@ public void GH5416_setter (Profile profile) [Test] public void RefOutParameters () { - BuildFile (Profile.macOSMobile, true, "tests/ref-out-parameters.cs"); + BuildFile (Profile.macOSMobile, true, "ref-out-parameters.cs"); } [Test] public void ReturnRelease () { - BuildFile (Profile.iOS, "tests/return-release.cs"); + BuildFile (Profile.iOS, "return-release.cs"); } [Test] @@ -764,24 +764,24 @@ public void ReturnRelease () [Test] public void IgnoreUnavailableProtocol () { - var bgen = BuildFile (Profile.iOS, "tests/ignore-unavailable-protocol.cs"); + var bgen = BuildFile (Profile.iOS, "ignore-unavailable-protocol.cs"); var myClass = bgen.ApiAssembly.MainModule.GetType ("NS", "MyClass"); var myProtocol = bgen.ApiAssembly.MainModule.GetType ("NS", "IMyProtocol"); var myClassInterfaces = myClass.Interfaces.Select (v => v.InterfaceType.Name).ToArray (); Assert.That (myClassInterfaces, Does.Not.Contain ("IMyProtocol"), "IMyProtocol"); - Assert.IsNull (myProtocol, "MyProtocol null"); + Assert.That (myProtocol, Is.Null, "MyProtocol null"); } [Test] public void VSTS970507 () { - BuildFile (Profile.iOS, "tests/vsts-970507.cs"); + BuildFile (Profile.iOS, "vsts-970507.cs"); } [Test] public void DiamondProtocol () { - BuildFile (Profile.iOS, "tests/diamond-protocol.cs"); + BuildFile (Profile.iOS, "diamond-protocol.cs"); } [Test] @@ -816,25 +816,25 @@ bool IsOptimizable (MethodDefinition method) public void DisposeAttributeOptimizable () { var profile = Profile.iOS; - var bgen = BuildFile (profile, "tests/dispose-attribute.cs"); + var bgen = BuildFile (profile, "dispose-attribute.cs"); // processing custom attributes (like its properties) will call Resolve so we must be able to find the platform assembly to run this test - var resolver = bgen.ApiAssembly.MainModule.AssemblyResolver as BaseAssemblyResolver; + var resolver = (BaseAssemblyResolver) bgen.ApiAssembly.MainModule.AssemblyResolver; resolver.AddSearchDirectory (Configuration.GetRefDirectory (profile.AsPlatform ())); // [Dispose] is, by default, not optimizable var with_dispose = bgen.ApiAssembly.MainModule.GetType ("NS", "WithDispose").Methods.First ((v) => v.Name == "Dispose"); - Assert.NotNull (with_dispose, "WithDispose"); + Assert.That (with_dispose, Is.Not.Null, "WithDispose"); Assert.That (IsOptimizable (with_dispose), Is.False, "WithDispose/Optimizable"); // [Dispose] can opt-in being optimizable var with_dispose_optin = bgen.ApiAssembly.MainModule.GetType ("NS", "WithDisposeOptInOptimizable").Methods.First ((v) => v.Name == "Dispose"); - Assert.NotNull (with_dispose_optin, "WithDisposeOptInOptimizable"); + Assert.That (with_dispose_optin, Is.Not.Null, "WithDisposeOptInOptimizable"); Assert.That (IsOptimizable (with_dispose_optin), Is.True, "WithDisposeOptInOptimizable/Optimizable"); // Without a [Dispose] attribute the generated method is optimizable var without_dispose = bgen.ApiAssembly.MainModule.GetType ("NS", "WithoutDispose").Methods.First ((v) => v.Name == "Dispose"); - Assert.NotNull (without_dispose, "WitoutDispose"); + Assert.That (without_dispose, Is.Not.Null, "WitoutDispose"); Assert.That (IsOptimizable (without_dispose), Is.True, "WitoutDispose/Optimizable"); } @@ -842,15 +842,15 @@ public void DisposeAttributeOptimizable () public void SnippetAttributesOptimizable () { var profile = Profile.iOS; - var bgen = BuildFile (profile, "tests/snippet-attributes.cs"); + var bgen = BuildFile (profile, "snippet-attributes.cs"); // processing custom attributes (like its properties) will call Resolve so we must be able to find the platform assembly to run this test - var resolver = bgen.ApiAssembly.MainModule.AssemblyResolver as BaseAssemblyResolver; + var resolver = (BaseAssemblyResolver) bgen.ApiAssembly.MainModule.AssemblyResolver; resolver.AddSearchDirectory (Configuration.GetRefDirectory (profile.AsPlatform ())); // [SnippetAttribute] subclasses are, by default, not optimizable var not_opt = bgen.ApiAssembly.MainModule.GetType ("NS", "NotOptimizable"); - Assert.NotNull (not_opt, "NotOptimizable"); + Assert.That (not_opt, Is.Not.Null, "NotOptimizable"); var pre_not_opt = not_opt.Methods.First ((v) => v.Name == "Pre"); Assert.That (IsOptimizable (pre_not_opt), Is.False, "NotOptimizable/Pre"); var prologue_not_opt = not_opt.Methods.First ((v) => v.Name == "Prologue"); @@ -860,7 +860,7 @@ public void SnippetAttributesOptimizable () // [SnippetAttribute] subclasses can opt-in being optimizable var optin_opt = bgen.ApiAssembly.MainModule.GetType ("NS", "OptInOptimizable"); - Assert.NotNull (optin_opt, "OptInOptimizable"); + Assert.That (optin_opt, Is.Not.Null, "OptInOptimizable"); var pre_optin_opt = optin_opt.Methods.First ((v) => v.Name == "Pre"); Assert.That (IsOptimizable (pre_optin_opt), Is.True, "OptInOptimizable/Pre"); var prologue_optin_opt = optin_opt.Methods.First ((v) => v.Name == "Prologue"); @@ -870,7 +870,7 @@ public void SnippetAttributesOptimizable () // Without a [SnippetAttribute] subclass attribute the generated method is optimizable var nothing = bgen.ApiAssembly.MainModule.GetType ("NS", "NoSnippet").Methods.First ((v) => v.Name == "Nothing"); - Assert.NotNull (nothing, "NoSnippet"); + Assert.That (nothing, Is.Not.Null, "NoSnippet"); Assert.That (IsOptimizable (nothing), Is.True, "Nothing/Optimizable"); } @@ -883,8 +883,8 @@ public void NativeEnum (Profile profile) bgen.Profile = profile; bgen.ProcessEnums = true; bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile); - bgen.Sources = new string [] { Path.Combine (Configuration.SourceRoot, "tests", "generator", "tests", "nativeenum-extensions.cs") }.ToList (); - bgen.ApiDefinitions = new string [] { Path.Combine (Configuration.SourceRoot, "tests", "generator", "tests", "nativeenum.cs") }.ToList (); + bgen.Sources = new string [] { Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nativeenum-extensions.cs") }.ToList (); + bgen.ApiDefinitions = new string [] { Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nativeenum.cs") }.ToList (); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); } @@ -892,83 +892,83 @@ public void NativeEnum (Profile profile) [Test] public void DelegateWithINativeObjectReturnType () { - var bgen = BuildFile (Profile.iOS, "tests/delegate-with-inativeobject-return-type.cs"); + var bgen = BuildFile (Profile.iOS, "delegate-with-inativeobject-return-type.cs"); bgen.AssertExecute ("build"); // Assert that the return type from the delegate is IntPtr var type = bgen.ApiAssembly.MainModule.GetType ("ObjCRuntime", "Trampolines").NestedTypes.First (v => v.Name == "DMyHandler"); - Assert.NotNull (type, "DMyHandler"); + Assert.That (type, Is.Not.Null, "DMyHandler"); var method = type.Methods.First (v => v.Name == "Invoke"); - Assert.AreEqual ("ObjCRuntime.NativeHandle", method.ReturnType.FullName, "Return type"); + Assert.That (method.ReturnType.FullName, Is.EqualTo ("ObjCRuntime.NativeHandle"), "Return type"); } [Test] public void ProtocolBindProperty () { - var bgen = BuildFile (Profile.iOS, "tests/protocol-bind-property.cs"); + var bgen = BuildFile (Profile.iOS, "protocol-bind-property.cs"); bgen.AssertExecute ("build"); // Assert that the return type from the delegate is IntPtr var type = bgen.ApiAssembly.MainModule.GetType ("NS", "MyProtocol_Extensions"); - Assert.NotNull (type, "MyProtocol_Extensions"); + Assert.That (type, Is.Not.Null, "MyProtocol_Extensions"); var method = type.Methods.First (v => v.Name == "GetOptionalProperty"); var ldstr = method.Body.Instructions.Single (v => v.OpCode == OpCodes.Ldstr); - Assert.AreEqual ("isOptionalProperty", (string) ldstr.Operand, "isOptionalProperty"); + Assert.That ((string) ldstr.Operand, Is.EqualTo ("isOptionalProperty"), "isOptionalProperty"); method = type.Methods.First (v => v.Name == "SetOptionalProperty"); ldstr = method.Body.Instructions.Single (v => v.OpCode == OpCodes.Ldstr); - Assert.AreEqual ("setOptionalProperty:", (string) ldstr.Operand, "setOptionalProperty"); + Assert.That ((string) ldstr.Operand, Is.EqualTo ("setOptionalProperty:"), "setOptionalProperty"); type = bgen.ApiAssembly.MainModule.GetType ("NS", "MyProtocolWrapper"); - Assert.NotNull (type, "MyProtocolWrapper"); + Assert.That (type, Is.Not.Null, "MyProtocolWrapper"); method = type.Methods.First (v => v.Name == "get_AbstractProperty"); ldstr = method.Body.Instructions.Single (v => v.OpCode == OpCodes.Ldstr); - Assert.AreEqual ("isAbstractProperty", (string) ldstr.Operand, "isAbstractProperty"); + Assert.That ((string) ldstr.Operand, Is.EqualTo ("isAbstractProperty"), "isAbstractProperty"); method = type.Methods.First (v => v.Name == "set_AbstractProperty"); ldstr = method.Body.Instructions.Single (v => v.OpCode == OpCodes.Ldstr); - Assert.AreEqual ("setAbstractProperty:", (string) ldstr.Operand, "setAbstractProperty"); + Assert.That ((string) ldstr.Operand, Is.EqualTo ("setAbstractProperty:"), "setAbstractProperty"); } [Test] public void AbstractTypeTest () { - var bgen = BuildFile (Profile.iOS, "tests/abstract-type.cs"); + var bgen = BuildFile (Profile.iOS, "abstract-type.cs"); bgen.AssertExecute ("build"); // Assert that the return type from the delegate is IntPtr var type = bgen.ApiAssembly.MainModule.GetType ("NS", "MyObject"); - Assert.NotNull (type, "MyObject"); - Assert.IsFalse (type.IsAbstract, "IsAbstract"); + Assert.That (type, Is.Not.Null, "MyObject"); + Assert.That (type.IsAbstract, Is.False, "IsAbstract"); var method = type.Methods.First (v => v.Name == ".ctor" && !v.HasParameters && !v.IsStatic); - Assert.IsTrue (method.IsFamily, "IsProtected ctor"); + Assert.That (method.IsFamily, Is.True, "IsProtected ctor"); method = type.Methods.First (v => v.Name == "AbstractMember" && !v.HasParameters && !v.IsStatic); var throwInstruction = method.Body?.Instructions?.FirstOrDefault (v => v.OpCode == OpCodes.Throw); - Assert.IsTrue (method.IsPublic, "IsPublic ctor"); - Assert.IsTrue (method.IsVirtual, "IsVirtual"); - Assert.IsFalse (method.IsAbstract, "IsAbstract"); - Assert.IsNotNull (throwInstruction, "Throw"); + Assert.That (method.IsPublic, Is.True, "IsPublic ctor"); + Assert.That (method.IsVirtual, Is.True, "IsVirtual"); + Assert.That (method.IsAbstract, Is.False, "IsAbstract"); + Assert.That (throwInstruction, Is.Not.Null, "Throw"); } [Test] [Ignore ("https://github.com/dotnet/roslyn/issues/61525")] public void NativeIntDelegates () { - var bgen = BuildFile (Profile.iOS, "tests/nint-delegates.cs"); + var bgen = BuildFile (Profile.iOS, "nint-delegates.cs"); Func verifyDelegate = (typename) => { // Assert that the return type from the delegate is IntPtr var type = bgen.ApiAssembly.MainModule.GetType ("NS", typename); - Assert.NotNull (type, typename); + Assert.That (type, Is.Not.Null, typename); var method = type.Methods.First (m => m.Name == "Invoke"); - Assert.IsNotNull (method.MethodReturnType.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == "NativeIntegerAttribute"), "Return type for delegate " + typename); + Assert.That (method.MethodReturnType.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == "NativeIntegerAttribute"), Is.Not.Null, "Return type for delegate " + typename); foreach (var p in method.Parameters) { - Assert.IsNotNull (p.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == "NativeIntegerAttribute"), $"Parameter {p.Name}'s type for delegate " + typename); + Assert.That (p.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == "NativeIntegerAttribute"), Is.Not.Null, $"Parameter {p.Name}'s type for delegate " + typename); } return false; @@ -983,7 +983,7 @@ public void NativeIntDelegates () [Test] public void CSharp10Syntax () { - BuildFile (Profile.iOS, "tests/csharp10syntax.cs"); + BuildFile (Profile.iOS, "csharp10syntax.cs"); } [Test] @@ -994,7 +994,7 @@ public void AttributesFromInlinedProtocols (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; - bgen.AddTestApiDefinition ("tests/attributes-from-inlined-protocols.cs"); + bgen.AddTestApiDefinition ("attributes-from-inlined-protocols.cs"); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); @@ -1056,12 +1056,14 @@ expectedAttributes [i] + "\n" + [Test] public void NFloatType () { - var bgen = BuildFile (Profile.iOS, "tests/nfloat.cs"); + var bgen = BuildFile (Profile.iOS, "nfloat.cs"); var messaging = bgen.ApiAssembly.MainModule.Types.FirstOrDefault (v => v.Name == "Messaging"); - Assert.IsNotNull (messaging, "Messaging"); + Assert.That (messaging, Is.Not.Null, "Messaging"); + if (messaging is null) + return; var pinvoke = messaging.Methods.FirstOrDefault (v => v.Name == "xamarin_nfloat_objc_msgSend_exception"); - Assert.IsNotNull (pinvoke, "PInvoke"); + Assert.That (pinvoke, Is.Not.Null, "PInvoke"); } [Test] @@ -1071,7 +1073,7 @@ public void NoAvailabilityForAccessors (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.AddTestApiDefinition ("tests/no-availability-for-accessors.cs"); + bgen.AddTestApiDefinition ("no-availability-for-accessors.cs"); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); @@ -1108,7 +1110,7 @@ public void NoAvailabilityForAccessors (Profile profile) [Test] public void GeneratedAttributeOnPropertyAccessors () { - var bgen = BuildFile (Profile.MacCatalyst, "tests/generated-attribute-on-property-accessors.cs"); + var bgen = BuildFile (Profile.MacCatalyst, "generated-attribute-on-property-accessors.cs"); var messaging = bgen.ApiAssembly.MainModule.Types.First (v => v.Name == "ISomething"); var property = messaging.Properties.First (v => v.Name == "IsLoadedInProcess"); @@ -1120,14 +1122,14 @@ public void GeneratedAttributeOnPropertyAccessors () [UnsupportedOSPlatform(""tvos"")]"; expectedPropertyAttributes = expectedPropertyAttributes.Replace ("\r", string.Empty); - Assert.AreEqual (expectedPropertyAttributes, RenderSupportedOSPlatformAttributes (property), "Property attributes"); - Assert.AreEqual (string.Empty, RenderSupportedOSPlatformAttributes (getter), "Getter Attributes"); + Assert.That (RenderSupportedOSPlatformAttributes (property), Is.EqualTo (expectedPropertyAttributes), "Property attributes"); + Assert.That (RenderSupportedOSPlatformAttributes (getter), Is.EqualTo (string.Empty), "Getter Attributes"); } [Test] public void GeneratedAttributeOnPropertyAccessors2 () { - var bgen = BuildFile (Profile.MacCatalyst, "tests/generated-attribute-on-property-accessors2.cs"); + var bgen = BuildFile (Profile.MacCatalyst, "generated-attribute-on-property-accessors2.cs"); var messaging = bgen.ApiAssembly.MainModule.Types.First (v => v.Name == "ISomething"); var property = messaging.Properties.First (v => v.Name == "MicrophoneEnabled"); @@ -1148,16 +1150,16 @@ public void GeneratedAttributeOnPropertyAccessors2 () expectedPropertyAttributes = expectedPropertyAttributes.Replace ("\r", string.Empty); expectedSetterAttributes = expectedSetterAttributes.Replace ("\r", string.Empty); - Assert.AreEqual (expectedPropertyAttributes, RenderSupportedOSPlatformAttributes (property), "Property attributes"); - Assert.AreEqual (string.Empty, RenderSupportedOSPlatformAttributes (getter), "Getter Attributes"); - Assert.AreEqual (expectedSetterAttributes, RenderSupportedOSPlatformAttributes (setter), "Setter Attributes"); + Assert.That (RenderSupportedOSPlatformAttributes (property), Is.EqualTo (expectedPropertyAttributes), "Property attributes"); + Assert.That (RenderSupportedOSPlatformAttributes (getter), Is.EqualTo (string.Empty), "Getter Attributes"); + Assert.That (RenderSupportedOSPlatformAttributes (setter), Is.EqualTo (expectedSetterAttributes), "Setter Attributes"); } [Test] [TestCase (Profile.iOS)] public void NewerAvailabilityInInlinedProtocol (Profile profile) { - var bgen = BuildFile (profile, "tests/newer-availability-in-inlined-protocol.cs"); + var bgen = BuildFile (profile, "newer-availability-in-inlined-protocol.cs"); var expectedMethods = new [] { new { @@ -1316,15 +1318,17 @@ public void NewerAvailabilityInInlinedProtocol (Profile profile) foreach (var expected in expectedMethods) { var type = bgen.ApiAssembly.MainModule.Types.FirstOrDefault (v => v.Name == expected.Type); - Assert.IsNotNull (type, $"Type not found: {expected.Type}"); + Assert.That (type, Is.Not.Null, $"Type not found: {expected.Type}"); if (type is null) continue; - Assert.AreEqual (expected.MethodCount, type.Methods.Count, $"Unexpected method count for {expected.Type}.\n\tActual methods:\n\t\t{string.Join ("\n\t\t", type.Methods.Select (v => v.FullName))}"); + Assert.That (type.Methods.Count, Is.EqualTo (expected.MethodCount), $"Unexpected method count for {expected.Type}.\n\tActual methods:\n\t\t{string.Join ("\n\t\t", type.Methods.Select (v => v.FullName))}"); if (expected.MethodCount == 0) continue; foreach (var expectedMember in expected.Methods) { var member = type.Methods.SingleOrDefault (v => v.Name == expectedMember.Method); - Assert.IsNotNull (member, $"Method not found: {expectedMember.Method} in {type.FullName}"); + Assert.That (member, Is.Not.Null, $"Method not found: {expectedMember.Method} in {type.FullName}"); + if (member is null) + continue; var renderedAttributes = RenderSupportedOSPlatformAttributes (member); var expectedAttributes = expectedMember.Attributes.Replace ("\r", string.Empty); if (renderedAttributes != expectedAttributes) { @@ -1342,15 +1346,15 @@ public void NewerAvailabilityInInlinedProtocol (Profile profile) foreach (var expected in expectedProperties) { var type = bgen.ApiAssembly.MainModule.Types.FirstOrDefault (v => v.Name == expected.Type); - Assert.IsNotNull (type, $"Type not found: {expected.Type}"); + Assert.That (type, Is.Not.Null, $"Type not found: {expected.Type}"); if (type is null) continue; - Assert.AreEqual (expected.PropertyCount, type.Properties.Count, $"Unexpected property count for {expected.Type}.\n\tActual properties:\n\t\t{string.Join ("\n\t\t", type.Properties.Select (v => v.Name))}"); + Assert.That (type.Properties.Count, Is.EqualTo (expected.PropertyCount), $"Unexpected property count for {expected.Type}.\n\tActual properties:\n\t\t{string.Join ("\n\t\t", type.Properties.Select (v => v.Name))}"); if (expected.PropertyCount == 0) continue; foreach (var expectedMember in expected.Properties) { var member = type.Properties.SingleOrDefault (v => v.Name == expectedMember.Property); - Assert.IsNotNull (member, $"Property not found: {expectedMember.Property} in {type.FullName}"); + Assert.That (member, Is.Not.Null, $"Property not found: {expectedMember.Property} in {type.FullName}"); if (member is null) continue; var renderedAttributes = RenderSupportedOSPlatformAttributes (member); @@ -1376,7 +1380,7 @@ public void NewerAvailabilityInInlinedProtocol (Profile profile) [TestCase (Profile.iOS)] public void ErrorDomain (Profile profile) { - BuildFile (profile, true, true, "tests/errordomain.cs"); + BuildFile (profile, true, true, "errordomain.cs"); } [Test] @@ -1386,7 +1390,7 @@ public void ObsoletedOSPlatform (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.AddTestApiDefinition ("tests/obsoletedosplatform.cs"); + bgen.AddTestApiDefinition ("obsoletedosplatform.cs"); bgen.CreateTemporaryBinding (); bgen.AssertExecute ("build"); } @@ -1394,7 +1398,7 @@ public void ObsoletedOSPlatform (Profile profile) [Test] public void InternalDelegate () { - BuildFile (Profile.iOS, "tests/internal-delegate.cs"); + BuildFile (Profile.iOS, "internal-delegate.cs"); } [Test] @@ -1404,10 +1408,10 @@ public void InternalDelegate () [TestCase (Profile.tvOS)] public void XmlDocs (Profile profile) { - var bgen = BuildFile (profile, false, true, "tests/xmldocs.cs"); + var bgen = BuildFile (profile, false, true, "xmldocs.cs"); Assert.That (bgen.XmlDocumentation, Does.Exist); var contents = File.ReadAllText (bgen.XmlDocumentation); - var expectedContentsPath = Path.Combine (Configuration.SourceRoot, "tests", "generator", $"ExpectedXmlDocs.{profile.AsPlatform ().AsString ()}.xml"); + var expectedContentsPath = Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", $"ExpectedXmlDocs.{profile.AsPlatform ().AsString ()}.xml"); if (!File.Exists (expectedContentsPath)) File.WriteAllText (expectedContentsPath, string.Empty); @@ -1420,9 +1424,9 @@ public void XmlDocs (Profile profile) if (contents != expectedContents) { if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("WRITE_KNOWN_FAILURES"))) { File.WriteAllText (expectedContentsPath, contents); - Assert.AreEqual (expectedContents, contents, $"Xml docs: The known failures have been updated in {expectedContentsPath}, so please commit the results. Re-running the test should now succeed."); + Assert.That (contents, Is.EqualTo (expectedContents), $"Xml docs: The known failures have been updated in {expectedContentsPath}, so please commit the results. Re-running the test should now succeed."); } else { - Assert.AreEqual (expectedContents, contents, $"Xml docs: If this is expected, set the WRITE_KNOWN_FAILURES=1 environment variable, run the test again, and commit the changes to the {expectedContentsPath} file."); + Assert.That (contents, Is.EqualTo (expectedContents), $"Xml docs: If this is expected, set the WRITE_KNOWN_FAILURES=1 environment variable, run the test again, and commit the changes to the {expectedContentsPath} file."); } } } @@ -1434,7 +1438,7 @@ public void XmlDocs (Profile profile) [TestCase (Profile.tvOS)] public void PreviewAPIs (Profile profile) { - var bgen = BuildFile (profile, false, true, "tests/preview.cs"); + var bgen = BuildFile (profile, false, true, "preview.cs"); // Each Experimental attribute in the api definition has its own diagnostic ID (with an incremental number) // Here we collect all diagnostic IDS for all the Experimental attributes in the compiled assembly, @@ -1455,14 +1459,14 @@ public void PreviewAPIs (Profile profile) [Test] public void DelegateParameterAttributes () { - BuildFile (Profile.iOS, "tests/delegate-parameter-attributes.cs"); + BuildFile (Profile.iOS, "delegate-parameter-attributes.cs"); } [Test] public void Issue19612 () { var profile = Profile.iOS; - var filename = Path.Combine (Configuration.SourceRoot, "tests", "generator", "issue19612.cs"); + var filename = Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "issue19612.cs"); Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); @@ -1485,7 +1489,7 @@ public void Issue19612 () cscArguments.Add ($"/r:{Configuration.GetBaseLibrary (tf)}"); BGenTool.AddPreviewNoWarn (cscArguments); var rv = ExecutionHelper.Execute (cscExecutable, cscArguments); - Assert.AreEqual (0, rv, "CSC exit code"); + Assert.That (rv, Is.EqualTo (0), "CSC exit code"); var bgen = new BGenTool (); bgen.Profile = profile; @@ -1503,7 +1507,7 @@ public void Issue19612 () public void BackingFieldType (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, true, true, "tests/backingfieldtype.cs"); + var bgen = BuildFile (profile, true, true, "backingfieldtype.cs"); const string nintName = "System.IntPtr"; const string nuintName = "System.UIntPtr"; @@ -1521,22 +1525,22 @@ public void BackingFieldType (Profile profile) foreach (var tc in testCases) { var getConstant = bgen.ApiAssembly.MainModule.GetType ("BackingField", $"{tc.BackingFieldType}FieldTypeExtensions").Methods.First ((v) => v.Name == "GetConstant"); - Assert.AreEqual (tc.NullableType, getConstant.ReturnType.FullName, $"{tc.BackingFieldType}: GetConstant return type"); + Assert.That (getConstant.ReturnType.FullName, Is.EqualTo (tc.NullableType), $"{tc.BackingFieldType}: GetConstant return type"); var getValue = bgen.ApiAssembly.MainModule.GetType ("BackingField", $"{tc.BackingFieldType}FieldTypeExtensions").Methods.First ((v) => v.Name == "GetValue"); - Assert.AreEqual (tc.RenderedBackingFieldType, getValue.Parameters [0].ParameterType.FullName, $"{tc.BackingFieldType}: GetValue parameter type"); + Assert.That (getValue.Parameters [0].ParameterType.FullName, Is.EqualTo (tc.RenderedBackingFieldType), $"{tc.BackingFieldType}: GetValue parameter type"); var toEnumArray = bgen.ApiAssembly.MainModule.GetType ("BackingField", $"{tc.BackingFieldType}FieldTypeExtensions").Methods.First ((v) => v.Name == "ToEnumArray"); - Assert.IsTrue (toEnumArray.ReturnType.IsArray, $"{tc.BackingFieldType} ToEnumArray return type IsArray"); - Assert.AreEqual ($"{tc.BackingFieldType}FieldType", toEnumArray.ReturnType.GetElementType ().Name, $"{tc.BackingFieldType} ToEnumArray return type"); - Assert.IsTrue (toEnumArray.Parameters [0].ParameterType.IsArray, $"{tc.BackingFieldType} ToEnumArray parameter type IsArray"); - Assert.AreEqual (tc.RenderedBackingFieldType, toEnumArray.Parameters [0].ParameterType.GetElementType ().FullName, $"{tc.BackingFieldType} ToEnumArray parameter type"); + Assert.That (toEnumArray.ReturnType.IsArray, Is.True, $"{tc.BackingFieldType} ToEnumArray return type IsArray"); + Assert.That (toEnumArray.ReturnType.GetElementType ().Name, Is.EqualTo ($"{tc.BackingFieldType}FieldType"), $"{tc.BackingFieldType} ToEnumArray return type"); + Assert.That (toEnumArray.Parameters [0].ParameterType.IsArray, Is.True, $"{tc.BackingFieldType} ToEnumArray parameter type IsArray"); + Assert.That (toEnumArray.Parameters [0].ParameterType.GetElementType ().FullName, Is.EqualTo (tc.RenderedBackingFieldType), $"{tc.BackingFieldType} ToEnumArray parameter type"); var toConstantArray = bgen.ApiAssembly.MainModule.GetType ("BackingField", $"{tc.BackingFieldType}FieldTypeExtensions").Methods.First ((v) => v.Name == "ToConstantArray"); - Assert.IsTrue (toConstantArray.ReturnType.IsArray, $"{tc.BackingFieldType} ToConstantArray return type IsArray"); - Assert.AreEqual (tc.SimplifiedNullableType, toConstantArray.ReturnType.GetElementType ().FullName, $"{tc.BackingFieldType} ToConstantArray return type"); - Assert.IsTrue (toConstantArray.Parameters [0].ParameterType.IsArray, $"{tc.BackingFieldType} ToConstantArray parameter type IsArray"); - Assert.AreEqual ($"{tc.BackingFieldType}FieldType", toConstantArray.Parameters [0].ParameterType.GetElementType ().Name, $"{tc.BackingFieldType} ToConstantArray parameter type"); + Assert.That (toConstantArray.ReturnType.IsArray, Is.True, $"{tc.BackingFieldType} ToConstantArray return type IsArray"); + Assert.That (toConstantArray.ReturnType.GetElementType ().FullName, Is.EqualTo (tc.SimplifiedNullableType), $"{tc.BackingFieldType} ToConstantArray return type"); + Assert.That (toConstantArray.Parameters [0].ParameterType.IsArray, Is.True, $"{tc.BackingFieldType} ToConstantArray parameter type IsArray"); + Assert.That (toConstantArray.Parameters [0].ParameterType.GetElementType ().Name, Is.EqualTo ($"{tc.BackingFieldType}FieldType"), $"{tc.BackingFieldType} ToConstantArray parameter type"); } } @@ -1545,7 +1549,7 @@ public void BackingFieldType (Profile profile) public void UnderlyingFieldType (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - BuildFile (profile, true, true, "tests/underlyingfieldtype.cs"); + BuildFile (profile, true, true, "underlyingfieldtype.cs"); } [Test] @@ -1556,7 +1560,7 @@ public void UnderlyingFieldType (Profile profile) public void AvailabilityAttributes (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/availability-attributes.cs"); + var bgen = BuildFile (profile, "availability-attributes.cs"); bgen.AssertNoWarnings (); } @@ -1565,7 +1569,7 @@ public void AvailabilityAttributes (Profile profile) public void DelegatesWithNullableReturnType (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/delegate-nullable-return.cs"); + var bgen = BuildFile (profile, "delegate-nullable-return.cs"); bgen.AssertNoWarnings (); var delegateCallback = bgen.ApiAssembly.MainModule.GetType ("NS", "MyCallback").Methods.First ((v) => v.Name == "EndInvoke"); @@ -1577,13 +1581,13 @@ public void DelegatesWithNullableReturnType (Profile profile) public void DelegatesWithPointerTypes (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/delegate-types.cs"); + var bgen = BuildFile (profile, "delegate-types.cs"); bgen.AssertNoWarnings (); var delegateCallback = bgen.ApiAssembly.MainModule.GetType ("NS", "MyCallback").Methods.First ((v) => v.Name == "EndInvoke"); - Assert.IsTrue (delegateCallback.MethodReturnType.ReturnType.IsPointer, "Pointer return type"); + Assert.That (delegateCallback.MethodReturnType.ReturnType.IsPointer, Is.True, "Pointer return type"); foreach (var p in delegateCallback.Parameters.Where (v => v.Name != "result")) { - Assert.IsTrue (p.ParameterType.IsPointer, $"Pointer parameter type: {p.Name}"); + Assert.That (p.ParameterType.IsPointer, Is.True, $"Pointer parameter type: {p.Name}"); } } @@ -1592,7 +1596,7 @@ public void DelegatesWithPointerTypes (Profile profile) public void ProtocolWithBaseTypeButNoModel (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, false, "tests/protocol-and-basetype-no-model.cs"); + var bgen = BuildFile (profile, false, "protocol-and-basetype-no-model.cs"); bgen.AssertExecute ("build"); bgen.AssertWarning (1123, "The type Protocols.ProtocolWithBaseTypeButNoModel has a [Protocol] and a [BaseType] attribute, but no [Model] attribute. This is likely incorrect; either remove the [BaseType] attribute, or add a [Model] attribute."); } @@ -1602,7 +1606,7 @@ public void ProtocolWithBaseTypeButNoModel (Profile profile) public void DesignatedInitializer (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/designated-initializer-issue-10106.cs"); + var bgen = BuildFile (profile, "designated-initializer-issue-10106.cs"); bgen.AssertNoWarnings (); } @@ -1611,7 +1615,7 @@ public void DesignatedInitializer (Profile profile) public void ReleaseAttribute (Profile profile) { Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/release-attribute.cs"); + var bgen = BuildFile (profile, "release-attribute.cs"); bgen.AssertNoWarnings (); var passesOwnsEqualsTrue = new Func ((method) => { @@ -1640,7 +1644,7 @@ public void ReleaseAttribute (Profile profile) .Where (v => v.Name != "get_ClassHandle"); Assert.Multiple (() => { foreach (var method in methods) - Assert.True (passesOwnsEqualsTrue (method), method.Name); + Assert.That (passesOwnsEqualsTrue (method), Is.True, method.Name); }); } @@ -1650,7 +1654,7 @@ public void BothProtectedAndInternal (Profile profile) { // https://github.com/dotnet/macios/issues/6889 Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); - var bgen = BuildFile (profile, "tests/both-protected-and-internal.cs"); + var bgen = BuildFile (profile, "both-protected-and-internal.cs"); bgen.AssertNoWarnings (); } } diff --git a/tests/generator/BGenTool.cs b/tests/bgen/BGenTool.cs similarity index 97% rename from tests/generator/BGenTool.cs rename to tests/bgen/BGenTool.cs index 20e666cce2ee..86ecf771286d 100644 --- a/tests/generator/BGenTool.cs +++ b/tests/bgen/BGenTool.cs @@ -46,12 +46,11 @@ class BGenTool : Tool { public BGenTool () { - EnvironmentVariables = new Dictionary (); } public void AddTestApiDefinition (string filename) { - ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "generator", filename)); + ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", filename)); } public void AddExtraSourcesRelativeToGeneratorDirectory (string pathRelativeToGeneratorDirectory) @@ -61,7 +60,7 @@ public void AddExtraSourcesRelativeToGeneratorDirectory (string pathRelativeToGe public string GetFullPathRelativeToGeneratorDirectory (string pathRelativeToGeneratorDirectory) { - return Path.Combine (Configuration.SourceRoot, "tests", "generator", pathRelativeToGeneratorDirectory); + return Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", pathRelativeToGeneratorDirectory); } public AssemblyDefinition ApiAssembly { @@ -221,7 +220,7 @@ public void AssertExecute (string message) public void AssertExecuteError (string message) { - Assert.AreNotEqual (0, Execute (), message); + Assert.That (Execute (), Is.Not.EqualTo (0), message); } int Execute () @@ -338,7 +337,7 @@ public void AssertType (string fullname, TypeAttributes? attributes = null, stri return; } if (attributes is not null) - Assert.AreEqual (attributes.Value, t.Attributes, $"Incorrect attributes for type {fullname}."); + Assert.That (t.Attributes, Is.EqualTo (attributes.Value), $"Incorrect attributes for type {fullname}."); } public void AssertMethod (string typename, string method, params string [] parameterTypes) @@ -359,7 +358,7 @@ public void AssertMethod (string typename, string method, MethodAttributes? attr return; } if (attributes.HasValue) - Assert.AreEqual (attributes.Value, m.Attributes, "Attributes for {0}", m.FullName); + Assert.That (m.Attributes, Is.EqualTo (attributes.Value), $"Attributes for {m.FullName}"); } public void AssertNoMethod (string typename, string method, string? returnType = null, params string [] parameterTypes) diff --git a/tests/generator/CollectionsExtensionsTests.cs b/tests/bgen/CollectionsExtensionsTests.cs similarity index 55% rename from tests/generator/CollectionsExtensionsTests.cs rename to tests/bgen/CollectionsExtensionsTests.cs index b8ac7b9d0f41..b037b559d72a 100644 --- a/tests/generator/CollectionsExtensionsTests.cs +++ b/tests/bgen/CollectionsExtensionsTests.cs @@ -7,15 +7,15 @@ public class CollectionsExtensionsTests { [Test] public void Yield () - => Assert.AreEqual (1, "test".Yield ().Count ()); + => Assert.That ("test".Yield ().Count (), Is.EqualTo (1)); [Test] public void DropLast () { var array = new [] { "first", "second", "last" }; var result = array.DropLast (); - Assert.AreEqual (array.Length - 1, result.Length, "Result Length"); - Assert.False (result.Contains (array.Last ()), "Contains last item"); + Assert.That (result.Length, Is.EqualTo (array.Length - 1), "Result Length"); + Assert.That (result.Contains (array.Last ()), Is.False, "Contains last item"); } } diff --git a/tests/generator/ConstructorArgumentsTests.cs b/tests/bgen/ConstructorArgumentsTests.cs similarity index 53% rename from tests/generator/ConstructorArgumentsTests.cs rename to tests/bgen/ConstructorArgumentsTests.cs index 8c8c0b06b45f..e26518dea17c 100644 --- a/tests/generator/ConstructorArgumentsTests.cs +++ b/tests/bgen/ConstructorArgumentsTests.cs @@ -13,9 +13,9 @@ public void GetCtorValuesNullVersion () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, "test"); var values = args.GetCtorValues (); - Assert.AreEqual (2, values.Length, "Length"); - Assert.AreEqual ((byte) PlatformName.iOS, values [0], "Platform"); - Assert.AreEqual ("test", values [1], "Message"); + Assert.That (values.Length, Is.EqualTo (2), "Length"); + Assert.That (values [0], Is.EqualTo ((byte) PlatformName.iOS), "Platform"); + Assert.That (values [1], Is.EqualTo ("test"), "Message"); } [Test] @@ -23,11 +23,11 @@ public void GetCtorValuesNullBuild () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, 13, 0, "test"); var values = args.GetCtorValues (); - Assert.AreEqual (4, values.Length, "Length"); - Assert.AreEqual ((byte) PlatformName.iOS, values [0], "Platform"); - Assert.AreEqual (13, values [1], "Major"); - Assert.AreEqual (0, values [2], "Minor"); - Assert.AreEqual ("test", values [3], "Message"); + Assert.That (values.Length, Is.EqualTo (4), "Length"); + Assert.That (values [0], Is.EqualTo ((byte) PlatformName.iOS), "Platform"); + Assert.That (values [1], Is.EqualTo (13), "Major"); + Assert.That (values [2], Is.EqualTo (0), "Minor"); + Assert.That (values [3], Is.EqualTo ("test"), "Message"); } [Test] @@ -35,12 +35,12 @@ public void GetCtorValuesFullVersion () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, 13, 0, 1, "test"); var values = args.GetCtorValues (); - Assert.AreEqual (5, values.Length, "Length"); - Assert.AreEqual ((byte) PlatformName.iOS, values [0], "Platform"); - Assert.AreEqual (13, values [1], "Major"); - Assert.AreEqual (0, values [2], "Minor"); - Assert.AreEqual (1, values [3], "Build"); - Assert.AreEqual ("test", values [4], "Message"); + Assert.That (values.Length, Is.EqualTo (5), "Length"); + Assert.That (values [0], Is.EqualTo ((byte) PlatformName.iOS), "Platform"); + Assert.That (values [1], Is.EqualTo (13), "Major"); + Assert.That (values [2], Is.EqualTo (0), "Minor"); + Assert.That (values [3], Is.EqualTo (1), "Build"); + Assert.That (values [4], Is.EqualTo ("test"), "Message"); } [Test] @@ -48,9 +48,9 @@ public void GetCtorTypesNullVersion () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, "test"); var types = args.GetCtorTypes (); - Assert.AreEqual (2, types.Length, "Length"); - Assert.AreEqual (typeof (PlatformName), types [0], "Platform"); - Assert.AreEqual (typeof (string), types [1], "Message"); + Assert.That (types.Length, Is.EqualTo (2), "Length"); + Assert.That (types [0], Is.EqualTo (typeof (PlatformName)), "Platform"); + Assert.That (types [1], Is.EqualTo (typeof (string)), "Message"); } [Test] @@ -58,11 +58,11 @@ public void GetCtorTypesNullBuild () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, 13, 0, "test"); var types = args.GetCtorTypes (); - Assert.AreEqual (4, types.Length, "Length"); - Assert.AreEqual (typeof (PlatformName), types [0], "Platform"); - Assert.AreEqual (typeof (int), types [1], "Major"); - Assert.AreEqual (typeof (int), types [2], "Minor"); - Assert.AreEqual (typeof (string), types [3], "Message"); + Assert.That (types.Length, Is.EqualTo (4), "Length"); + Assert.That (types [0], Is.EqualTo (typeof (PlatformName)), "Platform"); + Assert.That (types [1], Is.EqualTo (typeof (int)), "Major"); + Assert.That (types [2], Is.EqualTo (typeof (int)), "Minor"); + Assert.That (types [3], Is.EqualTo (typeof (string)), "Message"); } [Test] @@ -70,12 +70,12 @@ public void GetCtorTypesFullVersion () { var args = new AttributeFactory.ConstructorArguments (PlatformName.iOS, 13, 0, 1, "test"); var types = args.GetCtorTypes (); - Assert.AreEqual (5, types.Length, "Length"); - Assert.AreEqual (typeof (PlatformName), types [0], "Platform"); - Assert.AreEqual (typeof (int), types [1], "Major"); - Assert.AreEqual (typeof (int), types [2], "Minor"); - Assert.AreEqual (typeof (int), types [3], "Build"); - Assert.AreEqual (typeof (string), types [4], "Message"); + Assert.That (types.Length, Is.EqualTo (5), "Length"); + Assert.That (types [0], Is.EqualTo (typeof (PlatformName)), "Platform"); + Assert.That (types [1], Is.EqualTo (typeof (int)), "Major"); + Assert.That (types [2], Is.EqualTo (typeof (int)), "Minor"); + Assert.That (types [3], Is.EqualTo (typeof (int)), "Build"); + Assert.That (types [4], Is.EqualTo (typeof (string)), "Message"); } class TryGetArgumentsData : IEnumerable { @@ -103,14 +103,14 @@ public void TryGetCtorArguments (object [] arguments, PlatformName platformName, { var success = AttributeFactory.ConstructorArguments.TryGetCtorArguments (arguments, platformName, out var actualValues, out var actualTypes); - Assert.True (success, "success"); - Assert.AreEqual (expectedValues!.Length, actualValues!.Length, "Values Length"); + Assert.That (success, Is.True, "success"); + Assert.That (actualValues!.Length, Is.EqualTo (expectedValues!.Length), "Values Length"); for (int index = 0; index < expectedValues.Length; index++) { - Assert.AreEqual (expectedValues [index], actualValues [index], $"Values [{index}]"); + Assert.That (actualValues [index], Is.EqualTo (expectedValues [index]), $"Values [{index}]"); } - Assert.AreEqual (expectedTypes!.Length, actualTypes!.Length, "Types Length"); + Assert.That (actualTypes!.Length, Is.EqualTo (expectedTypes!.Length), "Types Length"); for (int index = 0; index < expectedTypes.Length; index++) { - Assert.AreEqual (expectedTypes [index], actualTypes [index], $"Types [{index}]"); + Assert.That (actualTypes [index], Is.EqualTo (expectedTypes [index]), $"Types [{index}]"); } } @@ -119,9 +119,9 @@ public void TryGetCtorArgumentsFail () { var success = AttributeFactory.ConstructorArguments.TryGetCtorArguments (Array.Empty (), PlatformName.iOS, out var actualValues, out var actualTypes); - Assert.False (success, "success"); - Assert.Null (actualValues, "values"); - Assert.Null (actualTypes, "type"); + Assert.That (success, Is.False, "success"); + Assert.That (actualValues, Is.Null, "values"); + Assert.That (actualTypes, Is.Null, "type"); } } } diff --git a/tests/generator/ErrorTests.cs b/tests/bgen/ErrorTests.cs similarity index 93% rename from tests/generator/ErrorTests.cs rename to tests/bgen/ErrorTests.cs index cc2e7c9cc3e5..ee78a1202d58 100644 --- a/tests/generator/ErrorTests.cs +++ b/tests/bgen/ErrorTests.cs @@ -35,7 +35,7 @@ public void BI1036 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bi1036.cs")); + bgen.ApiDefinitions.Add (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bi1036.cs")); bgen.CreateTemporaryBinding (); bgen.AssertExecuteError ("build"); bgen.AssertError (1036, "The last parameter in the method 'NS.Foo.Method' must be a delegate (it's 'System.String')."); @@ -49,7 +49,7 @@ public void BI1037 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-abstract-error.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "protocol-duplicate-abstract-error.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1037, "The selector Identifier on type Derived is found multiple times with both read only and write only versions, with no read/write version."); } @@ -62,7 +62,7 @@ public void BI1038 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-return.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "protocol-duplicate-method-diff-return.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1038, "The selector DoIt on type Derived is found multiple times with different return types."); } @@ -75,7 +75,7 @@ public void BI1039 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-length.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "protocol-duplicate-method-diff-length.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1039, "The selector doit:itwith:more: on type Derived is found multiple times with different argument length 3 : 4."); } @@ -88,7 +88,7 @@ public void BI1040 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-out.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "protocol-duplicate-method-diff-out.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1040, "The selector doit:withmore on type Derived is found multiple times with different argument out states on argument 1."); } @@ -101,7 +101,7 @@ public void BI1041 (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "protocol-duplicate-method-diff-type.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "protocol-duplicate-method-diff-type.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertErrorPattern (1041, "The selector doit:with:more: on type Derived is found multiple times with different argument types on argument 2 - System.Int32 : .*Foundation.NSObject."); } @@ -141,7 +141,7 @@ public void BI1048 (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bindas1048error.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bindas1048error.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1048, "Unsupported type String decorated with [BindAs]"); } @@ -153,7 +153,7 @@ public void BI1049 (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bindas1049error.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bindas1049error.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1049, "Could not unbox type String from NSNumber container used on member BindAs1049ErrorTests.MyFooClass.StringMethod decorated with [BindAs]."); } @@ -165,7 +165,7 @@ public void GH6863_property (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "ghissue6863_property.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "ghissue6863_property.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1071, "The BindAs type for the member \"GH6863_property.MyFooClass.StringProp\" must be an array when the member's type is an array."); } @@ -178,7 +178,7 @@ public void GH6863_method (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "ghissue6863_method.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "ghissue6863_method.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1072, "The BindAs type for the parameter \"id_test\" in the method \"GH6863_method.MyFooClass.StringMethod\" must be an array when the parameter's type is an array."); } @@ -191,7 +191,7 @@ public void BI1050_model (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bindas1050modelerror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bindas1050modelerror.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1050, "[BindAs] cannot be used inside Protocol or Model types. Type: MyFooClass"); } @@ -203,7 +203,7 @@ public void BI1050_protocol (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bindas1050protocolerror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bindas1050protocolerror.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1050, "[BindAs] cannot be used inside Protocol or Model types. Type: MyFooClass"); } @@ -215,7 +215,7 @@ public void BI1059 (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bi1059.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bi1059.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1084, "Found 2 Foundation.PreserveAttribute attributes on the type BI1059. At most one was expected."); } @@ -227,7 +227,7 @@ public void BI1060 (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bug42855.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bug42855.cs"))); bgen.AssertExecute ("build"); bgen.AssertWarning (1060, "The Bug42855Tests.MyFooClass protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model]."); } @@ -239,7 +239,7 @@ public void BI1077 (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bi1077.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bi1077.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1077, "Async method System.Void A(BI1077.ADelegate) with more than one result parameter in the callback by neither ResultTypeName or ResultType"); bgen.AssertError (1077, "Async method System.Void B(BI1077.BDelegate) with more than one result parameter in the callback by neither ResultTypeName or ResultType"); @@ -309,7 +309,7 @@ public void BI1117_classinternal (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bug52570classinternal.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bug52570classinternal.cs"))); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); } @@ -321,7 +321,7 @@ public void BI1117_methodinternal (Profile profile) Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ()); var bgen = new BGenTool (); bgen.Profile = profile; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "bug52570methodinternal.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "bug52570methodinternal.cs"))); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); } @@ -809,7 +809,7 @@ public void BI1067_1070 (Profile profile) BGenTool bgen = new BGenTool { Profile = profile, }; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "tests", "diamond-protocol-errors.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "diamond-protocol-errors.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1067, "The type 'DiamondProtocol.A.C' is trying to inline the property 'P1' from the protocols 'DiamondProtocol.A.P1' and 'DiamondProtocol.A.P2', but the inlined properties don't share the same accessors ('DiamondProtocol.A.P1 P1' is read-only, while '$DiamondProtocol.A.P2 P1' is write-only)."); bgen.AssertWarning (1068, "The type 'DiamondProtocol.D.C' is trying to inline the property 'P1' from the protocols 'DiamondProtocol.D.P1' and 'DiamondProtocol.D.P2', and the inlined properties use different selectors (P1.P1 uses 'pA', and P2.P1 uses 'pB'."); @@ -832,7 +832,7 @@ public void WarnAsError (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.WarnAsError = string.Empty; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "warnaserror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "warnaserror.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1117, message); } @@ -842,7 +842,7 @@ public void WarnAsError (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "warnaserror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "warnaserror.cs"))); bgen.AssertExecute ("build"); bgen.AssertWarning (1117, message); } @@ -853,7 +853,7 @@ public void WarnAsError (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.WarnAsError = "1116"; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "warnaserror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "warnaserror.cs"))); bgen.AssertExecute ("build"); bgen.AssertWarning (1117, message); } @@ -864,7 +864,7 @@ public void WarnAsError (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.WarnAsError = "1117"; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "warnaserror.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "warnaserror.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1117, message); } @@ -886,7 +886,7 @@ public void NoWarn (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.NoWarn = string.Empty; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "nowarn.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nowarn.cs"))); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); } @@ -896,7 +896,7 @@ public void NoWarn (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "nowarn.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nowarn.cs"))); bgen.AssertExecute ("build"); bgen.AssertWarning (1117, message); } @@ -907,7 +907,7 @@ public void NoWarn (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.NoWarn = "1116"; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "nowarn.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nowarn.cs"))); bgen.AssertExecute ("build"); bgen.AssertWarning (1117, message); } @@ -918,7 +918,7 @@ public void NoWarn (Profile profile) bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); bgen.NoWarn = "1117"; - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "nowarn.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "nowarn.cs"))); bgen.AssertExecute ("build"); bgen.AssertNoWarnings (); } @@ -933,7 +933,7 @@ public void MissingExportOnProperty (Profile profile) var bgen = new BGenTool (); bgen.Profile = profile; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "missing-export-property.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "missing-export-property.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1018, "No [Export] attribute on property Test.NSTextInputClient.SelectedRange"); } @@ -947,7 +947,7 @@ public void ErrorDomain_NoLibraryName (Profile profile) bgen.Profile = profile; bgen.ProcessEnums = true; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "tests", "errordomain-nolibraryname.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "errordomain-nolibraryname.cs"))); bgen.AssertExecuteError ("build"); bgen.AssertError (1087, "Missing value for the 'LibraryName' property for the '[ErrorDomain]' attribute for ErrorDomainNS.EWithDomain (e.g. '[ErrorDomain (\"MyDomain\", LibraryName = \"__Internal\")]')"); } @@ -962,7 +962,7 @@ public void StrongDictionaryErrors (Profile profile) bgen.Profile = profile; bgen.ProcessEnums = true; bgen.Defines = BGenTool.GetDefaultDefines (profile); - bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", "tests", "strongdictionary-errors.cs"))); + bgen.CreateTemporaryBinding (File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "bgen", "tests", "strongdictionary-errors.cs"))); bgen.AssertExecuteError ("build"); var errorMessages = new string [] diff --git a/tests/generator/GeneratorTests.cs b/tests/bgen/GeneratorTests.cs similarity index 100% rename from tests/generator/GeneratorTests.cs rename to tests/bgen/GeneratorTests.cs diff --git a/tests/generator/NomenclatorTests.cs b/tests/bgen/NomenclatorTests.cs similarity index 55% rename from tests/generator/NomenclatorTests.cs rename to tests/bgen/NomenclatorTests.cs index 10acefbec9a7..0dcec7141eae 100644 --- a/tests/generator/NomenclatorTests.cs +++ b/tests/bgen/NomenclatorTests.cs @@ -31,9 +31,9 @@ interface GenericTrampoline where T : class { } Type testType = typeof (object); - Mock typeCache; - Mock attributeManager; - Nomenclator nomenclator; + Mock? typeCache; + Mock? attributeManager; + Nomenclator? nomenclator; [SetUp] public void SetUp () @@ -51,10 +51,10 @@ public void GetDelegateNameNoEventArgsTest (string methodName) { var method = GetMethod (methodName, testType); var attr = new DelegateNameAttribute ("NSAnimationProgress"); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - Assert.AreEqual ("NSAnimationProgress", nomenclator.GetDelegateName (method)); + Assert.That (nomenclator!.GetDelegateName (method), Is.EqualTo ("NSAnimationProgress")); attributeManager.Verify (); } @@ -63,11 +63,11 @@ public void GetDelegateNameEventArgsTest (string methodName) { var method = GetMethod (methodName, testType); var attr = new EventArgsAttribute ("NSAnimation"); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((DelegateNameAttribute) null); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((DelegateNameAttribute?) null); attributeManager.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - Assert.AreEqual ("NSAnimation", nomenclator.GetDelegateName (method)); + Assert.That (nomenclator!.GetDelegateName (method), Is.EqualTo ("NSAnimation")); attributeManager.Verify (); } @@ -75,11 +75,11 @@ public void GetDelegateNameEventArgsTest (string methodName) public void GetDelegateNameEventThrows () { var method = GetMethod ("DidAccelerate", testType); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((DelegateNameAttribute) null); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((DelegateNameAttribute?) null); attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((EventArgsAttribute) null); - Assert.Throws (() => nomenclator.GetDelegateName (method)); + .Returns ((EventArgsAttribute?) null); + Assert.Throws (() => nomenclator!.GetDelegateName (method)); attributeManager.Verify (); } @@ -87,9 +87,9 @@ public void GetDelegateNameEventThrows () public void GetEventNameNoAttribute () { var method = GetMethod ("DidAccelerate", testType); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((EventNameAttribute) null); - Assert.AreEqual ("DidAccelerate", nomenclator.GetEventName (method)); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((EventNameAttribute?) null); + Assert.That (nomenclator!.GetEventName (method), Is.EqualTo ("DidAccelerate")); attributeManager.Verify (); } @@ -99,9 +99,9 @@ public void GetEnventNameAttribute () var method = GetMethod ("DidAccelerate", testType); string eventName = "DidAccelerateEventRaised"; var attr = new EventNameAttribute (eventName); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - Assert.AreEqual (eventName, nomenclator.GetEventName (method)); + Assert.That (nomenclator!.GetEventName (method), Is.EqualTo (eventName)); attributeManager.Verify (); } @@ -110,9 +110,9 @@ public void GetDelegateApiName () { var method = GetMethod ("DidAccelerate", testType); var attr = new DelegateApiNameAttribute ("TestFramework"); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - Assert.AreEqual ("TestFramework", nomenclator.GetDelegateApiName (method)); + Assert.That (nomenclator!.GetDelegateApiName (method), Is.EqualTo ("TestFramework")); attributeManager.Verify (); } @@ -120,9 +120,9 @@ public void GetDelegateApiName () public void GetDelegateApiNameMissingAttr () { var method = GetMethod ("DidAccelerate", testType); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((DelegateApiNameAttribute) null); - Assert.AreEqual ("DidAccelerate", nomenclator.GetDelegateApiName (method)); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((DelegateApiNameAttribute?) null); + Assert.That (nomenclator!.GetDelegateApiName (method), Is.EqualTo ("DidAccelerate")); attributeManager.Verify (); } @@ -130,9 +130,9 @@ public void GetDelegateApiNameMissingAttr () public void GetDelegateApiNameDuplicate () { var method = GetMethod ("DidAccelerate", testType); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((DelegateApiNameAttribute) null); - Assert.AreEqual ("DidAccelerate", nomenclator.GetDelegateApiName (method)); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((DelegateApiNameAttribute?) null); + Assert.That (nomenclator!.GetDelegateApiName (method), Is.EqualTo ("DidAccelerate")); Assert.Throws (() => nomenclator.GetDelegateApiName (method)); attributeManager.Verify (); } @@ -141,16 +141,16 @@ public void GetDelegateApiNameDuplicate () public void GetEventArgNameSingleParamTest () { var method = GetMethod ("DidAccelerateSingle", testType); - Assert.AreEqual ("EventArgs", nomenclator.GetEventArgName (method)); + Assert.That (nomenclator!.GetEventArgName (method), Is.EqualTo ("EventArgs")); } [Test] public void GetEventArgsNameSeveralParamsNoAttr () { var method = GetMethod ("DidAccelerate", testType); - attributeManager.Setup (am => am.GetCustomAttribute (method)) - .Returns ((EventArgsAttribute) null); - Assert.Throws (() => nomenclator.GetEventArgName (method)); + attributeManager!.Setup (am => am.GetCustomAttribute (method)) + .Returns ((EventArgsAttribute?) null); + Assert.Throws (() => nomenclator!.GetEventArgName (method)); attributeManager.Verify (); } @@ -159,9 +159,9 @@ public void GetEventArgsSkipGenerationEndWithEventArgs () { var method = GetMethod ("DidAccelerateSeveral", testType); var attr = new EventArgsAttribute ("ThisIsATestEventArgs"); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - Assert.Throws (() => nomenclator.GetEventArgName (method)); + Assert.Throws (() => nomenclator!.GetEventArgName (method)); attributeManager.Verify (); } @@ -170,11 +170,11 @@ public void GetEventArgsSkipGeneration () { var method = GetMethod ("DidAccelerateSeveral", testType); var attr = new EventArgsAttribute ("ThisIsATest", true); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - var name = nomenclator.GetEventArgName (method); - Assert.AreEqual ("ThisIsATestEventArgs", name, "name"); - Assert.True (nomenclator.WasEventArgGenerated (name), "was generated"); + var name = nomenclator!.GetEventArgName (method); + Assert.That (name, Is.EqualTo ("ThisIsATestEventArgs"), "name"); + Assert.That (nomenclator.WasEventArgGenerated (name), Is.True, "was generated"); } [Test] @@ -182,41 +182,41 @@ public void GetEventArgsFullName () { var method = GetMethod ("DidAccelerateSeveral", testType); var attr = new EventArgsAttribute ("ThisIsATest", false, true); - attributeManager.Setup (am => am.GetCustomAttribute (method)) + attributeManager!.Setup (am => am.GetCustomAttribute (method)) .Returns (attr); - var name = nomenclator.GetEventArgName (method); - Assert.AreEqual ("ThisIsATest", name, "name"); - Assert.False (nomenclator.WasEventArgGenerated (name), "was generated"); + var name = nomenclator!.GetEventArgName (method); + Assert.That (name, Is.EqualTo ("ThisIsATest"), "name"); + Assert.That (nomenclator.WasEventArgGenerated (name), Is.False, "was generated"); } [Test] public void GetTrampolineNameNotGeneric () - => Assert.AreEqual ("NSAnimationDelegate", nomenclator.GetTrampolineName (testType)); + => Assert.That (nomenclator!.GetTrampolineName (testType), Is.EqualTo ("NSAnimationDelegate")); [Test] public void GetTrampolineNameGeneric () { - var name1 = nomenclator.GetTrampolineName (typeof (GenericTrampoline)); - var name2 = nomenclator.GetTrampolineName (typeof (GenericTrampoline)); - Assert.AreEqual ("GenericTrampolineArity1V0", name1, "name1"); - Assert.AreEqual ("GenericTrampolineArity1V1", name2, "name2"); - Assert.AreNotEqual (name1, name2, "equal"); + var name1 = nomenclator!.GetTrampolineName (typeof (GenericTrampoline)); + var name2 = nomenclator!.GetTrampolineName (typeof (GenericTrampoline)); + Assert.That (name1, Is.EqualTo ("GenericTrampolineArity1V0"), "name1"); + Assert.That (name2, Is.EqualTo ("GenericTrampolineArity1V1"), "name2"); + Assert.That (name2, Is.Not.EqualTo (name1), "equal"); } [Test] public void GetGeneratedTypeNameType () { - attributeManager.Setup (am => am.GetCustomAttributes (It.IsAny ())) + attributeManager!.Setup (am => am.GetCustomAttributes (It.IsAny ())) .Returns (Array.Empty ()); - Assert.AreEqual ("NSAnimationDelegate", nomenclator.GetGeneratedTypeName (typeof (NSAnimationDelegate))); + Assert.That (nomenclator!.GetGeneratedTypeName (typeof (NSAnimationDelegate)), Is.EqualTo ("NSAnimationDelegate")); } [Test] public void GetGeneratedTypeNameGenericType () { - attributeManager.Setup (am => am.GetCustomAttributes (It.IsAny ())) + attributeManager!.Setup (am => am.GetCustomAttributes (It.IsAny ())) .Returns (Array.Empty ()); - Assert.AreEqual ("GenericTrampoline", nomenclator.GetGeneratedTypeName (typeof (GenericTrampoline).GetGenericTypeDefinition ())); + Assert.That (nomenclator!.GetGeneratedTypeName (typeof (GenericTrampoline).GetGenericTypeDefinition ()), Is.EqualTo ("GenericTrampoline")); } [Test] @@ -224,9 +224,9 @@ public void GetGeneratedTypeNameBindAttribute () { var selectorName = "selectorName"; var attr = new BindAttribute (selectorName); - attributeManager.Setup (am => am.GetCustomAttributes (It.IsAny ())) + attributeManager!.Setup (am => am.GetCustomAttributes (It.IsAny ())) .Returns (new [] { attr }); - Assert.AreEqual (selectorName, nomenclator.GetGeneratedTypeName (typeof (NSAnimationDelegate))); + Assert.That (nomenclator!.GetGeneratedTypeName (typeof (NSAnimationDelegate)), Is.EqualTo (selectorName)); } } } diff --git a/tests/generator/NullabilityContextTests.cs b/tests/bgen/NullabilityContextTests.cs similarity index 80% rename from tests/generator/NullabilityContextTests.cs rename to tests/bgen/NullabilityContextTests.cs index edb715111c27..fc67dd91890c 100644 --- a/tests/generator/NullabilityContextTests.cs +++ b/tests/bgen/NullabilityContextTests.cs @@ -135,8 +135,8 @@ public void NotNullableFieldTest (string fieldName, Type expectedType) { var fieldInfo = GetField (fieldName, testType); var info = context.Create (fieldInfo); - Assert.False (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.False, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NullableValueTypeField", typeof (Nullable))] @@ -145,8 +145,8 @@ public void NullableFieldTest (string fieldName, Type expectedType) { var fieldInfo = GetField (fieldName, testType); var info = context.Create (fieldInfo); - Assert.True (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.True, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NotNullableValueTypeProperty", typeof (int))] @@ -155,8 +155,8 @@ public void NotNullablePropertyTest (string propertyName, Type expectedType) { var propertyInfo = GetProperty (propertyName, testType); var info = context.Create (propertyInfo); - Assert.False (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.False, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } // public int? this [int i] { @@ -168,14 +168,14 @@ public void NotNullablePropertyTest (string propertyName, Type expectedType) public void IndexersTests (Type indexersTypes, Type resultType, bool isNullable, Type indexParameter, bool isIndexParameterNull) { var propertyInfo = GetIndexer (testType, indexersTypes); - Assert.NotNull (propertyInfo, "propertyInto is not null"); + Assert.That (propertyInfo, Is.Not.Null, "propertyInto is not null"); var info = context.Create (propertyInfo.GetMethod!.ReturnParameter!); - Assert.AreEqual (isNullable, info.IsNullable (), "info.IsNullable"); - Assert.AreEqual (resultType, info.Type, "info.Type"); + Assert.That (info.IsNullable (), Is.EqualTo (isNullable), "info.IsNullable"); + Assert.That (info.Type, Is.EqualTo (resultType), "info.Type"); var parameters = propertyInfo.SetMethod!.GetParameters (); var paramInfo = context.Create (parameters [0]); - Assert.AreEqual (isIndexParameterNull, paramInfo.IsNullable (), "paramInfo.IsNullable"); - Assert.AreEqual (indexParameter, paramInfo.Type, "paramInfo.Type"); + Assert.That (paramInfo.IsNullable (), Is.EqualTo (isIndexParameterNull), "paramInfo.IsNullable"); + Assert.That (paramInfo.Type, Is.EqualTo (indexParameter), "paramInfo.Type"); } [TestCase ("NullableValueTypeProperty", typeof (Nullable))] @@ -184,8 +184,8 @@ public void NullablePropertyTest (string propertyName, Type expectedType) { var propertyInfo = GetProperty (propertyName, testType); var info = context.Create (propertyInfo); - Assert.True (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.True, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NotNullableValueTypeParameter", typeof (int))] @@ -195,8 +195,8 @@ public void NotNullableParameterTest (string methodName, Type expectedType) var memberInfo = GetMethod (methodName, testType); var paramInfo = memberInfo.GetParameters () [0]; var info = context.Create (paramInfo); - Assert.False (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.False, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NotNullableOutValueTypeParameter", typeof (int))] @@ -208,8 +208,8 @@ public void NotNullableRefParameterTest (string methodName, Type expectedType) var memberInfo = GetMethod (methodName, testType); var paramInfo = memberInfo.GetParameters () [0]; var info = context.Create (paramInfo); - Assert.False (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType.MakeByRefType (), info.Type); + Assert.That (info.IsNullable (), Is.False, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType.MakeByRefType ())); } [TestCase ("NullableValueTypeParameter", typeof (Nullable))] @@ -219,8 +219,8 @@ public void NullableParameterTest (string methdName, Type expectedType) var memberInfo = GetMethod (methdName, testType); var paramInfo = memberInfo.GetParameters () [0]; var info = context.Create (paramInfo); - Assert.True (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.True, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NullableOutValueTypeParameter", typeof (Nullable))] @@ -232,8 +232,8 @@ public void NullableRefParameterTest (string methdName, Type expectedType) var memberInfo = GetMethod (methdName, testType); var paramInfo = memberInfo.GetParameters () [0]; var info = context.Create (paramInfo); - Assert.True (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType.MakeByRefType (), info.Type); + Assert.That (info.IsNullable (), Is.True, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType.MakeByRefType ())); } [TestCase ("NotNullableValueTypeReturn", typeof (int))] @@ -242,8 +242,8 @@ public void NotNullableReturnTypeTest (string methodName, Type expectedType) { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.IsFalse (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.False, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NullableValueTypeReturn", typeof (Nullable))] @@ -252,8 +252,8 @@ public void NullableReturnTypeTest (string methodName, Type expectedType) { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.IsTrue (info.IsNullable (), "isNullable"); - Assert.AreEqual (expectedType, info.Type); + Assert.That (info.IsNullable (), Is.True, "isNullable"); + Assert.That (info.Type, Is.EqualTo (expectedType)); } [TestCase ("NotNullableValueTypeArray", typeof (int []), false, typeof (int), false)] @@ -266,9 +266,9 @@ public void ReturnTypeArrayTests (string methodName, Type? expectedType, bool ar { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (arrayIsNullable, info.IsNullable (), "info.IsNullable"); - Assert.AreEqual (expectedElementType, info.ElementType!.Type, "info.ElementType.Type"); - Assert.AreEqual (elementTypeIsNullable, info.ElementType.IsNullable (), "info.ElementTyps.IsNullable"); + Assert.That (info.IsNullable (), Is.EqualTo (arrayIsNullable), "info.IsNullable"); + Assert.That (info.ElementType!.Type, Is.EqualTo (expectedElementType), "info.ElementType.Type"); + Assert.That (info.ElementType.IsNullable (), Is.EqualTo (elementTypeIsNullable), "info.ElementTyps.IsNullable"); } [TestCase ("NotNullableNestedArrayNotNullableValueType", typeof (int [] []), false, false, typeof (int), false)] @@ -284,10 +284,10 @@ public void ReturnNestedArrayTests (string methodName, Type? expectedType, bool { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (isArrayNullable, info.IsNullable (), "isArrayNullable"); - Assert.AreEqual (isNestedArrayNullable, info.ElementType!.IsNullable (), "isNestedArrayNullable"); - Assert.AreEqual (nestedArrayType, info.ElementType!.ElementType!.Type, "nestedArrayType"); - Assert.AreEqual (isNestedArrayElementNullable, info.ElementType.ElementType.IsNullable (), "isNestedArrayElementNullable"); + Assert.That (info.IsNullable (), Is.EqualTo (isArrayNullable), "isArrayNullable"); + Assert.That (info.ElementType!.IsNullable (), Is.EqualTo (isNestedArrayNullable), "isNestedArrayNullable"); + Assert.That (info.ElementType!.ElementType!.Type, Is.EqualTo (nestedArrayType), "nestedArrayType"); + Assert.That (info.ElementType.ElementType.IsNullable (), Is.EqualTo (isNestedArrayElementNullable), "isNestedArrayElementNullable"); } [TestCase ("NotNullableValueTypeList", typeof (List), false, typeof (int), false)] @@ -301,10 +301,10 @@ public void ReturnSimpleGenericType (string methodName, Type? expectedType, bool { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (expectedType, info.Type, "info.Type"); - Assert.AreEqual (isGenericTypeNullable, info.IsNullable (), "info.IsNullable"); - Assert.AreEqual (genericParameterType, info.GenericTypeArguments! [0].Type, "genericParameterType"); - Assert.AreEqual (isGenericParameterNull, info.GenericTypeArguments [0].IsNullable (), "isGenericParameterNull"); + Assert.That (info.Type, Is.EqualTo (expectedType), "info.Type"); + Assert.That (info.IsNullable (), Is.EqualTo (isGenericTypeNullable), "info.IsNullable"); + Assert.That (info.GenericTypeArguments! [0].Type, Is.EqualTo (genericParameterType), "genericParameterType"); + Assert.That (info.GenericTypeArguments [0].IsNullable (), Is.EqualTo (isGenericParameterNull), "isGenericParameterNull"); } [TestCase ("NestedGenericNotNullableValueType", typeof (List>), false, typeof (HashSet), false, typeof (int), false)] @@ -321,12 +321,12 @@ public void ReturnNestedGeneric (string methodName, Type? expectedType, bool isG { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (expectedType, info.Type, "info.Type"); - Assert.AreEqual (isGenericNullable, info.IsNullable (), "info.IsNullable"); - Assert.AreEqual (nestedGenericType, info.GenericTypeArguments! [0].Type, "nestedGenericType"); - Assert.AreEqual (isNestedGenericNullable, info.GenericTypeArguments [0].IsNullable (), "isNestedGenericNullable"); - Assert.AreEqual (nestedGenericArgumentType, info.GenericTypeArguments [0].GenericTypeArguments! [0].Type, "nestedGenericArgumentType"); - Assert.AreEqual (isNullableNestedGenericArgument, info.GenericTypeArguments [0].GenericTypeArguments! [0].IsNullable (), "isNullableNestedGenericArgument"); + Assert.That (info.Type, Is.EqualTo (expectedType), "info.Type"); + Assert.That (info.IsNullable (), Is.EqualTo (isGenericNullable), "info.IsNullable"); + Assert.That (info.GenericTypeArguments! [0].Type, Is.EqualTo (nestedGenericType), "nestedGenericType"); + Assert.That (info.GenericTypeArguments [0].IsNullable (), Is.EqualTo (isNestedGenericNullable), "isNestedGenericNullable"); + Assert.That (info.GenericTypeArguments [0].GenericTypeArguments! [0].Type, Is.EqualTo (nestedGenericArgumentType), "nestedGenericArgumentType"); + Assert.That (info.GenericTypeArguments [0].GenericTypeArguments! [0].IsNullable (), Is.EqualTo (isNullableNestedGenericArgument), "isNullableNestedGenericArgument"); } [TestCase ("DictionaryStringInt", typeof (Dictionary), false, typeof (string), false, typeof (int), false)] @@ -338,12 +338,12 @@ public void ReturnDictionary (string methodName, Type? dictionaryType, bool isDi { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (dictionaryType, info.Type, "info.Type"); - Assert.AreEqual (isDictionaryNullable, info.IsNullable (), "info.IsNullable"); - Assert.AreEqual (keyType, info.GenericTypeArguments! [0].Type, "keyType"); - Assert.AreEqual (isKeyNullable, info.GenericTypeArguments [0].IsNullable (), "isKeyNullable"); - Assert.AreEqual (valueType, info.GenericTypeArguments [1].Type, "valueType"); - Assert.AreEqual (isValueNullable, info.GenericTypeArguments [1].IsNullable (), "isValueNullable"); + Assert.That (info.Type, Is.EqualTo (dictionaryType), "info.Type"); + Assert.That (info.IsNullable (), Is.EqualTo (isDictionaryNullable), "info.IsNullable"); + Assert.That (info.GenericTypeArguments! [0].Type, Is.EqualTo (keyType), "keyType"); + Assert.That (info.GenericTypeArguments [0].IsNullable (), Is.EqualTo (isKeyNullable), "isKeyNullable"); + Assert.That (info.GenericTypeArguments [1].Type, Is.EqualTo (valueType), "valueType"); + Assert.That (info.GenericTypeArguments [1].IsNullable (), Is.EqualTo (isValueNullable), "isValueNullable"); } [TestCase ("GenericNotNullConstrain", false)] @@ -354,7 +354,7 @@ public void GenericReturnConstrainTests (string methodName, bool returnTypeIsNul { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.ReturnParameter!); - Assert.AreEqual (returnTypeIsNull, info.IsNullable ()); + Assert.That (info.IsNullable (), Is.EqualTo (returnTypeIsNull)); } [TestCase ("GenericNotNullParameterConstrain", false)] @@ -365,7 +365,7 @@ public void GenericParamConstrainTests (string methodName, bool returnTypeIsNull { var memberInfo = GetMethod (methodName, testType); var info = context.Create (memberInfo.GetParameters () [0]); - Assert.AreEqual (returnTypeIsNull, info.IsNullable ()); + Assert.That (info.IsNullable (), Is.EqualTo (returnTypeIsNull)); } } } diff --git a/tests/generator/PlatformNameExtensionsTests.cs b/tests/bgen/PlatformNameExtensionsTests.cs similarity index 77% rename from tests/generator/PlatformNameExtensionsTests.cs rename to tests/bgen/PlatformNameExtensionsTests.cs index 53b05348a632..2e8bca1ff17c 100644 --- a/tests/generator/PlatformNameExtensionsTests.cs +++ b/tests/bgen/PlatformNameExtensionsTests.cs @@ -14,8 +14,8 @@ public class PlatformNameExtensions { [TestCase (PlatformName.MacOSX, "NSApplication")] public void GetApplicationClassNameTest (PlatformName platformName, string expected) { - Assert.True (platformName.TryGetApplicationClassName (out var applicationClassName)); - Assert.AreEqual (expected, applicationClassName); + Assert.That (platformName.TryGetApplicationClassName (out var applicationClassName), Is.True); + Assert.That (applicationClassName, Is.EqualTo (expected)); } [TestCase (PlatformName.iOS, "CoreImage")] @@ -23,20 +23,20 @@ public void GetApplicationClassNameTest (PlatformName platformName, string expec [TestCase (PlatformName.MacCatalyst, "CoreImage")] [TestCase (PlatformName.MacOSX, "Quartz")] public void GetCoreImageMapTest (PlatformName platformName, string expected) - => Assert.AreEqual (expected, platformName.GetCoreImageMap ()); + => Assert.That (platformName.GetCoreImageMap (), Is.EqualTo (expected)); [TestCase (PlatformName.iOS, "MobileCoreServices")] [TestCase (PlatformName.TvOS, "MobileCoreServices")] [TestCase (PlatformName.MacCatalyst, "MobileCoreServices")] [TestCase (PlatformName.MacOSX, "CoreServices")] public void GetCoreServicesMap (PlatformName platformName, string expected) - => Assert.AreEqual (expected, platformName.GetCoreServicesMap ()); + => Assert.That (platformName.GetCoreServicesMap (), Is.EqualTo (expected)); [TestCase (PlatformName.iOS, "PDFKit")] [TestCase (PlatformName.MacCatalyst, "PDFKit")] [TestCase (PlatformName.MacOSX, "Quartz")] public void GetPDFKitMapTest (PlatformName platformName, string expected) - => Assert.AreEqual (expected, platformName.GetPDFKitMap ()); + => Assert.That (platformName.GetPDFKitMap (), Is.EqualTo (expected)); [TestCase (PlatformName.iOS, ApplePlatform.iOS)] [TestCase (PlatformName.TvOS, ApplePlatform.TVOS)] @@ -44,6 +44,6 @@ public void GetPDFKitMapTest (PlatformName platformName, string expected) [TestCase (PlatformName.MacOSX, ApplePlatform.MacOSX)] [TestCase (PlatformName.None, ApplePlatform.None)] public void AsApplePlatformTest (PlatformName platformName, ApplePlatform expected) - => Assert.AreEqual (expected, platformName.AsApplePlatform ()); + => Assert.That (platformName.AsApplePlatform (), Is.EqualTo (expected)); } } diff --git a/tests/generator/ProtocolTests.cs b/tests/bgen/ProtocolTests.cs similarity index 99% rename from tests/generator/ProtocolTests.cs rename to tests/bgen/ProtocolTests.cs index ee3a20e1c47c..6dad62853715 100644 --- a/tests/generator/ProtocolTests.cs +++ b/tests/bgen/ProtocolTests.cs @@ -10,7 +10,7 @@ public class ProtocolTests : BGenBase { [TestCase (Profile.iOS)] public void Members (Profile profile) { - var bgen = BuildFile (profile, "tests/protocols.cs"); + var bgen = BuildFile (profile, "protocols.cs"); var allTypeDefinitions = bgen.ApiAssembly.MainModule.GetTypes ().ToArray (); var allTypes = allTypeDefinitions.Select (v => v.FullName).OrderBy (v => v).ToArray (); diff --git a/tests/generator/README.md b/tests/bgen/README.md similarity index 100% rename from tests/generator/README.md rename to tests/bgen/README.md diff --git a/tests/generator/ReflectionTest.cs b/tests/bgen/ReflectionTest.cs similarity index 72% rename from tests/generator/ReflectionTest.cs rename to tests/bgen/ReflectionTest.cs index 908d88825934..6a65f5d35c2e 100644 --- a/tests/generator/ReflectionTest.cs +++ b/tests/bgen/ReflectionTest.cs @@ -7,21 +7,21 @@ public class ReflectionTest { protected FieldInfo GetField (string fieldName, Type testType) { var fieldInfo = testType.GetField (fieldName); - Assert.NotNull (fieldInfo, "fieldInfo is not null"); + Assert.That (fieldInfo, Is.Not.Null, "fieldInfo is not null"); return fieldInfo!; } protected PropertyInfo GetProperty (string propertyName, Type testType) { var propertyInfo = testType.GetProperty (propertyName); - Assert.NotNull (propertyInfo, "propertyInto is not null"); + Assert.That (propertyInfo, Is.Not.Null, "propertyInto is not null"); return propertyInfo!; } protected MethodInfo GetMethod (string methodName, Type testType) { var memberInfo = testType.GetMethod (methodName); - Assert.NotNull (memberInfo, "memberInfo is not null"); + Assert.That (memberInfo, Is.Not.Null, "memberInfo is not null"); return memberInfo!; } } diff --git a/tests/generator/StringExtensionTests.cs b/tests/bgen/StringExtensionTests.cs similarity index 77% rename from tests/generator/StringExtensionTests.cs rename to tests/bgen/StringExtensionTests.cs index 585cd16cb67b..d2445ded9bbf 100644 --- a/tests/generator/StringExtensionTests.cs +++ b/tests/bgen/StringExtensionTests.cs @@ -31,62 +31,62 @@ public IEnumerator GetEnumerator () [TestCaseSource (typeof (KeywordsDataSource))] public void KeywordsTest (string keyword) - => Assert.AreNotEqual (keyword, keyword.GetSafeParamName (), "keyword"); + => Assert.That (keyword.GetSafeParamName (), Is.Not.EqualTo (keyword), "keyword"); [TestCase ("😀OhOh")] [TestCase (" OhOh")] [TestCase ("Oh Oh")] public void NotFixableIllegalChar (string illegal) - => Assert.IsNull (illegal.GetSafeParamName (), "paramName is null"); + => Assert.That (illegal.GetSafeParamName (), Is.Null, "paramName is null"); [TestCase ("1param")] public void StartsWithFixableIllegalChar (string illegal) { var legal = illegal.GetSafeParamName (); - Assert.IsNotNull (legal, "legal is not null"); - Assert.AreEqual ("@" + illegal, legal, "legal"); + Assert.That (legal, Is.Not.Null, "legal is not null"); + Assert.That (legal, Is.EqualTo ("@" + illegal), "legal"); } [Test] public void QuoteNullString () { string? str = null; - Assert.AreEqual (string.Empty, str.Quote ()); + Assert.That (str.Quote (), Is.EqualTo (string.Empty)); } [Test] public void QuoteEmptyString () { string str = String.Empty; - Assert.AreEqual (@"""""", str.Quote ()); + Assert.That (str.Quote (), Is.EqualTo (@"""""")); } [TestCase ("No quotes", "@\"No quotes\"")] [TestCase ("\"quotes\"", "@\"\"\"quotes\"\"\"")] public void QuoteString (string input, string output) { - Assert.AreEqual (output, input.Quote ()); + Assert.That (input.Quote (), Is.EqualTo (output)); } [Test] public void CamelCaseTest () { var str = "pascalCaseExample"; - Assert.AreEqual ("PascalCaseExample", str.CamelCase ()); + Assert.That (str.CamelCase (), Is.EqualTo ("PascalCaseExample")); } [Test] public void PascalCaseTest () { var str = "CamelCaseExample"; - Assert.AreEqual ("camelCaseExample", str.PascalCase ()); + Assert.That (str.PascalCase (), Is.EqualTo ("camelCaseExample")); } [TestCase ("@thisIsNotCapitalized", "ThisIsNotCapitalized")] [TestCase ("thisIsNotCapitalized", "ThisIsNotCapitalized")] [TestCase ("t", "T")] public void CapitalizeTest (string input, string output) - => Assert.AreEqual (output, input.Capitalize ()); + => Assert.That (input.Capitalize (), Is.EqualTo (output)); [TestCase ("ArityTest", "ArityTest")] [TestCase ("Arity`Test", "Arity")] @@ -96,6 +96,6 @@ public void CapitalizeTest (string input, string output) [TestCase ("`", "`")] [TestCase (null, null)] public void RemoveArityTest (string input, string output) - => Assert.AreEqual (output, input.RemoveArity ()); + => Assert.That (input.RemoveArity (), Is.EqualTo (output)); } } diff --git a/tests/bgen/bgen-tests.csproj b/tests/bgen/bgen-tests.csproj index 3d7e7fd837b8..0a21be053805 100644 --- a/tests/bgen/bgen-tests.csproj +++ b/tests/bgen/bgen-tests.csproj @@ -6,12 +6,14 @@ false true + enable + $(DefaultItemExcludesInProjectFolder);tests/** - - - + + + @@ -22,77 +24,32 @@ - - Asserts.cs - - - BGenTests.cs - - - BGenTool.cs - - - AttributeFactoryTests.cs - - - CollectionsExtensionsTests.cs - - - ConstructorArgumentsTests.cs - - - ErrorTests.cs - - - GeneratorTests.cs - - Configuration.cs + common/Configuration.cs - ConfigurationNUnit.cs + common/ConfigurationNUnit.cs - ExecutionHelper.cs + common/ExecutionHelper.cs - Profile.cs - - - NomenclatorTests.cs - - - NullabilityContextTests.cs - - - StringExtensionTests.cs - - - PlatformNameExtensionsTests.cs - - - ReflectionTest.cs + common/Profile.cs - Cache.cs + mtouch/Cache.cs - StringUtils.cs + tools/common/StringUtils.cs - Tool.cs + common/Tool.cs - BinLog.cs + common/BinLog.cs - SdkVersions.cs - - - BGenBase.cs - - - ProtocolTest.cs + tools/common/SdkVersions.cs diff --git a/tests/generator/sof20696157.sh b/tests/bgen/sof20696157.sh similarity index 100% rename from tests/generator/sof20696157.sh rename to tests/bgen/sof20696157.sh diff --git a/tests/generator/ExpectedXmlDocs.MacCatalyst.xml b/tests/bgen/tests/ExpectedXmlDocs.MacCatalyst.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.MacCatalyst.xml rename to tests/bgen/tests/ExpectedXmlDocs.MacCatalyst.xml diff --git a/tests/generator/ExpectedXmlDocs.iOS.legacy.xml b/tests/bgen/tests/ExpectedXmlDocs.iOS.legacy.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.iOS.legacy.xml rename to tests/bgen/tests/ExpectedXmlDocs.iOS.legacy.xml diff --git a/tests/generator/ExpectedXmlDocs.iOS.xml b/tests/bgen/tests/ExpectedXmlDocs.iOS.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.iOS.xml rename to tests/bgen/tests/ExpectedXmlDocs.iOS.xml diff --git a/tests/generator/ExpectedXmlDocs.macOS.legacy.xml b/tests/bgen/tests/ExpectedXmlDocs.macOS.legacy.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.macOS.legacy.xml rename to tests/bgen/tests/ExpectedXmlDocs.macOS.legacy.xml diff --git a/tests/generator/ExpectedXmlDocs.macOS.xml b/tests/bgen/tests/ExpectedXmlDocs.macOS.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.macOS.xml rename to tests/bgen/tests/ExpectedXmlDocs.macOS.xml diff --git a/tests/generator/ExpectedXmlDocs.tvOS.legacy.xml b/tests/bgen/tests/ExpectedXmlDocs.tvOS.legacy.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.tvOS.legacy.xml rename to tests/bgen/tests/ExpectedXmlDocs.tvOS.legacy.xml diff --git a/tests/generator/ExpectedXmlDocs.tvOS.xml b/tests/bgen/tests/ExpectedXmlDocs.tvOS.xml similarity index 100% rename from tests/generator/ExpectedXmlDocs.tvOS.xml rename to tests/bgen/tests/ExpectedXmlDocs.tvOS.xml diff --git a/tests/generator/NSApplicationPublicEnsureMethods.cs b/tests/bgen/tests/NSApplicationPublicEnsureMethods.cs similarity index 100% rename from tests/generator/NSApplicationPublicEnsureMethods.cs rename to tests/bgen/tests/NSApplicationPublicEnsureMethods.cs diff --git a/tests/generator/tests/abstract-type.cs b/tests/bgen/tests/abstract-type.cs similarity index 100% rename from tests/generator/tests/abstract-type.cs rename to tests/bgen/tests/abstract-type.cs diff --git a/tests/generator/arrayfromhandlebug.cs b/tests/bgen/tests/arrayfromhandlebug.cs similarity index 100% rename from tests/generator/arrayfromhandlebug.cs rename to tests/bgen/tests/arrayfromhandlebug.cs diff --git a/tests/generator/tests/attributes-from-inlined-protocols.cs b/tests/bgen/tests/attributes-from-inlined-protocols.cs similarity index 100% rename from tests/generator/tests/attributes-from-inlined-protocols.cs rename to tests/bgen/tests/attributes-from-inlined-protocols.cs diff --git a/tests/generator/tests/availability-attributes.cs b/tests/bgen/tests/availability-attributes.cs similarity index 100% rename from tests/generator/tests/availability-attributes.cs rename to tests/bgen/tests/availability-attributes.cs diff --git a/tests/generator/tests/backingfieldtype.cs b/tests/bgen/tests/backingfieldtype.cs similarity index 100% rename from tests/generator/tests/backingfieldtype.cs rename to tests/bgen/tests/backingfieldtype.cs diff --git a/tests/generator/bi1036.cs b/tests/bgen/tests/bi1036.cs similarity index 100% rename from tests/generator/bi1036.cs rename to tests/bgen/tests/bi1036.cs diff --git a/tests/generator/bi1042.cs b/tests/bgen/tests/bi1042.cs similarity index 100% rename from tests/generator/bi1042.cs rename to tests/bgen/tests/bi1042.cs diff --git a/tests/generator/bi1046.cs b/tests/bgen/tests/bi1046.cs similarity index 100% rename from tests/generator/bi1046.cs rename to tests/bgen/tests/bi1046.cs diff --git a/tests/generator/bi1059.cs b/tests/bgen/tests/bi1059.cs similarity index 100% rename from tests/generator/bi1059.cs rename to tests/bgen/tests/bi1059.cs diff --git a/tests/generator/bi1077.cs b/tests/bgen/tests/bi1077.cs similarity index 100% rename from tests/generator/bi1077.cs rename to tests/bgen/tests/bi1077.cs diff --git a/tests/generator/bindas1048error.cs b/tests/bgen/tests/bindas1048error.cs similarity index 100% rename from tests/generator/bindas1048error.cs rename to tests/bgen/tests/bindas1048error.cs diff --git a/tests/generator/bindas1049error.cs b/tests/bgen/tests/bindas1049error.cs similarity index 100% rename from tests/generator/bindas1049error.cs rename to tests/bgen/tests/bindas1049error.cs diff --git a/tests/generator/bindas1050modelerror.cs b/tests/bgen/tests/bindas1050modelerror.cs similarity index 100% rename from tests/generator/bindas1050modelerror.cs rename to tests/bgen/tests/bindas1050modelerror.cs diff --git a/tests/generator/bindas1050protocolerror.cs b/tests/bgen/tests/bindas1050protocolerror.cs similarity index 100% rename from tests/generator/bindas1050protocolerror.cs rename to tests/bgen/tests/bindas1050protocolerror.cs diff --git a/tests/generator/bindastests.cs b/tests/bgen/tests/bindastests.cs similarity index 100% rename from tests/generator/bindastests.cs rename to tests/bgen/tests/bindastests.cs diff --git a/tests/generator/bmac-with-hyphen-in-name.cs b/tests/bgen/tests/bmac-with-hyphen-in-name.cs similarity index 100% rename from tests/generator/bmac-with-hyphen-in-name.cs rename to tests/bgen/tests/bmac-with-hyphen-in-name.cs diff --git a/tests/generator/bmac_smoke.cs b/tests/bgen/tests/bmac_smoke.cs similarity index 100% rename from tests/generator/bmac_smoke.cs rename to tests/bgen/tests/bmac_smoke.cs diff --git a/tests/generator/tests/both-protected-and-internal.cs b/tests/bgen/tests/both-protected-and-internal.cs similarity index 100% rename from tests/generator/tests/both-protected-and-internal.cs rename to tests/bgen/tests/both-protected-and-internal.cs diff --git a/tests/generator/btouch-with-hyphen-in-name.cs b/tests/bgen/tests/btouch-with-hyphen-in-name.cs similarity index 100% rename from tests/generator/btouch-with-hyphen-in-name.cs rename to tests/bgen/tests/btouch-with-hyphen-in-name.cs diff --git a/tests/generator/bug15283.cs b/tests/bgen/tests/bug15283.cs similarity index 100% rename from tests/generator/bug15283.cs rename to tests/bgen/tests/bug15283.cs diff --git a/tests/generator/bug15307.cs b/tests/bgen/tests/bug15307.cs similarity index 100% rename from tests/generator/bug15307.cs rename to tests/bgen/tests/bug15307.cs diff --git a/tests/generator/bug15799.cs b/tests/bgen/tests/bug15799.cs similarity index 100% rename from tests/generator/bug15799.cs rename to tests/bgen/tests/bug15799.cs diff --git a/tests/generator/bug16036.cs b/tests/bgen/tests/bug16036.cs similarity index 100% rename from tests/generator/bug16036.cs rename to tests/bgen/tests/bug16036.cs diff --git a/tests/generator/bug17232.cs b/tests/bgen/tests/bug17232.cs similarity index 100% rename from tests/generator/bug17232.cs rename to tests/bgen/tests/bug17232.cs diff --git a/tests/generator/bug18025.cs b/tests/bgen/tests/bug18025.cs similarity index 100% rename from tests/generator/bug18025.cs rename to tests/bgen/tests/bug18025.cs diff --git a/tests/generator/bug23041.cs b/tests/bgen/tests/bug23041.cs similarity index 100% rename from tests/generator/bug23041.cs rename to tests/bgen/tests/bug23041.cs diff --git a/tests/generator/bug24078-ignore-methods-events.cs b/tests/bgen/tests/bug24078-ignore-methods-events.cs similarity index 100% rename from tests/generator/bug24078-ignore-methods-events.cs rename to tests/bgen/tests/bug24078-ignore-methods-events.cs diff --git a/tests/generator/bug27428.cs b/tests/bgen/tests/bug27428.cs similarity index 100% rename from tests/generator/bug27428.cs rename to tests/bgen/tests/bug27428.cs diff --git a/tests/generator/bug27430.cs b/tests/bgen/tests/bug27430.cs similarity index 100% rename from tests/generator/bug27430.cs rename to tests/bgen/tests/bug27430.cs diff --git a/tests/generator/bug27986.cs b/tests/bgen/tests/bug27986.cs similarity index 100% rename from tests/generator/bug27986.cs rename to tests/bgen/tests/bug27986.cs diff --git a/tests/generator/bug29493.cs b/tests/bgen/tests/bug29493.cs similarity index 100% rename from tests/generator/bug29493.cs rename to tests/bgen/tests/bug29493.cs diff --git a/tests/generator/bug31788.cs b/tests/bgen/tests/bug31788.cs similarity index 100% rename from tests/generator/bug31788.cs rename to tests/bgen/tests/bug31788.cs diff --git a/tests/generator/bug34042.cs b/tests/bgen/tests/bug34042.cs similarity index 100% rename from tests/generator/bug34042.cs rename to tests/bgen/tests/bug34042.cs diff --git a/tests/generator/bug35176.cs b/tests/bgen/tests/bug35176.cs similarity index 100% rename from tests/generator/bug35176.cs rename to tests/bgen/tests/bug35176.cs diff --git a/tests/generator/bug36457.cs b/tests/bgen/tests/bug36457.cs similarity index 100% rename from tests/generator/bug36457.cs rename to tests/bgen/tests/bug36457.cs diff --git a/tests/generator/bug37527-missing-property.cs b/tests/bgen/tests/bug37527-missing-property.cs similarity index 100% rename from tests/generator/bug37527-missing-property.cs rename to tests/bgen/tests/bug37527-missing-property.cs diff --git a/tests/generator/bug37527-wrong-property.cs b/tests/bgen/tests/bug37527-wrong-property.cs similarity index 100% rename from tests/generator/bug37527-wrong-property.cs rename to tests/bgen/tests/bug37527-wrong-property.cs diff --git a/tests/generator/bug39614.cs b/tests/bgen/tests/bug39614.cs similarity index 100% rename from tests/generator/bug39614.cs rename to tests/bgen/tests/bug39614.cs diff --git a/tests/generator/bug40282.cs b/tests/bgen/tests/bug40282.cs similarity index 100% rename from tests/generator/bug40282.cs rename to tests/bgen/tests/bug40282.cs diff --git a/tests/generator/bug42742.cs b/tests/bgen/tests/bug42742.cs similarity index 100% rename from tests/generator/bug42742.cs rename to tests/bgen/tests/bug42742.cs diff --git a/tests/generator/bug42855.cs b/tests/bgen/tests/bug42855.cs similarity index 100% rename from tests/generator/bug42855.cs rename to tests/bgen/tests/bug42855.cs diff --git a/tests/generator/bug43579.cs b/tests/bgen/tests/bug43579.cs similarity index 100% rename from tests/generator/bug43579.cs rename to tests/bgen/tests/bug43579.cs diff --git a/tests/generator/bug46292.cs b/tests/bgen/tests/bug46292.cs similarity index 100% rename from tests/generator/bug46292.cs rename to tests/bgen/tests/bug46292.cs diff --git a/tests/generator/bug52570allowstaticmembers.cs b/tests/bgen/tests/bug52570allowstaticmembers.cs similarity index 100% rename from tests/generator/bug52570allowstaticmembers.cs rename to tests/bgen/tests/bug52570allowstaticmembers.cs diff --git a/tests/generator/bug52570classinternal.cs b/tests/bgen/tests/bug52570classinternal.cs similarity index 100% rename from tests/generator/bug52570classinternal.cs rename to tests/bgen/tests/bug52570classinternal.cs diff --git a/tests/generator/bug52570methodinternal.cs b/tests/bgen/tests/bug52570methodinternal.cs similarity index 100% rename from tests/generator/bug52570methodinternal.cs rename to tests/bgen/tests/bug52570methodinternal.cs diff --git a/tests/generator/bug53076.cs b/tests/bgen/tests/bug53076.cs similarity index 100% rename from tests/generator/bug53076.cs rename to tests/bgen/tests/bug53076.cs diff --git a/tests/generator/bug53076withmodel.cs b/tests/bgen/tests/bug53076withmodel.cs similarity index 100% rename from tests/generator/bug53076withmodel.cs rename to tests/bgen/tests/bug53076withmodel.cs diff --git a/tests/generator/bug57531.cs b/tests/bgen/tests/bug57531.cs similarity index 100% rename from tests/generator/bug57531.cs rename to tests/bgen/tests/bug57531.cs diff --git a/tests/generator/bug57870.cs b/tests/bgen/tests/bug57870.cs similarity index 100% rename from tests/generator/bug57870.cs rename to tests/bgen/tests/bug57870.cs diff --git a/tests/generator/classNameCollision-enum.cs b/tests/bgen/tests/classNameCollision-enum.cs similarity index 100% rename from tests/generator/classNameCollision-enum.cs rename to tests/bgen/tests/classNameCollision-enum.cs diff --git a/tests/generator/classNameCollision.cs b/tests/bgen/tests/classNameCollision.cs similarity index 100% rename from tests/generator/classNameCollision.cs rename to tests/bgen/tests/classNameCollision.cs diff --git a/tests/generator/tests/csharp10syntax.cs b/tests/bgen/tests/csharp10syntax.cs similarity index 100% rename from tests/generator/tests/csharp10syntax.cs rename to tests/bgen/tests/csharp10syntax.cs diff --git a/tests/generator/tests/delegate-nullable-return.cs b/tests/bgen/tests/delegate-nullable-return.cs similarity index 100% rename from tests/generator/tests/delegate-nullable-return.cs rename to tests/bgen/tests/delegate-nullable-return.cs diff --git a/tests/generator/tests/delegate-parameter-attributes.cs b/tests/bgen/tests/delegate-parameter-attributes.cs similarity index 100% rename from tests/generator/tests/delegate-parameter-attributes.cs rename to tests/bgen/tests/delegate-parameter-attributes.cs diff --git a/tests/generator/tests/delegate-types.cs b/tests/bgen/tests/delegate-types.cs similarity index 100% rename from tests/generator/tests/delegate-types.cs rename to tests/bgen/tests/delegate-types.cs diff --git a/tests/generator/tests/delegate-with-inativeobject-return-type.cs b/tests/bgen/tests/delegate-with-inativeobject-return-type.cs similarity index 100% rename from tests/generator/tests/delegate-with-inativeobject-return-type.cs rename to tests/bgen/tests/delegate-with-inativeobject-return-type.cs diff --git a/tests/generator/tests/designated-initializer-issue-10106.cs b/tests/bgen/tests/designated-initializer-issue-10106.cs similarity index 100% rename from tests/generator/tests/designated-initializer-issue-10106.cs rename to tests/bgen/tests/designated-initializer-issue-10106.cs diff --git a/tests/generator/desk63279A.cs b/tests/bgen/tests/desk63279A.cs similarity index 100% rename from tests/generator/desk63279A.cs rename to tests/bgen/tests/desk63279A.cs diff --git a/tests/generator/desk63279B.cs b/tests/bgen/tests/desk63279B.cs similarity index 100% rename from tests/generator/desk63279B.cs rename to tests/bgen/tests/desk63279B.cs diff --git a/tests/generator/desk79124.cs b/tests/bgen/tests/desk79124.cs similarity index 100% rename from tests/generator/desk79124.cs rename to tests/bgen/tests/desk79124.cs diff --git a/tests/generator/tests/diamond-protocol-errors.cs b/tests/bgen/tests/diamond-protocol-errors.cs similarity index 100% rename from tests/generator/tests/diamond-protocol-errors.cs rename to tests/bgen/tests/diamond-protocol-errors.cs diff --git a/tests/generator/tests/diamond-protocol.cs b/tests/bgen/tests/diamond-protocol.cs similarity index 100% rename from tests/generator/tests/diamond-protocol.cs rename to tests/bgen/tests/diamond-protocol.cs diff --git a/tests/generator/tests/dispose-attribute.cs b/tests/bgen/tests/dispose-attribute.cs similarity index 100% rename from tests/generator/tests/dispose-attribute.cs rename to tests/bgen/tests/dispose-attribute.cs diff --git a/tests/generator/tests/editor-browsable.cs b/tests/bgen/tests/editor-browsable.cs similarity index 100% rename from tests/generator/tests/editor-browsable.cs rename to tests/bgen/tests/editor-browsable.cs diff --git a/tests/generator/tests/errordomain-nolibraryname.cs b/tests/bgen/tests/errordomain-nolibraryname.cs similarity index 100% rename from tests/generator/tests/errordomain-nolibraryname.cs rename to tests/bgen/tests/errordomain-nolibraryname.cs diff --git a/tests/generator/tests/errordomain.cs b/tests/bgen/tests/errordomain.cs similarity index 100% rename from tests/generator/tests/errordomain.cs rename to tests/bgen/tests/errordomain.cs diff --git a/tests/generator/fieldenumtests.cs b/tests/bgen/tests/fieldenumtests.cs similarity index 100% rename from tests/generator/fieldenumtests.cs rename to tests/bgen/tests/fieldenumtests.cs diff --git a/tests/generator/forcedtype.cs b/tests/bgen/tests/forcedtype.cs similarity index 100% rename from tests/generator/forcedtype.cs rename to tests/bgen/tests/forcedtype.cs diff --git a/tests/generator/forum54078.cs b/tests/bgen/tests/forum54078.cs similarity index 100% rename from tests/generator/forum54078.cs rename to tests/bgen/tests/forum54078.cs diff --git a/tests/generator/tests/generated-attribute-on-property-accessors.cs b/tests/bgen/tests/generated-attribute-on-property-accessors.cs similarity index 100% rename from tests/generator/tests/generated-attribute-on-property-accessors.cs rename to tests/bgen/tests/generated-attribute-on-property-accessors.cs diff --git a/tests/generator/tests/generated-attribute-on-property-accessors2.cs b/tests/bgen/tests/generated-attribute-on-property-accessors2.cs similarity index 100% rename from tests/generator/tests/generated-attribute-on-property-accessors2.cs rename to tests/bgen/tests/generated-attribute-on-property-accessors2.cs diff --git a/tests/generator/generic-strong-dictionary.cs b/tests/bgen/tests/generic-strong-dictionary.cs similarity index 100% rename from tests/generator/generic-strong-dictionary.cs rename to tests/bgen/tests/generic-strong-dictionary.cs diff --git a/tests/generator/generic-type-nsobject.cs b/tests/bgen/tests/generic-type-nsobject.cs similarity index 100% rename from tests/generator/generic-type-nsobject.cs rename to tests/bgen/tests/generic-type-nsobject.cs diff --git a/tests/generator/ghissue18645.cs b/tests/bgen/tests/ghissue18645.cs similarity index 100% rename from tests/generator/ghissue18645.cs rename to tests/bgen/tests/ghissue18645.cs diff --git a/tests/generator/ghissue3869.cs b/tests/bgen/tests/ghissue3869.cs similarity index 100% rename from tests/generator/ghissue3869.cs rename to tests/bgen/tests/ghissue3869.cs diff --git a/tests/generator/ghissue5416a.cs b/tests/bgen/tests/ghissue5416a.cs similarity index 100% rename from tests/generator/ghissue5416a.cs rename to tests/bgen/tests/ghissue5416a.cs diff --git a/tests/generator/ghissue5416b.cs b/tests/bgen/tests/ghissue5416b.cs similarity index 100% rename from tests/generator/ghissue5416b.cs rename to tests/bgen/tests/ghissue5416b.cs diff --git a/tests/generator/ghissue5444.cs b/tests/bgen/tests/ghissue5444.cs similarity index 100% rename from tests/generator/ghissue5444.cs rename to tests/bgen/tests/ghissue5444.cs diff --git a/tests/generator/ghissue5692.cs b/tests/bgen/tests/ghissue5692.cs similarity index 100% rename from tests/generator/ghissue5692.cs rename to tests/bgen/tests/ghissue5692.cs diff --git a/tests/generator/ghissue6626.cs b/tests/bgen/tests/ghissue6626.cs similarity index 100% rename from tests/generator/ghissue6626.cs rename to tests/bgen/tests/ghissue6626.cs diff --git a/tests/generator/ghissue6863_method.cs b/tests/bgen/tests/ghissue6863_method.cs similarity index 100% rename from tests/generator/ghissue6863_method.cs rename to tests/bgen/tests/ghissue6863_method.cs diff --git a/tests/generator/ghissue6863_property.cs b/tests/bgen/tests/ghissue6863_property.cs similarity index 100% rename from tests/generator/ghissue6863_property.cs rename to tests/bgen/tests/ghissue6863_property.cs diff --git a/tests/generator/ghissue7304.cs b/tests/bgen/tests/ghissue7304.cs similarity index 100% rename from tests/generator/ghissue7304.cs rename to tests/bgen/tests/ghissue7304.cs diff --git a/tests/generator/ghissue9065.cs b/tests/bgen/tests/ghissue9065.cs similarity index 100% rename from tests/generator/ghissue9065.cs rename to tests/bgen/tests/ghissue9065.cs diff --git a/tests/generator/tests/ignore-unavailable-protocol.cs b/tests/bgen/tests/ignore-unavailable-protocol.cs similarity index 100% rename from tests/generator/tests/ignore-unavailable-protocol.cs rename to tests/bgen/tests/ignore-unavailable-protocol.cs diff --git a/tests/generator/tests/inativeobject-arrays-in-blocks.cs b/tests/bgen/tests/inativeobject-arrays-in-blocks.cs similarity index 100% rename from tests/generator/tests/inativeobject-arrays-in-blocks.cs rename to tests/bgen/tests/inativeobject-arrays-in-blocks.cs diff --git a/tests/generator/tests/inativeobjects-in-blocks-sources.cs b/tests/bgen/tests/inativeobjects-in-blocks-sources.cs similarity index 100% rename from tests/generator/tests/inativeobjects-in-blocks-sources.cs rename to tests/bgen/tests/inativeobjects-in-blocks-sources.cs diff --git a/tests/generator/tests/inativeobjects-in-blocks.cs b/tests/bgen/tests/inativeobjects-in-blocks.cs similarity index 100% rename from tests/generator/tests/inativeobjects-in-blocks.cs rename to tests/bgen/tests/inativeobjects-in-blocks.cs diff --git a/tests/generator/tests/internal-delegate.cs b/tests/bgen/tests/internal-delegate.cs similarity index 100% rename from tests/generator/tests/internal-delegate.cs rename to tests/bgen/tests/internal-delegate.cs diff --git a/tests/generator/tests/is-direct-binding.cs b/tests/bgen/tests/is-direct-binding.cs similarity index 100% rename from tests/generator/tests/is-direct-binding.cs rename to tests/bgen/tests/is-direct-binding.cs diff --git a/tests/generator/issue19612.cs b/tests/bgen/tests/issue19612.cs similarity index 100% rename from tests/generator/issue19612.cs rename to tests/bgen/tests/issue19612.cs diff --git a/tests/generator/issue3875.cs b/tests/bgen/tests/issue3875.cs similarity index 100% rename from tests/generator/issue3875.cs rename to tests/bgen/tests/issue3875.cs diff --git a/tests/generator/issue3875B.cs b/tests/bgen/tests/issue3875B.cs similarity index 100% rename from tests/generator/issue3875B.cs rename to tests/bgen/tests/issue3875B.cs diff --git a/tests/generator/issue3875C.cs b/tests/bgen/tests/issue3875C.cs similarity index 100% rename from tests/generator/issue3875C.cs rename to tests/bgen/tests/issue3875C.cs diff --git a/tests/generator/missing-export-property.cs b/tests/bgen/tests/missing-export-property.cs similarity index 100% rename from tests/generator/missing-export-property.cs rename to tests/bgen/tests/missing-export-property.cs diff --git a/tests/generator/multiple-api-definitions1.cs b/tests/bgen/tests/multiple-api-definitions1.cs similarity index 100% rename from tests/generator/multiple-api-definitions1.cs rename to tests/bgen/tests/multiple-api-definitions1.cs diff --git a/tests/generator/multiple-api-definitions2-a.cs b/tests/bgen/tests/multiple-api-definitions2-a.cs similarity index 100% rename from tests/generator/multiple-api-definitions2-a.cs rename to tests/bgen/tests/multiple-api-definitions2-a.cs diff --git a/tests/generator/multiple-api-definitions2-b.cs b/tests/bgen/tests/multiple-api-definitions2-b.cs similarity index 100% rename from tests/generator/multiple-api-definitions2-b.cs rename to tests/bgen/tests/multiple-api-definitions2-b.cs diff --git a/tests/generator/tests/nativeenum-extensions.cs b/tests/bgen/tests/nativeenum-extensions.cs similarity index 100% rename from tests/generator/tests/nativeenum-extensions.cs rename to tests/bgen/tests/nativeenum-extensions.cs diff --git a/tests/generator/tests/nativeenum.cs b/tests/bgen/tests/nativeenum.cs similarity index 100% rename from tests/generator/tests/nativeenum.cs rename to tests/bgen/tests/nativeenum.cs diff --git a/tests/generator/tests/newer-availability-in-inlined-protocol.cs b/tests/bgen/tests/newer-availability-in-inlined-protocol.cs similarity index 100% rename from tests/generator/tests/newer-availability-in-inlined-protocol.cs rename to tests/bgen/tests/newer-availability-in-inlined-protocol.cs diff --git a/tests/generator/tests/nfloat.cs b/tests/bgen/tests/nfloat.cs similarity index 100% rename from tests/generator/tests/nfloat.cs rename to tests/bgen/tests/nfloat.cs diff --git a/tests/generator/tests/nint-delegates.cs b/tests/bgen/tests/nint-delegates.cs similarity index 100% rename from tests/generator/tests/nint-delegates.cs rename to tests/bgen/tests/nint-delegates.cs diff --git a/tests/generator/tests/no-availability-for-accessors.cs b/tests/bgen/tests/no-availability-for-accessors.cs similarity index 100% rename from tests/generator/tests/no-availability-for-accessors.cs rename to tests/bgen/tests/no-availability-for-accessors.cs diff --git a/tests/generator/noasyncinternalwrapper.cs b/tests/bgen/tests/noasyncinternalwrapper.cs similarity index 100% rename from tests/generator/noasyncinternalwrapper.cs rename to tests/bgen/tests/noasyncinternalwrapper.cs diff --git a/tests/generator/noasyncwarningcs0219.cs b/tests/bgen/tests/noasyncwarningcs0219.cs similarity index 100% rename from tests/generator/noasyncwarningcs0219.cs rename to tests/bgen/tests/noasyncwarningcs0219.cs diff --git a/tests/generator/nowarn.cs b/tests/bgen/tests/nowarn.cs similarity index 100% rename from tests/generator/nowarn.cs rename to tests/bgen/tests/nowarn.cs diff --git a/tests/generator/tests/nscopying-nullability.cs b/tests/bgen/tests/nscopying-nullability.cs similarity index 100% rename from tests/generator/tests/nscopying-nullability.cs rename to tests/bgen/tests/nscopying-nullability.cs diff --git a/tests/generator/tests/obsoletedosplatform.cs b/tests/bgen/tests/obsoletedosplatform.cs similarity index 100% rename from tests/generator/tests/obsoletedosplatform.cs rename to tests/bgen/tests/obsoletedosplatform.cs diff --git a/tests/generator/tests/preview.cs b/tests/bgen/tests/preview.cs similarity index 100% rename from tests/generator/tests/preview.cs rename to tests/bgen/tests/preview.cs diff --git a/tests/generator/property-redefination-ios.cs b/tests/bgen/tests/property-redefination-ios.cs similarity index 100% rename from tests/generator/property-redefination-ios.cs rename to tests/bgen/tests/property-redefination-ios.cs diff --git a/tests/generator/property-redefination-mac.cs b/tests/bgen/tests/property-redefination-mac.cs similarity index 100% rename from tests/generator/property-redefination-mac.cs rename to tests/bgen/tests/property-redefination-mac.cs diff --git a/tests/generator/tests/protocol-and-basetype-no-model.cs b/tests/bgen/tests/protocol-and-basetype-no-model.cs similarity index 100% rename from tests/generator/tests/protocol-and-basetype-no-model.cs rename to tests/bgen/tests/protocol-and-basetype-no-model.cs diff --git a/tests/generator/tests/protocol-bind-property.cs b/tests/bgen/tests/protocol-bind-property.cs similarity index 100% rename from tests/generator/tests/protocol-bind-property.cs rename to tests/bgen/tests/protocol-bind-property.cs diff --git a/tests/generator/protocol-duplicate-abstract-error.cs b/tests/bgen/tests/protocol-duplicate-abstract-error.cs similarity index 100% rename from tests/generator/protocol-duplicate-abstract-error.cs rename to tests/bgen/tests/protocol-duplicate-abstract-error.cs diff --git a/tests/generator/protocol-duplicate-abstract.cs b/tests/bgen/tests/protocol-duplicate-abstract.cs similarity index 100% rename from tests/generator/protocol-duplicate-abstract.cs rename to tests/bgen/tests/protocol-duplicate-abstract.cs diff --git a/tests/generator/protocol-duplicate-method-diff-length.cs b/tests/bgen/tests/protocol-duplicate-method-diff-length.cs similarity index 100% rename from tests/generator/protocol-duplicate-method-diff-length.cs rename to tests/bgen/tests/protocol-duplicate-method-diff-length.cs diff --git a/tests/generator/protocol-duplicate-method-diff-out.cs b/tests/bgen/tests/protocol-duplicate-method-diff-out.cs similarity index 100% rename from tests/generator/protocol-duplicate-method-diff-out.cs rename to tests/bgen/tests/protocol-duplicate-method-diff-out.cs diff --git a/tests/generator/protocol-duplicate-method-diff-return.cs b/tests/bgen/tests/protocol-duplicate-method-diff-return.cs similarity index 100% rename from tests/generator/protocol-duplicate-method-diff-return.cs rename to tests/bgen/tests/protocol-duplicate-method-diff-return.cs diff --git a/tests/generator/protocol-duplicate-method-diff-type.cs b/tests/bgen/tests/protocol-duplicate-method-diff-type.cs similarity index 100% rename from tests/generator/protocol-duplicate-method-diff-type.cs rename to tests/bgen/tests/protocol-duplicate-method-diff-type.cs diff --git a/tests/generator/tests/protocols.cs b/tests/bgen/tests/protocols.cs similarity index 100% rename from tests/generator/tests/protocols.cs rename to tests/bgen/tests/protocols.cs diff --git a/tests/generator/tests/ref-out-parameters.cs b/tests/bgen/tests/ref-out-parameters.cs similarity index 100% rename from tests/generator/tests/ref-out-parameters.cs rename to tests/bgen/tests/ref-out-parameters.cs diff --git a/tests/generator/tests/release-attribute.cs b/tests/bgen/tests/release-attribute.cs similarity index 100% rename from tests/generator/tests/release-attribute.cs rename to tests/bgen/tests/release-attribute.cs diff --git a/tests/generator/tests/return-release.cs b/tests/bgen/tests/return-release.cs similarity index 100% rename from tests/generator/tests/return-release.cs rename to tests/bgen/tests/return-release.cs diff --git a/tests/generator/smartenumwithframework.cs b/tests/bgen/tests/smartenumwithframework.cs similarity index 100% rename from tests/generator/smartenumwithframework.cs rename to tests/bgen/tests/smartenumwithframework.cs diff --git a/tests/generator/tests/snippet-attributes.cs b/tests/bgen/tests/snippet-attributes.cs similarity index 100% rename from tests/generator/tests/snippet-attributes.cs rename to tests/bgen/tests/snippet-attributes.cs diff --git a/tests/generator/sof20696157.cs b/tests/bgen/tests/sof20696157.cs similarity index 100% rename from tests/generator/sof20696157.cs rename to tests/bgen/tests/sof20696157.cs diff --git a/tests/generator/strong-dict-native-enum.cs b/tests/bgen/tests/strong-dict-native-enum.cs similarity index 100% rename from tests/generator/strong-dict-native-enum.cs rename to tests/bgen/tests/strong-dict-native-enum.cs diff --git a/tests/generator/strong-dict-support-templated-dicts.cs b/tests/bgen/tests/strong-dict-support-templated-dicts.cs similarity index 100% rename from tests/generator/strong-dict-support-templated-dicts.cs rename to tests/bgen/tests/strong-dict-support-templated-dicts.cs diff --git a/tests/generator/tests/strongdictionary-errors.cs b/tests/bgen/tests/strongdictionary-errors.cs similarity index 100% rename from tests/generator/tests/strongdictionary-errors.cs rename to tests/bgen/tests/strongdictionary-errors.cs diff --git a/tests/generator/tests/types-in-multiple-namespaces.cs b/tests/bgen/tests/types-in-multiple-namespaces.cs similarity index 100% rename from tests/generator/tests/types-in-multiple-namespaces.cs rename to tests/bgen/tests/types-in-multiple-namespaces.cs diff --git a/tests/generator/tests/underlyingfieldtype.cs b/tests/bgen/tests/underlyingfieldtype.cs similarity index 100% rename from tests/generator/tests/underlyingfieldtype.cs rename to tests/bgen/tests/underlyingfieldtype.cs diff --git a/tests/generator/virtualwrap.cs b/tests/bgen/tests/virtualwrap.cs similarity index 100% rename from tests/generator/virtualwrap.cs rename to tests/bgen/tests/virtualwrap.cs diff --git a/tests/generator/tests/vsts-970507.cs b/tests/bgen/tests/vsts-970507.cs similarity index 100% rename from tests/generator/tests/vsts-970507.cs rename to tests/bgen/tests/vsts-970507.cs diff --git a/tests/generator/warnaserror.cs b/tests/bgen/tests/warnaserror.cs similarity index 100% rename from tests/generator/warnaserror.cs rename to tests/bgen/tests/warnaserror.cs diff --git a/tests/generator/tests/xmldocs.cs b/tests/bgen/tests/xmldocs.cs similarity index 100% rename from tests/generator/tests/xmldocs.cs rename to tests/bgen/tests/xmldocs.cs diff --git a/tests/bindings-test/dotnet/shared.csproj b/tests/bindings-test/dotnet/shared.csproj index a1957248ec75..710148d2d1c0 100644 --- a/tests/bindings-test/dotnet/shared.csproj +++ b/tests/bindings-test/dotnet/shared.csproj @@ -27,7 +27,7 @@ - + diff --git a/tests/common/Tool.cs b/tests/common/Tool.cs index 422e63f23788..a213c9ed0554 100644 --- a/tests/common/Tool.cs +++ b/tests/common/Tool.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; @@ -78,7 +79,7 @@ abstract class Tool { List messages = new List (); - public Dictionary? EnvironmentVariables { get; set; } + public Dictionary EnvironmentVariables { get; set; } = new (); public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds (60); #pragma warning disable 0649 // Field 'X' is never assigned to, and will always have its default value Y public string? WorkingDirectory; @@ -171,7 +172,9 @@ public static void ParseMessages (List messages, string [] lines, s { foreach (var l in lines) { var line = l; - var msg = new ToolMessage (); + var msg = new ToolMessage () { + Message = string.Empty, + }; var origin = string.Empty; if (IndexOfAny (line, out var idxError, out var endError, ": error ", ": error ")) { @@ -231,7 +234,7 @@ public void ParseMessages () ParseMessages (messages, output.ToString ().Split ('\n', '\r'), MessageToolName); } - static bool TrySplitCode (string? code, out string? prefix, out int number) + static bool TrySplitCode (string? code, [NotNullWhen (true)] out string? prefix, out int number) { prefix = null; number = -1; @@ -258,18 +261,18 @@ public void ParseBinLog (string binlog) if (buildLogEvent.Type != BuildLogEventType.Error && buildLogEvent.Type != BuildLogEventType.Warning) continue; - var msg = new ToolMessage (); + var msg = new ToolMessage () { + IsError = buildLogEvent.Type == BuildLogEventType.Error, + Message = buildLogEvent.Message ?? "", + LineNumber = buildLogEvent.LineNumber, + FileName = buildLogEvent.File ?? "" + }; if (TrySplitCode (buildLogEvent.Code, out var prefix, out var number)) { msg.Prefix = prefix ?? ""; msg.Number = number; } - msg.IsError = buildLogEvent.Type == BuildLogEventType.Error; - msg.Message = buildLogEvent.Message ?? ""; - msg.LineNumber = buildLogEvent.LineNumber; - msg.FileName = buildLogEvent.File ?? ""; - messages.Add (msg); } } @@ -324,7 +327,7 @@ public static void AssertWarningCount (IEnumerable messages, int co public void AssertErrorCount (int count, string message = "errors") { - Assert.AreEqual (count, ErrorCount, message); + Assert.That (ErrorCount, Is.EqualTo (count), message); } public void AssertErrorPattern (int number, string messagePattern, string? filename = null, int? linenumber = null, bool custom_pattern_syntax = false) @@ -454,7 +457,7 @@ public void AssertNoWarnings () if (!warnings.Any ()) return; - Assert.Fail ("No warnings expected, but got:\n{0}\t", string.Join ("\n\t", warnings.Select ((v) => v.Message).ToArray ())); + Assert.Fail ($"No warnings expected, but got:\n{string.Join ("\n\t", warnings.Select ((v) => v.Message).ToArray ())}\t"); } public void AssertNoMessage (int number) @@ -463,7 +466,7 @@ public void AssertNoMessage (int number) if (!msgs.Any ()) return; - Assert.Fail ("No messages with number {0} expected, but got:\n{1}\t", number, string.Join ("\n\t", msgs.Select ((v) => v.Message).ToArray ())); + Assert.Fail ($"No messages with number {number} expected, but got:\n{string.Join ("\n\t", msgs.Select ((v) => v.Message).ToArray ())}\t"); } public bool HasOutput (string line) diff --git a/tests/generator/.gitignore b/tests/generator/.gitignore deleted file mode 100644 index 9ec1f99dd294..000000000000 --- a/tests/generator/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.source -*.tmpdir diff --git a/tests/generator/Makefile b/tests/generator/Makefile deleted file mode 100644 index bfb03df5df97..000000000000 --- a/tests/generator/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP=../.. - -include $(TOP)/Make.config - -export TargetFrameworkFallbackSearchPaths=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild-frameworks -export MSBuildExtensionsPathFallbackPathsOverride=$(IOS_DESTDIR)/Library/Frameworks/Mono.framework/External/xbuild - -all-local:: run-unit-tests - -build-unit-tests: - $(Q_XBUILD) $(SYSTEM_MSBUILD) -t -- /Library/Frameworks//Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore $(TOP)/src/generator.sln - $(SYSTEM_MSBUILD) generator-tests.csproj $(XBUILD_VERBOSITY) - -run-tests run-unit-tests: build-unit-tests - rm -f .failed-stamp - $(TOP)/tools/nunit3-console-3.11.1 $(abspath $(TOP)/tests/generator/bin/Debug/generator-tests.dll) "--result=$(abspath $(CURDIR)/TestResult.xml);format=nunit2" $(TEST_FIXTURE) --labels=After || touch $(CURDIR)/.failed-stamp - @# Create an html file and tell MonkeyWrench to upload it (if we're running there) - @[[ -z "$$BUILD_REPOSITORY" ]] || \ - ( xsltproc $(TOP)/tests/HtmlTransform.xslt TestResult.xml > index.html && \ - echo "@MonkeyWrench: AddFile: $$PWD/index.html") - @[[ ! -e .failed-stamp ]] - -clean-local:: - rm -Rf bin diff --git a/tests/generator/generator-tests.csproj b/tests/generator/generator-tests.csproj deleted file mode 100644 index 0a39b4fab9c5..000000000000 --- a/tests/generator/generator-tests.csproj +++ /dev/null @@ -1,110 +0,0 @@ - - - - - Debug - AnyCPU - {10790816-D00E-40A0-8653-2A8AB4DD33A9} - Library - generatortests - generator-tests - v4.8 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - latest - - - true - bin\Release - prompt - 4 - latest - - - - - - - - - - - - - - SdkVersions.cs - - - NullableAttributes.cs - - - - - - - - ExecutionHelper.cs - - - Configuration.cs - - - ConfigurationNUnit.cs - - - Cache.cs - - - StringUtils.cs - - - NullableAttributes.cs - - - - - - - - - - Profile.cs - - - Tool.cs - - - BinLog.cs - - - - - - - - - - - - - - - - - - - - - {D2EE02C0-9BFD-477D-AC92-4DE2D8490790} - generator - - - -