示例#1
0
        public void ShouldSucceedForArgumentHasLengthLessThanWhenArrayHasNoItems(int[] arrayArg, string message)
        {
            // Given
            var argument = TestUtility.CreateArgument(() => arrayArg);

            // When
            var action = new TestDelegate(() => Has.LengthLessThan <int>(() => 1)(argument, message));

            // Then
            Assert.DoesNotThrow(action);
        }
示例#2
0
        public void ShouldFailForArgumentHasLengthLessThanWhenArrayHasEqualNumberOfItemsSingular(int[] arrayArg, string message, string format)
        {
            // Given
            arrayArg = new[] { 1 };
            var argument = TestUtility.CreateArgument(() => arrayArg);
            var expected = string.Format(format, "Provided array parameter should have less than 1 element, but has 1 element", "arrayArg");

            // When
            var action = new TestDelegate(() => Has.LengthLessThan <int>(() => 1)(argument, message));

            // Then
            var exception = Assert.Throws <ArgumentException>(action);

            exception.ParamName.ShouldBe("arrayArg");
            exception.Message.ShouldBe(expected);
            exception.InnerException.ShouldBe(null);
        }