public void MutableClassWithInitialState() { // Here the implicit NotNull is wrong, but we have the NotNullMemberIsNotInitialized warning at declaration site and // the NullGuard check at the property getter. var mutableClass = new PropertiesSample.MutableClass(); Action act = () => { var value = mutableClass.Property; TestValueAnalysis(value, value == null /*Expect:ConditionIsAlwaysTrueOrFalse[Prps && !RtGo]*/); }; act.ShouldThrow <InvalidOperationException>().WithMessage("[NullGuard] Return value * is null."); }
public void MutableClass() { var mutableClass = new PropertiesSample.MutableClass { Property = "value" }; TestValueAnalysis(mutableClass.Property, mutableClass.Property == null /*Expect:ConditionIsAlwaysTrueOrFalse[Prps && !RtGo]*/); mutableClass.Property.Should().Be("value"); TestValueAnalysis(mutableClass.DelegatingProperty, mutableClass.DelegatingProperty == null /*Expect:ConditionIsAlwaysTrueOrFalse[Prps && !RtGo]*/); mutableClass.DelegatingProperty.Should().Be("value"); TestValueAnalysis( mutableClass.DelegatingGetterOnlyProperty, mutableClass.DelegatingGetterOnlyProperty == null /*Expect:ConditionIsAlwaysTrueOrFalse[Prps]*/); mutableClass.DelegatingGetterOnlyProperty.Should().Be("value"); }