Esempio n. 1
0
        public void ShouldSucceedForArgumentHasLengthLessThanOrEqualToWhenArrayHasNoItems(int[] arrayArg, string message)
        {
            // Given
            var argument = TestUtility.CreateArgument(() => arrayArg);

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

            // Then
            Assert.DoesNotThrow(action);
        }
Esempio n. 2
0
        public void ShouldFailForArgumentHasLengthLessThanOrEqualToWhenArrayHasMoreItemsPlural(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 array parameter should have less than or equal to 2 elements, but has 6 elements", "arrayArg");

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

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

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