Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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");
        }
Ejemplo n.º 3
0
        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");
        }