public void Unique_given_1_1_1_2_3_3_returns_1_2_3() { int[] input = { 1, 1, 2, 3, 3 }; var output = CollectionUtilities.Unique(input); Assert.Equal(new[] { 1, 2, 3 }, output); }
public void Unique_given_1_2_3_3_3_3_4_returns_1_2_3_4() { var unique = CollectionUtilities.Unique(new[] { 1, 2, 3, 3, 3, 3, 4 }); var expected = new HashSet <int> { 2, 3, 4, 1 }; Assert.True(expected.SetEquals(unique)); }
public void Unique_given_1_2_2_3_3_4_5_returns_1_2_3_4_5() { int[] numbers = { 1, 2, 2, 3, 3, 4, 5 }; var unique = CollectionUtilities.Unique(numbers); Assert.True(new HashSet <int> { 1, 2, 3, 4, 5 }.SetEquals(unique)); }
public void Unique_given_1_2_2_2_3_returns_1_2_3() { var input = new[] { 1, 2, 2, 2, 3 }; var even = CollectionUtilities.Unique(input); // Not possible with Xunit - can be done with MSTest or NUnit using CollectionAssert //Assert.Equal(new HashSet<int> { 3, 2, 1 }, even); Assert.True(even.SetEquals(new[] { 3, 2, 1 })); }
public void Unique_given_1_2_3_2_2_2_4_returns_1_2_3_4() { // Arrange int[] input = { 1, 2, 3, 2, 2, 2, 4 }; // Act var output = CollectionUtilities.Unique(input); // Assert int[] expected = { 1, 2, 3, 4 }; Assert.Equal(expected, output); }