jbogard / ContosoUniversityCore

MIT License
591 stars 151 forks source link

Introduced testing DSL #6

Closed siberianguy closed 7 years ago

siberianguy commented 7 years ago

I've been looking what else we can do to improve this great repository. I've recently read your colleague's post and it inspired me do some changes. I'll introduce them step by step to be sure you're on board with these ideas.

This time I introduced testing DSL using C# 6 "using static" feature instead of injecting SliceFixture parameter. Honestly this parameter was very confusing when I looked at the codebase for the first time. Like... what is it? Does it pregenerate some input data or what? Semantically it's not a parameter for our tests, it's just a piece of infrastructure. Hopefully, tests look a little bit clearer now. And by the way one more advantage of this approach is that SliceFixture becomes extensible (i. e. we can introduce PostsSliceFixture and import it specifically to Posts tests).

P. S. It looks like a lot of changes (a lot of find&replace actually) but basically I've done three things:

  1. Made all SliceFixture methods static
  2. Removed SliceFixture as a parameter in tests
  3. Removed SliceFixture parameter configuration from Convention classes.
siberianguy commented 7 years ago

Jimmy, please take a look at it when you have a moment. I can't find a job right now and I wanted to work on this repository but I can't go further without your feedback :(

jbogard commented 7 years ago

I like the changes! Funny, I was just working with one of our teams that I noticed did the exact same thing! With this repo, I like to make sure that it represents how we actually build apps, and not an aspirational sort of thing, so I'm careful about adding things that we don't really do. But this definitely fits the bill!

siberianguy commented 7 years ago

Thanks!