Skip to content

Instantly share code, notes, and snippets.

@johnnonolan
Last active December 12, 2015 10:18
Show Gist options
  • Save johnnonolan/4757737 to your computer and use it in GitHub Desktop.
Save johnnonolan/4757737 to your computer and use it in GitHub Desktop.
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);
}
}
}
}
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));
}
}
}
@johnnonolan
Copy link
Author

I like this.. I started writing ext methods for all primitive datatypes but generics just add so much awesome sauce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment