public void HashSet_Generic_TryGetValue_NotContains() { T value = CreateT(1); SegmentedHashSet <T> set = new SegmentedHashSet <T> { value }; T equalValue = CreateT(2); Assert.False(set.TryGetValue(equalValue, out T? actualValue)); Assert.Equal(default(T), actualValue); }
public void HashSet_Generic_TryGetValue_NotContains_OverwriteOutputParam() { T value = CreateT(1); SegmentedHashSet <T> set = new SegmentedHashSet <T> { value }; T equalValue = CreateT(2); #pragma warning disable IDE0059 // Unnecessary assignment of a value (intentional for the test) T?actualValue = equalValue; #pragma warning restore IDE0059 // Unnecessary assignment of a value Assert.False(set.TryGetValue(equalValue, out actualValue)); Assert.Equal(default(T), actualValue); }
public void HashSet_Generic_TryGetValue_Contains() { T value = CreateT(1); SegmentedHashSet <T> set = new SegmentedHashSet <T> { value }; T equalValue = CreateT(1); Assert.True(set.TryGetValue(equalValue, out T? actualValue)); Assert.Equal(value, actualValue); if (!typeof(T).IsValueType) { Assert.Same((object)value, (object?)actualValue); } }
public void HashSet_Generic_TryGetValue_Contains_OverwriteOutputParam() { T value = CreateT(1); SegmentedHashSet <T> set = new SegmentedHashSet <T> { value }; T equalValue = CreateT(1); #pragma warning disable IDE0059 // Unnecessary assignment of a value (intentional for the test) T?actualValue = CreateT(2); #pragma warning restore IDE0059 // Unnecessary assignment of a value Assert.True(set.TryGetValue(equalValue, out actualValue)); Assert.Equal(value, actualValue); if (!typeof(T).IsValueType) { Assert.Same((object)value, (object?)actualValue); } }