コード例 #1
0
        public void TestThatNotNullOrWhiteSpaceReturnsArgumentNullGuardWhenStringValueIsNotNull()
        {
            IArgumentNullGuard sut = CreateSut();

            string             value        = _fixture.Create <string>();
            string             argumentName = _fixture.Create <string>();
            IArgumentNullGuard result       = sut.NotNullOrWhiteSpace(value, argumentName);

            Assert.IsNotNull(result);
            Assert.AreSame(sut, result);
        }
コード例 #2
0
        public void TestThatNotNullOrWhiteSpaceThrowsArgumentNullExceptionWhenStringValueIsNullOrWhiteSpace(string value)
        {
            IArgumentNullGuard sut = CreateSut();

            string argumentName          = _fixture.Create <string>();
            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.NotNullOrWhiteSpace(value, argumentName));

            TestHelper.AssertArgumentNullExceptionIsValid(result, argumentName);
        }
コード例 #3
0
        /// <summary>
        /// Validates whether the <paramref name="value"/> is null, empty or white space and throws an <see cref="ArgumentNullException"/> when so.
        /// </summary>
        /// <param name="value">The value to validate.</param>
        /// <param name="argumentName">The name of the argument.</param>
        /// <returns>Instance of Argument Null Guard.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <see cref="value"/> is null, empty or white space or when the <see cref="argumentName"/> is null, empty or white space.</exception>
        public static IArgumentNullGuard NotNullOrWhiteSpace(string value, string argumentName)
        {
            IArgumentNullGuard argumentNullGuard = Create();

            return(argumentNullGuard.NotNullOrWhiteSpace(value, argumentName));
        }