nunit / nunit.analyzers

Roslyn analyzers for writing unit tests with NUnit
MIT License
88 stars 32 forks source link

Augment SameAsIncompatibleTypes and EqualToIncompatibleTypes to apply for more cases #279

Closed manfred-brands closed 4 years ago

manfred-brands commented 4 years ago

The Assert.That constraints work on type object and the compiler doesn't detect comparing non-matching types. The rules SameAsIncompatibleTypes and EqualToIncompatibleTypes made a good start on this but there are many other asserts.

This ticket is to augment these rules to:

The compiler is also happy to allow:

object instance1 = new object();
object instance2 = new object();
Assert.That(instance1, Is.LessThan(instance2));

but it does not allow:

Assert.Less(instance1, instance2);

Augment the incompatible type check to verify that the types implement IComparable where needed or add a new Comparable analyzer.

manfred-brands commented 4 years ago

I will work on this.