Bytes2you.Validation.UnitTests.Testing.Helpers.Ensure.ArgumentNullExceptionIsThrown C# (CSharp) Method

ArgumentNullExceptionIsThrown() public static method

public static ArgumentNullExceptionIsThrown ( System.Action action, string expectedArgumentName ) : void
action System.Action
expectedArgumentName string
return void
        public static void ArgumentNullExceptionIsThrown(Action action, string expectedArgumentName)
        {
            if (action == null)
            {
                throw new ArgumentNullException("method");
            }

            if (expectedArgumentName == null)
            {
                throw new ArgumentNullException("expectedArgumentName");
            }

            if (expectedArgumentName == string.Empty)
            {
                throw new ArgumentException(ValidationPredicateMessages.NullOrEmptyStringMessage, "expectedArgumentName");
            }

            ArgumentNullException ex = null;
            try
            {
                action();
            }
            catch (ArgumentNullException e)
            {
                ex = e;
            }

            Assert.AreEqual(typeof(ArgumentNullException), ex.GetType());
            Assert.IsNotNull(ex);
            Assert.AreEqual(expectedArgumentName, ex.ParamName);
        }