Пример #1
0
        public static void True_ThrowsArgumentException_ForFalse_1()
        {
            // Arrange
            var    paramName = "paramName";
            Action act       = () => Enforce.True(false, paramName);

            // Act
            var ex = Record.Exception(act);

            // Assert
            Assert.NotNull(ex);
            Assert.NotNull(ex.Message);
            var argex = Assert.IsType <ArgumentException>(ex);

            Assert.Equal(paramName, argex.ParamName);
        }
Пример #2
0
        public static void True_ThrowsArgumentException_ForFalse_2()
        {
            // Arrange
            var    paramName = "paramName";
            var    message   = "My message";
            Action act       = () => Enforce.True(false, paramName, message);

            // Act
            var ex = Record.Exception(act);

            // Assert
            Assert.NotNull(ex);
            var argex = Assert.IsType <ArgumentException>(ex);

            Assert.Equal(paramName, argex.ParamName);
            // ArgumentException appends some info to our message.
            Assert.StartsWith(message, ex.Message, StringComparison.OrdinalIgnoreCase);
        }
Пример #3
0
 public static void True_DoesNotThrow_ForTrue_2() => Enforce.True(true, "paramName", "My message");
Пример #4
0
 public static void True_DoesNotThrow_ForTrue_1() => Enforce.True(true, "paramName");