CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of MBUnit
C#
[Test, ExpectedException(typeof(ArgumentNullException))]
private void MyTest()
{
 ///
}
by bnaya   December 06, 2010 @ 3:12am
Tags: MBUnit, Test
186 Views
no comments
 
C#
[Test]
[ThreadedRepeat(5)]
public void Should_handle_multithreaded_access()
{
    Assert.IsNotEmpty(MyClass.GetExpensiveString());
} 
by bnaya   November 30, 2010 @ 5:58am
Tags: MBUnit, Test
194 Views
no comments
 
C#
// This example reads data from an Embedded Resource 
// called Data.bin within the same namespace as the test fixture. 
 
 
[Test]
public void ShoppingCartTotalWithSingleItem(
  [BinaryData(ResourcePath = "Data.bin")] byte[] data)
{
    // Code logic here...
}
by bnaya   November 14, 2010 @ 11:00am
Tags: MBUnit, Test
193 Views
no comments
 
C#
[Test] 
public void MyTest(
  [Column(1, 2, 3)] int x, 
  [Column("a", "b")] string y, 
  [Column(0.1, 0.2)] double z)
{ 
  // This test will run 3 * 2 * 2 = 12 times with all combinations of 
  // the values specified in the column for each parameter. This test 
  // is combinatorial because the values are assigned to each parameter 
  // separately.
by bnaya   November 14, 2010 @ 10:58am
Tags: MBUnit, Test
140 Views
no comments
 
C#
[Comparer]
public static int Compare(Foo x, Foo y)
{
    return /* Insert comparison logic here... */
}
[Converter]
public static Pen KnownColorToPen(KnownColor knownColor)
{
    return new Pen(Color.FromKnownColor(knownColor));
}
by bnaya   November 14, 2010 @ 10:54am
Tags: MBUnit, Test
152 Views
no comments
 
C#
[Test]
[CsvData(ResourcePath = "Data.csv")]
public void ShoppingCartTotalWithSingleItem(string item, decimal unitPrice, decimal quantity)
{
    ShoppingCart shoppingCart = new ShoppingCart();
    shoppingCart.Add(item, unitprice, quantity);
    Assert.AreEqual(unitPrice * quantity, shoppingCart.TotalCost);
}
by bnaya   November 14, 2010 @ 10:52am
Tags: MBUnit, Test
144 Views
no comments
 
C#
[TestFixture]
public class MyTestFixture
{
    [Test]
    [Impersonate(UserName = "Julius Caesar", Password = "VeniVidiVici")]
    public void MyTest()
    {
        // Some test logic here...
    }
}
by bnaya   November 14, 2010 @ 10:48am
Tags: MBUnit, Test
210 Views
no comments
 
C#
[TestFixture]
public class MyTestFixture
{
    [Test]
    [MultipleCulture("en-US", "en-GB")]
    public void CheckCurrencySymbol()
    {
        Assert.AreEqual("$4.50", String.Format("{0:C}", 4.5d);
    }
}
by bnaya   November 14, 2010 @ 10:44am
Tags: MBUnit, Test
186 Views
no comments
 
C#
// Specifies that a test can be run in
// parallel with other parallelizable tests
 
public class Fixture
{
    // may run in parallel with test 2
    [Parallelizable]
    public void Test1() { ... }
 
    // may run in parallel with test 1
by bnaya   November 14, 2010 @ 10:42am
Tags: MBUnit, Test
171 Views
no comments
 
C#
[Header("Parameter1", "Parameter2")]
[Row(1, "a")]
[Row(2, "b")]
public class Fixture
{
    [Parameter]
    public int Parameter1;
 
    [Parameter]
    public string Parameter2 { get; set; }
by bnaya   November 14, 2010 @ 10:41am
Tags: MBUnit, Test
144 Views
no comments
 
C#
public class MyPrincipalAttribute : PrincipalAttribute
{
    protected override IPrincipal CreatePrincipal()
    {
        // Create or retrieve the principal...
    }
}
 
[TestFixture]
public class MyTestFixture
by bnaya   November 14, 2010 @ 10:40am
Tags: MBUnit, Test
132 Views
no comments
 
C#
[Test]
public void MyTestMethod([RandomNumbers(Minimum = 0, Maximum = 10, Count = 3)] decimal value)
{
    // This test will run 3 times. It generates at each iteration
    // a decimal number between 0 and 10.
}
 
by bnaya   November 14, 2010 @ 10:39am
Tags: MBUnit, Test
129 Views
no comments
 
C#
[Test]
[Row(1, "a", 0.1)]
[Row(2, "b", 0.2)]
public void MyTest(int x, string y, double z)
{
    // This test will run twice.  Once with x = 1, y = "a", and z = 0.1
    // then again with x = 2, y = "b", and z = 0.2.
}
by bnaya   November 14, 2010 @ 10:37am
Tags: MBUnit, Test
137 Views
no comments
 
C#
[Test]
public void MyTestMethod2(
     [SequentialNumbers(Start = 0, End = 10, Count = 5)] decimal value)
{
    // This test will run 5 times with the values 0, 2.5, 5, 7.5, and 10.
}
 
by bnaya   November 14, 2010 @ 10:33am
Tags: MBUnit, Test
174 Views
no comments
 
C#
[TestFixture]
public class MyTestFixture
{
    [Test]
    public void MyTestMethod([RandomStrings(Count = 3, Pattern = @"[A-Z]{5,8}")] string text)
    {
        // This test will run 3 times. It generates at each iteration
        // a random string containing 5 to 8 uppercase alphabetic characters.
    }
}
by bnaya   November 14, 2010 @ 10:31am
Tags: MBUnit, Test
186 Views
no comments
 
C#
[Test]
    [XmlData("//item", ResourcePath = "Data.xml")]
    public void ShoppingCartTotalWithSingleItem(
        [Bind("@name")] string item, 
        [Bind("unitPrice")] decimal unitPrice, 
        [Bind("quantity")] decimal quantity)
    {
        var shoppingCart = new ShoppingCart();
        shoppingCart.Add(item, unitprice, quantity);
        Assert.AreEqual(unitPrice * quantity, shoppingCart.TotalCost);
by bnaya   November 14, 2010 @ 10:26am
Tags: MBUnit, Test
228 Views
no comments
 
C#
public class RollbackTest 
{
    [Test, Rollback]
    public void TestWithRollback()
    {
        // Any transaction performed within this test will be rolled back
        // automatically when the test completes.
    }
 
    [Test, Rollback(IncludeSetupAndTearDown=true)]
by bnaya   November 13, 2010 @ 11:11pm
Tags: MBUnit, Test
126 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate