public async Task WhenStoreModifiedExternallyThenIteratingOverBreakpointsShouldNotThrow() { var store = new BreakpointStore(); Action <int> threadAddAction = (x) => { store.Add(new Breakpoint($"fileName{x}.cs", 10)); }; Action threadEnumerateAction = () => { foreach (var bk in store.GetBreakpointsAtFile("fileName1.cs")) { } }; List <Task> tasks = new List <Task> (); for (int i = 0; i < 10; i++) { tasks.Add(Task.Run(() => { threadAddAction(i); })); tasks.Add(Task.Run(() => { threadEnumerateAction(); })); } foreach (var task in tasks) { await task; } }
public void GetBreakpointsAtFileReturnsCorrectFiles() { var store = new BreakpointStore(); store.Add(new Breakpoint("fileName1.cs", 10)); store.Add(new Breakpoint("fileName1.cs", 20)); store.Add(new Breakpoint("fileName2.cs", 10)); store.Add(new Breakpoint("fileName3.cs", 15)); int count = 0; foreach (var bk in store.GetBreakpointsAtFile("fileName1.cs")) { count++; Assert.AreEqual("fileName1.cs", bk.FileName); } Assert.AreEqual(2, count); }