Exemple #1
0
        public void AssertRun_Given_ClassWithNoAsyncDeadlock_Should_Succeed()
        {
            var instance = new ClassWithAsyncDeadlock();
            var finder   = new ConcurrencyChecker(instance, null, 2000);

            finder.Assert(1, () => instance.ShouldNotDeadLock());
        }
Exemple #2
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);
        }
Exemple #3
0
        public void AssertRun_Given_ClassWithDictionaryAsyncDeadlock_Should_ThrowException()
        {
            var instance = new ClassWithAsyncDeadlock();
            var finder   = new ConcurrencyChecker(instance, null, 500);

            var error = Assert.Throws <ConcurrencyException>(() => finder.Assert(5, async() => await instance.DictionaryNotThreadSafeShouldLock()));

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

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

            ConcurrencyChecker.AssertAsyncDeadlocksOnly(() => instance.ShouldNotDeadLock(), 200);
        }