public void UpdateOrThrow() { var target = new ConcurrentIndexed <int, string>(); Assert.ThrowsAny <Exception>(() => target.UpdateOrThrow(1, x => x + "!")); target.Set(1, "1"); Assert.Equal("1!", target.UpdateOrThrow(1, x => x + "!")); }
public void SetOrThrow() { var target = new ConcurrentIndexed <int, string>(); Assert.ThrowsAny <Exception>(() => target.UpdateOrThrow(1, "1")); target.AddOrThrow(1, "1"); target.UpdateOrThrow(1, "1-1"); Assert.Equal("1-1", target.GetOrThrow(1)); }
public void AddUpdateOrThrow(int i) { var thing = new ConcurrentIndexed <int, string>(); thing.AddOrThrow(i, "hello"); Assert.Equal("hello", thing.GetOrThrow(i)); Assert.Throws <Exception>(() => { thing.AddOrThrow(i, "hello"); }); thing.UpdateOrThrow(i, (s) => s + " world"); Assert.Equal("hello world", thing.GetOrThrow(i)); }