Last active
December 12, 2015 10:18
-
-
Save johnnonolan/4757737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NUnit.Framework; | |
namespace Tersely.Tests | |
{ | |
[TestFixture()] | |
public class Test | |
{ | |
[Test()] | |
public void TestCase () | |
{ | |
(6 * 7).ShouldBe(42); | |
} | |
[Test] | |
public void TestGeneric () | |
{ | |
var x = new X(); | |
x.compareMe = "y"; | |
var y = new X(); | |
y.compareMe = "y"; | |
x.ShouldBe(y); | |
} | |
class X { | |
public string compareMe { | |
get; | |
set; | |
} | |
public override int GetHashCode () | |
{ | |
return base.GetHashCode (); | |
} | |
public override bool Equals (object obj) | |
{ | |
return compareMe.Equals( ((X) obj).compareMe); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NUnit.Framework; | |
namespace Tersely | |
{ | |
public static class Tersely | |
{ | |
public static void ShouldBe<T> (this T actual, T expected) | |
{ | |
Assert.That(actual,Is.EqualTo(expected)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this.. I started writing ext methods for all primitive datatypes but generics just add so much awesome sauce.