public void RunRoundingEdgeCase() { double d = 3; int i = 2; PAssert.IsTrue(() => 4.5 == d + 3 / i); }
public void EqualsButNotOperatorEquals() { var t1 = new Tuple<string>("foo"); var t2 = new Tuple<string>("foo"); PAssert.IsTrue(() => t1 == t2); }
public void RunComplexExpression() { int x = 11; int y = 6; DateTime d = new DateTime(2010, 3, 1); PAssert.IsTrue(() => x + 5 == d.Month * y); }
public void Should_assert_on_the_thrown_exception() { var expectedException = new Exception("broken"); var actualException = PAssert.Throws <Exception>(() => MethodThatDoesThrow(expectedException), x => x.Message == "broken"); Assert.That(actualException, Is.EqualTo(expectedException)); }
public async Task Should_return_the_thrown_exception_when_async() { var expectedException = new Exception(); var actualException = await PAssert.Throws <Exception>(async() => await AsyncMethodThatDoesThrow(expectedException)); Assert.That(actualException, Is.EqualTo(expectedException)); }
public async Task Should_assert_on_the_thrown_exception_when_async() { var expectedException = new Exception("broken"); var actualException = await PAssert.Throws <Exception>(async() => await AsyncMethodThatDoesThrow(expectedException), x => x.Message == "broken"); Assert.That(actualException, Is.EqualTo(expectedException)); }
public void PrintingEnumerablesWithNulls() { var list = new List <int?> { 1, 2, null, 4, 5 }; PAssert.IsTrue(() => list.Sum() == null); }
public void Should_return_the_thrown_exception() { var expectedException = new Exception(); var actualException = PAssert.Throws <Exception>(() => MethodThatDoesThrow(expectedException)); Assert.That(actualException, Is.EqualTo(expectedException)); }
public void RunComplexExpression3() { List <int> l = new List <int> { 1, 2, 3 }; bool b = false; PAssert.IsTrue(() => l[2].ToString() == (b ? "three" : "four")); }
public void SequenceEqualButNotOperatorEquals() { object list = new List <int> { 1, 2, 3 }; object array = new[] { 1, 2, 3 }; PAssert.IsTrue(() => list == array); }
public void Should_fail_when_expression_does_not_throw_an_exception() { try { PAssert.Throws <Exception>(() => MethodThatDoesNotThrowAnException()); } catch { return; } throw new Exception("Expected throws assertion to fail."); }
public void Should_fail_if_thrown_exception_is_of_wrong_type() { try { PAssert.Throws <ArgumentException>(() => MethodThatDoesThrow(new NullReferenceException())); } catch { return; } throw new Exception("Expected throws assertion to fail."); }
public void Should_not_block_when_async() { var sw = new Stopwatch(); sw.Start(); // no await here: var assert = PAssert.Throws <Exception>(async() => { await Task.Delay(TimeSpan.FromSeconds(10)); throw new Exception("uncaught"); }); sw.Stop(); Assert.That(sw.Elapsed, Is.LessThan(TimeSpan.FromSeconds(1))); }
public void RunComplexExpressionWithStaticField() { int y = 6; DateTime d = new DateTime(2010, 3, 1); PAssert.IsTrue(() => field + 5 == d.Month * y); }
public void PrintingComplexLinqExpressionStatements() { var list = Enumerable.Range(0, 5); PAssert.IsTrue(() => (from x in list from y in list where x > y select x + "," + y).Count() == 0); }
public void PrintingLinqExpressionStatements() { var list = Enumerable.Range(0, 150); PAssert.IsTrue(() => (from l in list where l % 2 == 0 select l).Sum() == 0); }
public void PrintingLinqStatements() { var list = Enumerable.Range(0, 150); PAssert.IsTrue(() => list.Where(x => x % 2 == 0).Sum() == 0); }
public void PrintingIsTest() { var b = new object(); PAssert.IsTrue(() => b is string); }
public void RunTypeOfExpression() { int x = 1; PAssert.IsTrue(() => x.GetType() == typeof(string)); }
public void RunComplexExpression2() { string x = " lalalaa "; int i = 10; PAssert.IsTrue(() => x.Trim().Length == Math.Max(4, new int[] { 5, 4, i / 3, 2 }[0])); }
public void PrintingDelegateInvocation() { var array = new int[] { 1, 2, 3 }; PAssert.IsTrue(() => array.Any(x => x > 3)); }
public void PrintingDelegateMethodGroupInvocation() { var array = new int[] { 1, 2, 3 }; PAssert.IsTrue(() => array.Any(GreaterThan3)); }
public void Should_succeed_when_expression_does_throw_an_exception() { PAssert.Throws <Exception>(() => MethodThatDoesThrow(new Exception())); }
public void PrintingUnaryNot() { var b = true; PAssert.IsTrue(() => !b); }
public void PrintingUnaryNegate() { var b = 5; PAssert.IsTrue(() => - b == 0); }
public void RunStringCompare() { string s = "hello, bobby"; Tuple<string> t = new Tuple<string>("hello, Bobby"); PAssert.IsTrue(() => s == t.Item1); }
public async Task Should_succeed_when_async_expression_does_throw_exception() { await PAssert.Throws <Exception>(async() => await AsyncMethodThatDoesThrow(new Exception())); }
public void PrintingNewArrayTest() { var array = new int[]{1,2,3}; PAssert.IsTrue(() => array.Equals(new[]{4,5,6})); }