public void AgainstNullArgument_FalseCondition_NoException() { string param = "notNull"; Assert.That(() => Guard.AgainstNullArgument("param", param), Throws.Nothing); Assert.That(() => new GuardSubject().Method("notNull"), Throws.Nothing); }
public void AgainstNullArgument_TrueCondition_ExceptionWithDefaultMessageAndParam() { string param = null, paramName = "param", actualMessage = new ArgumentNullException(paramName).Message; Assert.That(() => Guard.AgainstNullArgument(paramName, param), Throws.InstanceOf <ArgumentNullException>() .With.Property("Message").EqualTo(actualMessage).IgnoreCase .And.With.Property("ParamName").EqualTo(paramName)); Assert.That(() => new GuardSubject().Method(null), Throws.InstanceOf <ArgumentNullException>() .With.Property("Message").EqualTo(actualMessage).IgnoreCase .And.With.Property("ParamName").EqualTo(paramName)); }
public void Method(string param) { Guard.AgainstNullArgument("param", param); }