public void ShouldSucceedForArgumentHasNoNullsWhenSequenceHasNoItems(object[] arrayArg, string message) { // Given var argument = TestUtility.CreateArgument(() => arrayArg); // When var action = new TestDelegate(() => Has.NoNulls(argument, message)); // Then Assert.DoesNotThrow(action); }
public void ShoulFailForArgumentHasNoNullsWhenSequenceHasNulls(object[] arrayArg, string message, string format) { // Given arrayArg = new[] { new object(), null, new object() }; var argument = TestUtility.CreateArgument(() => arrayArg); var expected = string.Format(format, "Provided enumerable parameter should not have null(s), but had null at index 1", "arrayArg"); // When var action = new TestDelegate(() => Has.NoNulls(argument, message)); // Then var exception = Assert.Throws <ArgumentException>(action); exception.ParamName.ShouldBe("arrayArg"); exception.Message.ShouldBe(expected); exception.InnerException.ShouldBe(null); }