(+N) Consulting Inc.

Consulting | Software Solutions | Training

Pex Gotcha - watch your predicate expressions

Just came back from another great SoCal Code Camp. I had some valuable insights and discussions about TDD and the use of Pex. Thank you attendees! While developing the presentation for Pex, I ran into a situation where the Pex.Assume() did not seem to work at all: Consider the function public List<short> MakeList(short baseNum, short count) { List<short> result = new List<short>(count); for (short i = 1; i <= count; i++) { result.Add((short)(baseNum * i)); } return result; }   Pex correctly identifies a potential flaw where the multiplication (baseNum * i) would result in overflow. Adding a filter PexAssume.IsTrue(baseNum * count < short.MaxValue)... [More]