public void DoOrAdd() { var target = new ConcurrentIndexed <int, string>(); target.DoOrAdd(1, x => "1!", "1"); Assert.Equal("1", target.GetOrThrow(1)); target.DoOrAdd(1, x => "1!", "1"); Assert.Equal("1!", target.GetOrThrow(1)); }
public void AddUpdate(int i) { var thing = new ConcurrentIndexed <int, string>(); thing.DoOrAdd(i, (s) => s + " world", "hello"); Assert.Equal("hello", thing.GetOrThrow(i)); thing.DoOrAdd(i, (s) => s + " world", "hello"); Assert.Equal("hello world", thing.GetOrThrow(i)); }
public void UpdateFallback(int i) { var thing = new ConcurrentIndexed <int, string>(); Assert.Equal("not hello", thing.DoOrAdd(i, (x) => x + " world", "not hello")); Assert.Equal("not hello", thing.GetOrThrow(i)); }