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

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

            // Then
            Assert.DoesNotThrow(action);
        }
Ejemplo n.º 2
0
        public void ShouldFailForArgumentHasLengthEqualToWhenArrayHasLessItems(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 6 elements, but has 1 element", "arrayArg");

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

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

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