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:
Please notice the following:
in exceptionInfo
is null
in every line, although it has [PexAssumeNotNull]
{null}
, although I defined PexAssume.AreElementsNotNull(alertConfigObject)
new mixed
has {value=null}
, although I defined
PexAssume.TrueForAll(alertConfigObject, x => x.value != null)
However: [PexAssumeNotNull]
works well for alertConfigObject, as I do not see null as an input anymore.
So why are the other assumptions not working?
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;
}