Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Add TryAdd and Clear regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
A-And committed Sep 22, 2018
1 parent 5f7e07f commit e373d99
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,31 @@ public void Remove_NonExistentEntries_DoesNotPreventEnumeration()
}
}

[Fact]
[Trait("MyTrait", "MyTraitValue")]
public void Clear_OnEmptyCollection_DoesNotInvalidateEnumerator()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
var valuesEnum = dictionary.GetEnumerator();

dictionary.Clear();
Assert.Empty(dictionary);
valuesEnum.MoveNext();
}

[Fact]
[Trait("MyTrait", "MyTraitValue")]
public void Unsuccessful_TryAdd_DoesNotInvalidateEnumerator()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("a", "b");

var valuesEnum = dictionary.GetEnumerator();
Assert.False(dictionary.TryAdd("a", "c"));

valuesEnum.MoveNext();
}

[Theory]
[MemberData(nameof(CopyConstructorInt32Data))]
public void CopyConstructorInt32(int size, Func<int, int> keyValueSelector, Func<IDictionary<int, int>, IDictionary<int, int>> dictionarySelector)
Expand Down

0 comments on commit e373d99

Please sign in to comment.