public void ShouldSucceedForArgumentHasNoDuplicatesWhenSequenceHasNoItems(int[] arrayArg, string message) { // Given var argument = TestUtility.CreateArgument(() => arrayArg); // When var action = new TestDelegate(() => Has.NoDuplicates(argument, message)); // Then Assert.DoesNotThrow(action); }
public void ShouldFailForArgumentHasNoDuplicatesWhenSequenceHasDuplicates(int[] arrayArg, string message, string format) { // Given arrayArg = new[] { 1, 2, 3, 1, 4, 5 }; var argument = TestUtility.CreateArgument(() => arrayArg); var expected = string.Format(format, "Provided enumerable parameter should not have duplicate elements, but has same elements at index 0 and index 3", "arrayArg"); // When var action = new TestDelegate(() => Has.NoDuplicates(argument, message)); // Then var exception = Assert.Throws <ArgumentException>(action); exception.ParamName.ShouldBe("arrayArg"); exception.Message.ShouldBe(expected); exception.InnerException.ShouldBe(null); }