public void NoConstraintGenericWithStringType_AndMethodWithNullArgument() { var instance = new GenericsSample.NoConstraint <string>(); Action act = () => instance.Method(null /*Expect:AssignNullToNotNullAttribute[MIn]*/); act.ShouldThrow <ArgumentNullException>().And.ParamName.Should().Be("a"); }
public void NoConstraintGenericWithDateTimeType_AndMethodWithDefaultOfTArgument() { var instance = new GenericsSample.NoConstraint <DateTime>(); Action act = () => instance.Method(default(DateTime)); act.ShouldNotThrow("the argument check should not perform a 'param == default(T)' comparison"); }
public void NoConstraintGenericWithNullableIntType_AndMethodWithNullArgument() { var instance = new GenericsSample.NoConstraint <int?>(); Action act = () => instance.Method(null /*Expect:AssignNullToNotNullAttribute[MIn]*/); act.ShouldThrow <ArgumentNullException>( "known issue for generics without constraint (it's a trade-off between this false positive and a false-negative if T is a reference type") .And.ParamName.Should().Be("a"); }