コード例 #1
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
        public void RunRoundingEdgeCase()
        {
            double d = 3;
            int i = 2;

            PAssert.IsTrue(() => 4.5 == d + 3 / i);
        }
コード例 #2
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
        public void EqualsButNotOperatorEquals()
        {
            var t1 = new Tuple<string>("foo");
            var t2 = new Tuple<string>("foo");

            PAssert.IsTrue(() => t1 == t2);
        }
コード例 #3
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void RunComplexExpression()
 {
     int x = 11;
     int y = 6;
     DateTime d = new DateTime(2010, 3, 1);
     PAssert.IsTrue(() => x + 5 == d.Month * y);
 }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        public void PrintingEnumerablesWithNulls()
        {
            var list = new List <int?> {
                1, 2, null, 4, 5
            };

            PAssert.IsTrue(() => list.Sum() == null);
        }
コード例 #8
0
        public void Should_return_the_thrown_exception()
        {
            var expectedException = new Exception();

            var actualException = PAssert.Throws <Exception>(() => MethodThatDoesThrow(expectedException));

            Assert.That(actualException, Is.EqualTo(expectedException));
        }
コード例 #9
0
        public void RunComplexExpression3()
        {
            List <int> l = new List <int> {
                1, 2, 3
            };
            bool b = false;

            PAssert.IsTrue(() => l[2].ToString() == (b ? "three" : "four"));
        }
コード例 #10
0
        public void SequenceEqualButNotOperatorEquals()
        {
            object list = new List <int> {
                1, 2, 3
            };
            object array = new[] { 1, 2, 3 };

            PAssert.IsTrue(() => list == array);
        }
コード例 #11
0
        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.");
        }
コード例 #12
0
        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.");
        }
コード例 #13
0
        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)));
        }
コード例 #14
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void RunComplexExpressionWithStaticField()
 {
     int y = 6;
     DateTime d = new DateTime(2010, 3, 1);
     PAssert.IsTrue(() => field + 5 == d.Month * y);
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        public void PrintingLinqExpressionStatements()
        {
            var list = Enumerable.Range(0, 150);

            PAssert.IsTrue(() => (from l in list where l % 2 == 0 select l).Sum() == 0);
        }
コード例 #17
0
        public void PrintingLinqStatements()
        {
            var list = Enumerable.Range(0, 150);

            PAssert.IsTrue(() => list.Where(x => x % 2 == 0).Sum() == 0);
        }
コード例 #18
0
        public void PrintingIsTest()
        {
            var b = new object();

            PAssert.IsTrue(() => b is string);
        }
コード例 #19
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void RunTypeOfExpression()
 {
     int x = 1;
     PAssert.IsTrue(() => x.GetType() == typeof(string));
 }
コード例 #20
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 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]));
 }
コード例 #21
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void PrintingDelegateInvocation()
 {
     var array = new int[] { 1, 2, 3 };
     PAssert.IsTrue(() => array.Any(x => x > 3));
 }
コード例 #22
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void PrintingDelegateMethodGroupInvocation()
 {
     var array = new int[] { 1, 2, 3 };
     PAssert.IsTrue(() => array.Any(GreaterThan3));
 }
コード例 #23
0
 public void Should_succeed_when_expression_does_throw_an_exception()
 {
     PAssert.Throws <Exception>(() => MethodThatDoesThrow(new Exception()));
 }
コード例 #24
0
        public void PrintingUnaryNot()
        {
            var b = true;

            PAssert.IsTrue(() => !b);
        }
コード例 #25
0
        public void PrintingUnaryNegate()
        {
            var b = 5;

            PAssert.IsTrue(() => - b == 0);
        }
コード例 #26
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void RunStringCompare()
 {
     string s = "hello, bobby";
     Tuple<string> t = new Tuple<string>("hello, Bobby");
     PAssert.IsTrue(() => s == t.Item1);
 }
コード例 #27
0
 public async Task Should_succeed_when_async_expression_does_throw_exception()
 {
     await PAssert.Throws <Exception>(async() => await AsyncMethodThatDoesThrow(new Exception()));
 }
コード例 #28
0
ファイル: EndToEndTest.cs プロジェクト: jcannata/Cedar.Domain
 public void PrintingNewArrayTest()
 {
     var array = new int[]{1,2,3};
     PAssert.IsTrue(() => array.Equals(new[]{4,5,6}));
 }