Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a0734ea
Use centralized NUnit package versions from Directory.Build.props
rolfbjarne May 7, 2026
2dd4fba
Fix NUnit v4 API breaking changes
rolfbjarne May 7, 2026
8dc3951
Add NUnit.Framework.Legacy using to SDK-style test projects
rolfbjarne May 7, 2026
380dbe3
Migrate classic assertions to ClassicAssert in dotnet UnitTests and x…
rolfbjarne May 7, 2026
52578c0
Migrate classic assertions in on-device and linker test projects
rolfbjarne May 8, 2026
1b70710
Fix remaining NUnit 4 assertion issues
rolfbjarne May 8, 2026
42f5418
Fix NUnit 4 assertions in remaining test projects
rolfbjarne May 8, 2026
780c4ec
Fix Assert.Fail and Assert.That format-arg calls in introspection tests
rolfbjarne May 8, 2026
e5a3919
Fix NLTaggerTest NSString message and RecordTest StringUtil references
rolfbjarne May 8, 2026
d182f6d
Convert ClassicAssert to Assert.That constraint syntax
rolfbjarne May 8, 2026
6b21613
Fix broken lambda conversions in Assert.That calls
rolfbjarne May 8, 2026
85266c0
Fix remaining broken lambda conversions in Assert.That calls
rolfbjarne May 8, 2026
7df86ee
Fix .Within(message) misconversions where message was treated as tole…
rolfbjarne May 8, 2026
2434b1d
Fix Assert.That format-arg messages in introspection and other tests
rolfbjarne May 8, 2026
af6c53c
Auto-format source code
May 8, 2026
5db6a9c
Add nunit.framework.legacy.dll to expected bundle files
rolfbjarne May 11, 2026
4ab19b6
Fix monotouch-test compilation errors for NUnit v4
rolfbjarne May 11, 2026
42e54c7
Fix NUnit v4 test failures in monotouch-test (macOS)
rolfbjarne May 13, 2026
7995c30
Fix FetchResultTest: handle empty photo library on simulator
rolfbjarne May 14, 2026
b64210a
Revert "Fix FetchResultTest: handle empty photo library on simulator"
rolfbjarne May 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-t4": {
"version": "2.2.1",
"version": "3.0.0",
"commands": [
"t4"
],
Expand Down
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<NUnit3TestAdapterPackageVersion>6.1.0</NUnit3TestAdapterPackageVersion>
<NUnitAnalyzersPackageVersion>4.7.0</NUnitAnalyzersPackageVersion>
<NUnitPackageVersion>4.4.0</NUnitPackageVersion>
<NUnitLitePackageVersion>$(NUnitPackageVersion)</NUnitLitePackageVersion>
<NUnitV2ResultWriterPackageVersion>3.8.0</NUnitV2ResultWriterPackageVersion>

<!-- Use the latest C# version by default -->
<LangVersion Condition="'$(LangVersion)' == ''">latest</LangVersion>
Expand Down
6 changes: 3 additions & 3 deletions tests/BundledResources/ResourcesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void Bundled ()
// files are extracted (by MonoDevelop) so we can see them in the file system
// that's true for simulator or devices and whatever the linker settings are
var dir = NSBundle.MainBundle.ResourcePath!;
Assert.True (File.Exists (Path.Combine (dir, "basn3p08.png")), "file-basn3p08.png");
Assert.True (File.Exists (Path.Combine (dir, "basn3p08_with_loc.png")), "file-basn3p08_with_loc.png");
Assert.True (File.Exists (Path.Combine (dir, "xamvideotest.mp4")), "xamvideotest.mp4");
Assert.That (File.Exists (Path.Combine (dir, "basn3p08.png")), Is.True, "file-basn3p08.png");
Assert.That (File.Exists (Path.Combine (dir, "basn3p08_with_loc.png")), Is.True, "file-basn3p08_with_loc.png");
Assert.That (File.Exists (Path.Combine (dir, "xamvideotest.mp4")), Is.True, "xamvideotest.mp4");

// resources are removed by the linker or an extra step (e.g. "link sdk" or "don't link") but that
// extra step is done only on device (to keep the simulator builds as fast as possible)
Expand Down
14 changes: 7 additions & 7 deletions tests/EmbeddedResources/ResourcesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class ResourcesTest {
public void Embedded ()
{
var manager = new ResourceManager ("EmbeddedResources.Welcome", typeof (ResourcesTest).Assembly);
Assert.AreEqual ("Welcome", manager.GetString ("String1", new CultureInfo ("en")), "en");
Assert.AreEqual ("G'day", manager.GetString ("String1", new CultureInfo ("en-AU")), "en-AU");
Assert.AreEqual ("Willkommen", manager.GetString ("String1", new CultureInfo ("de")), "de");
Assert.AreEqual ("Willkommen", manager.GetString ("String1", new CultureInfo ("de-DE")), "de-DE");
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es")), "es");
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es-AR")), "es-AR");
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es-ES")), "es-ES");
Assert.That (manager.GetString ("String1", new CultureInfo ("en")), Is.EqualTo ("Welcome"), "en");
Assert.That (manager.GetString ("String1", new CultureInfo ("en-AU")), Is.EqualTo ("G'day"), "en-AU");
Assert.That (manager.GetString ("String1", new CultureInfo ("de")), Is.EqualTo ("Willkommen"), "de");
Assert.That (manager.GetString ("String1", new CultureInfo ("de-DE")), Is.EqualTo ("Willkommen"), "de-DE");
Assert.That (manager.GetString ("String1", new CultureInfo ("es")), Is.EqualTo ("Bienvenido"), "es");
Assert.That (manager.GetString ("String1", new CultureInfo ("es-AR")), Is.EqualTo ("Bienvenido"), "es-AR");
Assert.That (manager.GetString ("String1", new CultureInfo ("es-ES")), Is.EqualTo ("Bienvenido"), "es-ES");
}
}
}
90 changes: 45 additions & 45 deletions tests/bindings-test/ProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ public void Constructors ()
using var dateNow = (NSDate) DateTime.Now;

using (var obj = IConstructorProtocol.CreateInstance<TypeProvidingProtocolConstructors> ("Hello world")!) {
Assert.AreEqual ("Hello world", obj.StringValue, "A StringValue");
Assert.IsNull (obj.DateValue, "A DateValue");
Assert.That (obj.StringValue, Is.EqualTo ("Hello world"), "A StringValue");
Assert.That (obj.DateValue, Is.Null, "A DateValue");
}

using (var obj = IConstructorProtocol.CreateInstance<TypeProvidingProtocolConstructors> (dateNow)!) {
Assert.IsNull (obj.StringValue, "B StringValue");
Assert.AreEqual (dateNow, obj.DateValue, "B DateValue");
Assert.That (obj.StringValue, Is.Null, "B StringValue");
Assert.That (obj.DateValue, Is.EqualTo (dateNow), "B DateValue");
}

using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors> ("Hello Subclassed")!) {
Assert.AreEqual ("Hello Subclassed", obj.StringValue, "C1 StringValue");
Assert.IsNull (obj.DateValue, "C1 DateValue");
Assert.That (obj.StringValue, Is.EqualTo ("Hello Subclassed"), "C1 StringValue");
Assert.That (obj.DateValue, Is.Null, "C1 DateValue");
}

using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors> (dateNow)!) {
Assert.IsNull (obj.StringValue, "C2 StringValue");
Assert.AreEqual (dateNow, obj.DateValue, "C2 DateValue");
Assert.That (obj.StringValue, Is.Null, "C2 StringValue");
Assert.That (obj.DateValue, Is.EqualTo (dateNow), "C2 DateValue");
}

if (global::XamarinTests.ObjCRuntime.Registrar.IsDynamicRegistrar) {
Expand All @@ -60,8 +60,8 @@ public void Constructors ()
}, "D1 Exception");
} else {
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> ("Hello Subclassed 2")!) {
Assert.AreEqual ("Managed interceptor! Hello Subclassed 2", obj.StringValue, "D1 StringValue");
Assert.IsNull (obj.DateValue, "D1 DateValue");
Assert.That (obj.StringValue, Is.EqualTo ("Managed interceptor! Hello Subclassed 2"), "D1 StringValue");
Assert.That (obj.DateValue, Is.Null, "D1 DateValue");
}
}

Expand All @@ -71,8 +71,8 @@ public void Constructors ()
}, "D2 Exception");
} else {
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> (dateNow)!) {
Assert.IsNull (obj.StringValue, "D2 StringValue");
Assert.AreEqual (dateNow.AddSeconds (42), obj.DateValue, "D2 DateValue");
Assert.That (obj.StringValue, Is.Null, "D2 StringValue");
Assert.That (obj.DateValue, Is.EqualTo (dateNow.AddSeconds (42)), "D2 DateValue");
}
}
}
Expand Down Expand Up @@ -107,27 +107,27 @@ public void OnlyProtocol ()

// the interface must be created
var IP1 = bindingAssembly.GetType ("Bindings.Test.Protocol.IP1")!;
Assert.IsNotNull (IP1, "IP1");
Assert.That (IP1, Is.Not.Null, "IP1");
// with a [Protocol] attribute
var IP1Attributes = IP1.GetCustomAttributes (typeof (ProtocolAttribute), false);
if (HasProtocolAttributes) {
Assert.AreEqual (1, IP1Attributes.Length, "[Protocol] IP1");
Assert.That (IP1Attributes.Length, Is.EqualTo (1), "[Protocol] IP1");
var IP1Protocol = (ProtocolAttribute) IP1Attributes [0];
Assert.AreEqual ("P1", IP1Protocol.Name, "Name");
Assert.That (IP1Protocol.Name, Is.EqualTo ("P1"), "Name");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P1Wrapper");
Assert.IsNotNull (wrapperType, "P1_Wrapper");
Assert.AreEqual (wrapperType, IP1Protocol.WrapperType, "WrapperType");
Assert.That (wrapperType, Is.Not.Null, "P1_Wrapper");
Assert.That (IP1Protocol.WrapperType, Is.EqualTo (wrapperType), "WrapperType");
} else {
Assert.AreEqual (0, IP1Attributes.Length, "[Protocol] IP1");
Assert.That (IP1Attributes.Length, Is.EqualTo (0), "[Protocol] IP1");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P1Wrapper");
Assert.IsNotNull (wrapperType, "P1_Wrapper");
Assert.That (wrapperType, Is.Not.Null, "P1_Wrapper");
}
// but not the model
Assert.IsNull (bindingAssembly.GetType ("Bindings.Test.Protocol.P1"), "P1");
Assert.That (bindingAssembly.GetType ("Bindings.Test.Protocol.P1"), Is.Null, "P1");
}

[Test]
Expand All @@ -139,32 +139,32 @@ public void ProtocolWithBaseType ()

// the interface must be created
var IP2 = bindingAssembly.GetType ("Bindings.Test.Protocol.IP2")!;
Assert.IsNotNull (IP2, "IP2");
Assert.That (IP2, Is.Not.Null, "IP2");

// with a [Protocol] attribute
var IP2Attributes = IP2.GetCustomAttributes (typeof (ProtocolAttribute), false);
if (HasProtocolAttributes) {
Assert.AreEqual (1, IP2Attributes.Length, "[Protocol] IP2");
Assert.That (IP2Attributes.Length, Is.EqualTo (1), "[Protocol] IP2");
var IP2Protocol = (ProtocolAttribute) IP2Attributes [0];
Assert.AreEqual ("P2", IP2Protocol.Name, "Name");
Assert.That (IP2Protocol.Name, Is.EqualTo ("P2"), "Name");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P2Wrapper");
Assert.IsNotNull (wrapperType, "P2_Wrapper");
Assert.AreEqual (wrapperType, IP2Protocol.WrapperType, "WrapperType");
Assert.That (wrapperType, Is.Not.Null, "P2_Wrapper");
Assert.That (IP2Protocol.WrapperType, Is.EqualTo (wrapperType), "WrapperType");
} else {
Assert.AreEqual (0, IP2Attributes.Length, "[Protocol] IP2");
Assert.That (IP2Attributes.Length, Is.EqualTo (0), "[Protocol] IP2");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P2Wrapper");
Assert.IsNotNull (wrapperType, "P2_Wrapper");
Assert.That (wrapperType, Is.Not.Null, "P2_Wrapper");
}

// and a model-like class
var model = bindingAssembly.GetType ("Bindings.Test.Protocol.P2")!;
Assert.IsNotNull (model, "P2");
Assert.That (model, Is.Not.Null, "P2");
// but without the [Model] attribute
Assert.False (model.IsDefined (typeof (ModelAttribute), false), "model");
Assert.That (model.IsDefined (typeof (ModelAttribute), false), Is.False, "model");
}

[Test]
Expand All @@ -176,32 +176,32 @@ public void ProtocolWithBaseTypeAndModel ()

// the interface must be created
var IP3 = bindingAssembly.GetType ("Bindings.Test.Protocol.IP3")!;
Assert.IsNotNull (IP3, "IP3");
Assert.That (IP3, Is.Not.Null, "IP3");

// with a [Protocol] attribute
var IP3Attributes = IP3.GetCustomAttributes (typeof (ProtocolAttribute), false);
if (HasProtocolAttributes) {
Assert.AreEqual (1, IP3Attributes.Length, "[Protocol] IP3");
Assert.That (IP3Attributes.Length, Is.EqualTo (1), "[Protocol] IP3");
var IP3Protocol = (ProtocolAttribute) IP3Attributes [0];
Assert.AreEqual ("P3", IP3Protocol.Name, "Name");
Assert.That (IP3Protocol.Name, Is.EqualTo ("P3"), "Name");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P3Wrapper");
Assert.IsNotNull (wrapperType, "P3_Wrapper");
Assert.AreEqual (wrapperType, IP3Protocol.WrapperType, "WrapperType");
Assert.That (wrapperType, Is.Not.Null, "P3_Wrapper");
Assert.That (IP3Protocol.WrapperType, Is.EqualTo (wrapperType), "WrapperType");
} else {
Assert.AreEqual (0, IP3Attributes.Length, "[Protocol] IP3");
Assert.That (IP3Attributes.Length, Is.EqualTo (0), "[Protocol] IP3");

// and a wrapper type
var wrapperType = bindingAssembly.GetType ("Bindings.Test.Protocol.P3Wrapper");
Assert.IsNotNull (wrapperType, "P3_Wrapper");
Assert.That (wrapperType, Is.Not.Null, "P3_Wrapper");
}

// and a model class
var model = bindingAssembly.GetType ("Bindings.Test.Protocol.P3")!;
Assert.IsNotNull (model, "P3");
Assert.That (model, Is.Not.Null, "P3");
// with a [Model] attribute
Assert.True (model.IsDefined (typeof (ModelAttribute), false), "model");
Assert.That (model.IsDefined (typeof (ModelAttribute), false), Is.True, "model");
}

class MembersImplementation : NSObject, Bindings.Test.Protocol.IMemberAttributes {
Expand Down Expand Up @@ -230,14 +230,14 @@ void CleanupSignatures (objc_method_description [] methods)
public void ProtocolMembers ()
{
IntPtr protocol = objc_getProtocol ("MemberAttributes");
Assert.AreNotEqual (IntPtr.Zero, protocol, "a");
Assert.That (protocol, Is.Not.EqualTo (IntPtr.Zero), "a");

objc_method_description [] methods;

// Required instance methods
methods = protocol_copyMethodDescriptionList (protocol, true, true);
CleanupSignatures (methods);
Assert.AreEqual (4, methods.Length, "Required Instance Methods: Count");
Assert.That (methods.Length, Is.EqualTo (4), "Required Instance Methods: Count");
AssertContains (methods, new objc_method_description ("requiredInstanceMethod", "v@:"), "Required Instance Methods: requiredInstanceMethod");
AssertContains (methods, new objc_method_description ("requiredInstanceProperty", "@@:"), "Required Instance Methods: requiredInstanceProperty");
AssertContains (methods, new objc_method_description ("setRequiredInstanceProperty:", "v@:@"), "Required Instance Methods: setRequiredInstanceProperty");
Expand All @@ -246,15 +246,15 @@ public void ProtocolMembers ()
// Required static methods
methods = protocol_copyMethodDescriptionList (protocol, true, false);
CleanupSignatures (methods);
Assert.AreEqual (3, methods.Length, "Required Static Methods: Count");
Assert.That (methods.Length, Is.EqualTo (3), "Required Static Methods: Count");
AssertContains (methods, new objc_method_description ("requiredStaticMethod", "v@:"), "Required Static Methods: requiredStaticMethod");
AssertContains (methods, new objc_method_description ("setRequiredStaticProperty:", "v@:@"), "Required Static Methods: setRequiredStaticProperty:");
AssertContains (methods, new objc_method_description ("requiredStaticProperty", "@@:"), "Required Static Methods: requiredStaticProperty");

// Optional instance methods
methods = protocol_copyMethodDescriptionList (protocol, false, true);
CleanupSignatures (methods);
Assert.AreEqual (19, methods.Length, "Optional Instance Methods: Count");
Assert.That (methods.Length, Is.EqualTo (19), "Optional Instance Methods: Count");
AssertContains (methods, new objc_method_description ("variadicMethod:", "v@:^v"), "Optional Instance Methods: variadicMethod:");
AssertContains (methods, new objc_method_description ("methodWithReturnType", "@@:"), "Optional Instance Methods: methodWithReturnType");
AssertContains (methods, new objc_method_description ("methodWithParameter:", "v@:i"), "Optional Instance Methods: methodWithParameter:");
Expand All @@ -278,7 +278,7 @@ public void ProtocolMembers ()
// Optional static methods
methods = protocol_copyMethodDescriptionList (protocol, false, false);
CleanupSignatures (methods);
Assert.AreEqual (3, methods.Length, "Optional Static Methods: Count");
Assert.That (methods.Length, Is.EqualTo (3), "Optional Static Methods: Count");
AssertContains (methods, new objc_method_description ("optionalStaticMethod", "v@:"), "Optional Static Methods: optionalStaticMethod");
AssertContains (methods, new objc_method_description ("optionalStaticProperty", "@@:"), "Optional Static Methods: optionalStaticProperty");
AssertContains (methods, new objc_method_description ("setOptionalStaticProperty:", "v@:@"), "Optional Static Methods: setOptionalStaticProperty:");
Expand All @@ -290,9 +290,9 @@ public void ProtocolMembers ()
// see file objc4-647/runtime/objc-runtime-old.mm in Apple's open source code),
// so we need to verify differently for the dynamic registrar.
if (XamarinTests.ObjCRuntime.Registrar.IsStaticRegistrar) {
Assert.AreEqual (9, properties.Length, "Properties: Count");
Assert.That (properties.Length, Is.EqualTo (9), "Properties: Count");
} else {
Assert.AreEqual (2, properties.Length, "Properties: Count");
Assert.That (properties.Length, Is.EqualTo (2), "Properties: Count");
}

AssertContains (properties, new objc_property ("requiredInstanceProperty", "T@\"NSString\",N", new objc_property_attribute [] {
Expand Down
Loading
Loading