public void Run_Given_ClassWithDictionaryConcurrencyIssues_With_AddChangePropertyOnChildDictionary_Should_Succeed() { var instance = new ClassWithDictionaryConcurrencyIssues(); var finder = new ConcurrencyChecker(instance, null, 2000); var error = Assert.Throws <ConcurrencyException>(() => finder.Assert(2000, () => { instance.AddToCache(Guid.NewGuid().ToString(), 1); }, () => { Thread.Sleep(1); })); Console.WriteLine(error.Message); Assert.IsTrue(error.Message.Contains("ClassWithDictionaryConcurrencyIssues->Cache: Possible concurrency issue because of the following exception: Collection was modified; enumeration operation may not execute.")); }
public void Run_Given_ClassWithDictionaryConcurrencyIssues_With_ChangePropertyOnChildDictionary_Should_ThrowConcurrencyException() { var instance = new ClassWithDictionaryConcurrencyIssues(); var finder = new ConcurrencyChecker(instance, null, 2000); var error = Assert.Throws <ConcurrencyException>(() => finder.Assert(2000, () => { instance.UpdateCache("Existing", 1); }, () => { instance.UpdateCache("Existing", 2); })); Console.WriteLine(error.Message); Assert.IsTrue(error.Message.Contains("ClassWithDictionaryConcurrencyIssues->Cache: Possible concurrency issue because of the following exception: Collection was modified; enumeration operation may not execute.")); }