public void TestThatNotNullReturnsArgumentNullGuardWhenStringValueIsEmptyOrWhitespace(string value) { IArgumentNullGuard sut = CreateSut(); string argumentName = _fixture.Create <string>(); IArgumentNullGuard result = sut.NotNull(value, argumentName); Assert.IsNotNull(result); Assert.AreSame(sut, result); }
public void TestThatNotNullReturnsArgumentNullGuardWhenObjectValueIsNotNull() { IArgumentNullGuard sut = CreateSut(); object value = _fixture.Create <object>(); string argumentName = _fixture.Create <string>(); IArgumentNullGuard result = sut.NotNull(value, argumentName); Assert.IsNotNull(result); Assert.AreSame(sut, result); }
public void TestThatNotNullThrowsArgumentNullExceptionWhenArgumentNameIsNullEmptyOrWhiteSpace(string argumentName) { IArgumentNullGuard sut = CreateSut(); object value = _fixture.Create <object>(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.NotNull(value, argumentName)); TestHelper.AssertArgumentNullExceptionIsValid(result, "argumentName"); }
public void TestThatNotNullThrowsArgumentNullExceptionWhenObjectValueIsNull() { IArgumentNullGuard sut = CreateSut(); const object value = null; string argumentName = _fixture.Create <string>(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.NotNull(value, argumentName)); TestHelper.AssertArgumentNullExceptionIsValid(result, argumentName); }
/// <summary> /// Validates whether the <paramref name="value"/> is null 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 or when the <see cref="argumentName"/> is null, empty or white space.</exception> public static IArgumentNullGuard NotNull(object value, string argumentName) { IArgumentNullGuard argumentNullGuard = Create(); return(argumentNullGuard.NotNull(value, argumentName)); }