Created
July 21, 2010 08:35
-
-
Save follesoe/484229 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.Collections; | |
using System.Collections.Generic; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace KS.Bestandsrapportering.TestInfrastruktur | |
{ | |
public static class TestExtensions | |
{ | |
public static void SkalVæreLik(this object valueToTest, object expected) | |
{ | |
Assert.AreEqual(expected, valueToTest); | |
} | |
public static void SkalVæreLik(this object valueToTest, object expected, string message) | |
{ | |
Assert.AreEqual(expected, valueToTest, message); | |
} | |
public static void VæreLik(this object valueToTest, object expected) | |
{ | |
Assert.AreEqual(expected, valueToTest); | |
} | |
public static void SkalVæreStørreEnn(this double verdi, double sammenlign) | |
{ | |
Assert.IsTrue(verdi > sammenlign); | |
} | |
public static void SkalVæreMindreEnn(this double verdi, double sammenlign) | |
{ | |
Assert.IsTrue(verdi < sammenlign, string.Format("{0} er ikke mindre enn {1}!", verdi, sammenlign)); | |
} | |
public static void SkalIkkeVæreLik(this object valueToTest, object expected) | |
{ | |
Assert.AreNotEqual(expected, valueToTest); | |
} | |
public static void IkkeVæreLik(this object valueToTest, object expected) | |
{ | |
Assert.AreNotEqual(expected, valueToTest); | |
} | |
public static void SkalIkkeVæreNull(this object valueToTest) | |
{ | |
Assert.IsNotNull(valueToTest); | |
} | |
public static void IkkeVæreNull(this object valueToTest) | |
{ | |
Assert.IsNotNull(valueToTest); | |
} | |
public static void SkalVæreNull(this object valueToTest) | |
{ | |
Assert.IsNull(valueToTest); | |
} | |
public static void ShouldBeSameAs(this object valueToTest, object expected) | |
{ | |
Assert.AreSame(valueToTest, expected); | |
} | |
public static void ShouldNotBeSameAs(this object valueToTest, object expected) | |
{ | |
Assert.AreNotSame(valueToTest, expected); | |
} | |
public static void SkalVæreSann(this bool valueToTest) | |
{ | |
Assert.IsTrue(valueToTest); | |
} | |
public static void SkalVæreSann(this bool valueToTest, string message) | |
{ | |
Assert.IsTrue(valueToTest, message); | |
} | |
public static void VæreSann(this bool valueToTest) | |
{ | |
Assert.IsTrue(valueToTest); | |
} | |
public static void SkalVæreUsann(this bool valueToTest) | |
{ | |
Assert.IsFalse(valueToTest); | |
} | |
public static void SkalVæreUsann(this bool valueToTest, string message) | |
{ | |
Assert.IsFalse(valueToTest, message); | |
} | |
public static void VæreUsann(this bool valueToTest) | |
{ | |
Assert.IsFalse(valueToTest); | |
} | |
public static void SkalVæreInstansAv<T>(this object valueToTest) | |
{ | |
Assert.IsInstanceOfType(valueToTest, typeof(T)); | |
} | |
public static void ShouldBeInstanceOfType<T>(this object valueToTest) | |
{ | |
Assert.IsInstanceOfType(valueToTest, typeof(T)); | |
} | |
public static void ShouldNotBeInstanceOfType<T>(this object valueToTest) | |
{ | |
Assert.IsNotInstanceOfType(valueToTest, typeof(T)); | |
} | |
public static void ShouldBeEmpty(this IList list) | |
{ | |
Assert.AreEqual(0, list.Count); | |
} | |
public static void SkalInneholdeElementer(this IList list) | |
{ | |
Assert.IsTrue(list.Count > 0); | |
} | |
public static void SkalInneholdeElementer(this IList list, string beskjed) | |
{ | |
Assert.IsTrue(list.Count > 0, beskjed); | |
} | |
public static void InneholdeElementer(this IList list) | |
{ | |
Assert.IsTrue(list.Count > 0); | |
} | |
public static void SkalIkkeInneholdeElementer(this IList list) | |
{ | |
Assert.AreEqual(0, list.Count); | |
} | |
public static void IkkeInneholdeElementer(this IList list) | |
{ | |
Assert.AreEqual(0, list.Count); | |
} | |
public static void SkalInneholdeElementer<T>(this IList<T> list, int antallElementer) | |
{ | |
Assert.AreEqual(antallElementer, list.Count); | |
} | |
public static void SkalInneholdeElementer<T>(this IList<T> list, int antallElementer, string beskjed) | |
{ | |
Assert.AreEqual(antallElementer, list.Count, beskjed); | |
} | |
public static void InneholdeElementer<T>(this IList<T> list, int antallElementer) | |
{ | |
Assert.AreEqual(antallElementer, list.Count); | |
} | |
public static void ShouldContain(this IList list, object expectedObject) | |
{ | |
var index = list.IndexOf(expectedObject); | |
if (index == -1) | |
{ | |
Assert.Fail("Expected object was not in list"); | |
} | |
} | |
public static void ShouldHave(this IList list, int expectedCount) | |
{ | |
Assert.AreEqual(expectedCount, list.Count); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment