stklik
stklik

Reputation: 844

Pex ignores [PexAssumeNotNull] and PexAssume.AreElementsNotNull()

I have the following PexMethod:

[PexMethod]
public bool fwAlertConfig_objectConfigExists(
    [PexAssumeUnderTest]WinCC target,
    [PexAssumeNotNull] List<mixed> alertConfigObject,
    [PexAssumeNotNull] ref int configType,
    [PexAssumeNotNull] ref List<string> exceptionInfo
)
{
    PexAssume.TrueForAll(alertConfigObject, x => x.value != null);
    PexAssume.AreElementsNotNull(alertConfigObject);
    bool result
       = target.fwAlertConfig_objectConfigExists(alertConfigObject, ref configType, ref exceptionInfo);
    return result;

}

I deliberately placed the [PexAssumeNotNull] and PexAssume there. However, it seems that these things are ignored when I "Run Pex explorations" these are the inputs created: PexResults

Please notice the following:

However: [PexAssumeNotNull] works well for alertConfigObject, as I do not see null as an input anymore. So why are the other assumptions not working?

Upvotes: 0

Views: 110

Answers (1)

Tao G&#243;mez Gil
Tao G&#243;mez Gil

Reputation: 2705

I couldn't test it, because you didn't provide the code under test, but you can try to replace the [PexAssumeNotNull] attribute with the static method PexAssume.IsNotNull, like this:

   [PexMethod]
   public bool fwAlertConfig_objectConfigExists(
       WinCC target,
       List<mixed> alertConfigObject,
       ref int configType,
       ref List<string> exceptionInfo)
   {
       PexAssume.IsNotNull(target);
       PexAssume.IsNotNull(alertConfigObject);
       PexAssume.IsNotNull(configType);
       PexAssume.IsNotNull(exceptionInfo);

       PexAssume.TrueForAll(alertConfigObject, x => x.value != null);
       PexAssume.AreElementsNotNull(alertConfigObject);
       bool result
          = target.fwAlertConfig_objectConfigExists(alertConfigObject, ref configType, ref exceptionInfo);
       return result;
   }

Upvotes: 1

Related Questions