Mark Rendle
Mark Rendle

Reputation: 9414

Is there a library of default unit tests for .NET interface implementations?

For example, I have a type which implements IDictionary, and I need test coverage to ensure that it does it properly. I just wondered if there is a repository of standard, reusable tests for this kind of thing anywhere; if there isn't, I might create one.

Upvotes: 16

Views: 321

Answers (2)

Mark Rendle
Mark Rendle

Reputation: 9414

I couldn't find anything which specifically met this need, so I made it. I've created a Github repo and added my IDictionary<TKey,TValue> test to it; hopefully people will fork and contribute more tests.

https://github.com/markrendle/InterfaceTests.Net

Upvotes: 1

Steven Robbins
Steven Robbins

Reputation: 26599

I doubt there's a publicly available .net one, but the Mono project might be a good place to start?

Whether they're testing "the contract" of the interface, or the specific implementation, I'm not sure, but there's certainly tests for the Dictionary class:

https://github.com/mono/mono/blob/master/mcs/class/corlib/Test/System.Collections.Generic/DictionaryTest.cs

Upvotes: 7

Related Questions