public void TryAddDuplicateItemReturnsFalse() { var set = new AsyncObservableKeyedSet <int, int>(param => param, Context, new[] { 1, 2, 3 }); Ensure(set.TryAddAsync(2), Is.False); Ensure(set.Count, Is.EqualTo(3)); Ensure(set.TryAddAsync(67532), Is.True); Ensure(set.Count, Is.EqualTo(4)); }
public void TryAddDuplicateKeyReturnsFalse() { var set = new AsyncObservableKeyedSet <int, int>(param => param % 5, Context, new[] { 15 }); Ensure(set.TryAddAsync(30), Is.False); Ensure(set.Count, Is.EqualTo(1)); Ensure(set.TryAddAsync(31), Is.True); Ensure(set.TryAddAsync(31), Is.False); Ensure(set.TryAddAsync(33), Is.True); Ensure(set.TryAddAsync(33), Is.False); Ensure(set.TryAddAsync(33), Is.False); Ensure(set.Count, Is.EqualTo(3)); Ensure(set.TryAddAsync(30), Is.False); Ensure(Task.Run(() => set.Count), Is.EqualTo(3)); Ensure(set.TryAddAsync(32), Is.True); Ensure(set.Count, Is.EqualTo(4)); }