Example #1
0
    public Task RequiresNonNullMethodReturnValueWhenNullableReferenceTypeNotUsedInClassWithNullableContext2()
    {
        var sample    = new ClassWithNullableContext2();
        var exception = Assert.Throws <InvalidOperationException>(() => sample.MethodWithReturnValue(true));

        return(Verifier.Verify(exception.Message));
    }
Example #2
0
    public void RequiresNonNullArgumentWhenNullableReferenceTypeNotUsedInClassWithNullableContext2()
    {
        var sample    = new ClassWithNullableContext2();
        var exception = Assert.Throws <ArgumentNullException>(() => { sample.SomeMethod(null, ""); });

        Assert.Equal("nonNullArg", exception.ParamName);
    }
Example #3
0
    public void AllowsNullArgumentAndReturnValueForNullableClassConstrainedGeneric()
    {
        var sample = new ClassWithNullableContext2();
        var result = sample.GenericNullableClassWithNotNullableParam <string>(null);

        Assert.Null(result);
    }
Example #4
0
    public void PropertyGetterReturnsValueForNonNullableTypeInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();
        var value  = new Tuple <string, string>("a", "b");

        sample.MixedNonNullProperty = value;
        Assert.Equal(value, sample.MixedNonNullProperty);
    }
Example #5
0
    public void PropertyGetterReturnsValueForNonNullableTypeInClassWithNullableContext2()
    {
        var          sample = new ClassWithNullableContext2();
        const string value  = "Test";

        sample.NonNullProperty = value;
        Assert.Equal(value, sample.NonNullProperty);
    }
Example #6
0
    public void PropertyGetterThrowsOnNonNullableTypeInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        Assert.Throws <InvalidOperationException>(() =>
        {
            var dummy = sample.MixedNonNullProperty;
        });
    }
Example #7
0
    public void PropertyGetterReturnsNullForNullableTypeInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        Assert.Null(sample.NullProperty);
    }
Example #8
0
    public void PropertySetterAllowsNullArgumentForNullableTypeInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        sample.NullProperty = null;
    }
Example #9
0
    public void PropertySetterThrowsOnNullArgumentForNonNullableTypeInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        Assert.Throws <ArgumentNullException>(() => sample.MixedNonNullProperty = null);
    }
Example #10
0
 public void AllowsNullReturnValueWhenStaticNullableReferenceTypeUsedInClassWithNullableContext2()
 {
     Assert.Null(ClassWithNullableContext2.StaticMethodAllowsNullReturnValue(""));
 }
Example #11
0
    public void AllowsNullReturnValueWhenNullableDisabledInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        Assert.Null(sample.MethodWithNullableContext0());
    }
Example #12
0
    public void AllowsNullReturnValueWhenNullableReferenceTypeUsedInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        sample.MethodAllowsNullReturnValue();
    }
Example #13
0
    public void AllowsNullWithoutAttributeWhenNullableReferenceTypeUsedInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        sample.MethodWillNullableArg(null);
    }
Example #14
0
    public void AllowsNullWhenNullableReferenceTypeUsedInClassWithNullableContext2()
    {
        var sample = new ClassWithNullableContext2();

        sample.SomeMethod("", null);
    }
Example #15
0
 public void RequiresNonNullReturnForNotNullReturnValue()
 {
     var sample    = new ClassWithNullableContext2();
     var exception = Assert.Throws <InvalidOperationException>(() => { sample.GenericNotNullReturnValue <string>(); });
 }