Example #1
0
        public void AssertRun_Given_ClassWithAsyncDeadlock_Should_ThrowException()
        {
            var instance = new ClassWithAsyncDeadlock();

            var error = Assert.Throws <ConcurrencyException>(() => ConcurrencyChecker.AssertAsyncDeadlocksOnly(() => instance.ShouldDeadlock(), 200));

            Assert.AreEqual("Possible deadlock detected. Make sure that you do not use .Wait(), .WaitAny(), .WaitAll(), .GetAwaiter().GetResult() or .Result on async methods.", error.Message);
        }
Example #2
0
        public void AssertRun_Given_ClassWithDictionaryAsyncDeadlock_Should_ThrowException()
        {
            var instance = new ClassWithAsyncDeadlock();

            Assert.Throws <AggregateException>(() => ConcurrencyChecker.AssertAsyncDeadlocksOnly(async() => await instance.DictionaryNotThreadSafeShouldLock(), 500));
        }
Example #3
0
        public void AssertRun_Given_ClassWithNoAsyncDeadlock_Should_Succeed()
        {
            var instance = new ClassWithAsyncDeadlock();

            ConcurrencyChecker.AssertAsyncDeadlocksOnly(() => instance.ShouldNotDeadLock(), 200);
        }
Example #4
0
        public void Run_Given_ClassWithNoConcurrencyIssue_When_Calling_AsyncMethod_Should_Succeed()
        {
            var instance = new ClassWithNoConcurrencyIssues();

            ConcurrencyChecker.AssertAsyncDeadlocksOnly(async() => await instance.DoSomeWorkAndReturnResponseAsync(), 200);
        }
Example #5
0
        public void Run_Given_ClassWithAsyncDeadlockIssueFix_Should_Deadlock()
        {
            var instance = new ClassWithAsyncDeadlockIssueFix();

            ConcurrencyChecker.AssertAsyncDeadlocksOnly(() => instance.Foo());
        }
Example #6
0
        public void Run_Given_ClassWithAsyncDeadlockIssue_Should_Deadlock()
        {
            var instance = new ClassWithAsyncDeadlockIssue();

            Assert.Throws <ConcurrencyException>(() => ConcurrencyChecker.AssertAsyncDeadlocksOnly(() => instance.Foo()));
        }