internal static void AssertVariableWithUndefined <T>(this FlowOutputSet outset, string variableName, string message, params T[] expectedValues) where T : IComparable, IComparable <T>, IEquatable <T> { var variable = outset.ReadVariable(new VariableIdentifier(variableName)); var entry = variable.ReadMemory(outset.Snapshot); var actualValues = new List <T>(); foreach (var value in entry.PossibleValues) { //filter undefined values if (value is UndefinedValue) { continue; } if (!(value is ScalarValue <T>)) { Assert.Fail("Cannot convert {0} to {1} for variable ${2} in {3}. {4}", value, typeof(T), variableName, entry, message); } actualValues.Add((value as ScalarValue <T>).Value); } if (message == null) { message = string.Format(" in variable ${0} containing {1}", variableName, entry); } CollectionAssert.AreEquivalent(expectedValues, actualValues, message); }
internal static void AssertVariable <T>(this FlowOutputSet outset, string variableName, string message, params T[] expectedValues) where T : IComparable, IComparable <T>, IEquatable <T> { var variable = outset.ReadVariable(new VariableIdentifier(variableName)); var entry = variable.ReadMemory(outset.Snapshot); foreach (var value in entry.PossibleValues) { if (value is UndefinedValue) { Assert.Fail("Undefined value is not allowed for variable ${0} in {1}", variableName, entry); } } var actualValues = new List <T>(); foreach (Value value in entry.PossibleValues) { ScalarValue <T> scalar = value as ScalarValue <T>; if (scalar != null) { actualValues.Add(scalar.Value); } } if (message == null) { message = string.Format(" in variable ${0} containing {1}", variableName, entry); } CollectionAssert.AreEquivalent(expectedValues, actualValues.ToArray(), message); }
internal static void AssertUndefined(this FlowOutputSet outset, string variableName, string message) { var variable = outset.ReadVariable(new VariableIdentifier(variableName)); var entry = variable.ReadMemory(outset.Snapshot); bool hasUndefValue = false; foreach (var value in entry.PossibleValues) { if (value.GetType() == typeof(UndefinedValue)) { hasUndefValue = true; } } if (!hasUndefValue) { Assert.Fail("The variable ${0} does not contain undefined value.", variableName); } }