0

given the signature

 public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)

I've been tracing through properties and constructors of SnapshotSpan and haven't found anything that looks remotely possible to stub out for testing a classifier against say a string or a file.

How would I unit test a new VS2012 classifier?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Maslow
  • 18,464
  • 20
  • 106
  • 193

1 Answers1

0

SnapshotSpan is a struct (i.e. a value type. ref http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.text.snapshotspan.aspx), it cannot be stubbed and shimmed.

IClassifier.GetClassificationSpans is an interface method and we're creating StubIClassifier class so you can stub IClassifier. As to parameter ClassificationSpan, we created a ShimClassificationSpan class which you can use to shim it.

For a detail on using Fakes in VS2012, please ref http://msdn.microsoft.com/en-us/library/hh549175.aspx.

Regards,

Patrick Tseng - Visual Studio ALM team.

Patrick Tseng
  • 264
  • 1
  • 1