Skip to content

Conversation

JakeGinnivan
Copy link
Member

An attempt at the new api for #9

@JakeGinnivan
Copy link
Member Author

Also addresses #7

@JakeGinnivan
Copy link
Member Author

Sample syntax:

// All methods virtual
var itemsToVerify = typeof(SampleDomainClass).Assembly.GetTypes();
Convention.Is<AllMethodsAreVirtual>(itemsToVerify);

// All items have a protected or public ctor
var itemsToVerify = typeof(SampleDomainClass).Assembly.GetTypes();
Convention.Is<AllClassesHaveDefaultConstructor>(itemsToVerify);

// Example of a filter which takes a filter. This could be an argument instead of a filter?
Convention.Is<FilesAreEmbeddedResources>(new[] { typeof(ProjectBasedConventions).Assembly }, i => i.EndsWith(".sql"));

// And finally making sure we don't reference bin/obj assemblies
Convention.Is<ProjectDoesNotReferenceDllsFromBinOrObjDirectories>(new[] { typeof(ProjectBasedConventions).Assembly });

Hopefully this is a good starting point

@JakeGinnivan
Copy link
Member Author

@kkozmic thoughts?

@kkozmic
Copy link
Contributor

kkozmic commented Jul 28, 2013

I'll take that and convert the conventions I've got running at work to that API and see what feel it has to it.

@kkozmic
Copy link
Contributor

kkozmic commented Jul 30, 2013

There's a lot here that I like. Especially the idea of shipping some pre-packaged conventions. I was struggling with integrating this into the old model. Now it seems to fit quite nicely.

What I liked about the old model (although I think we need to change it in the new one) was the clean division of responsibility between the (base) convention class, and its associated ConventionData class. I think it might be a good idea to preserve this in some way for v2.

I'd see this as having three main user facing actors:

  1. The Convention type (IConvention<TData>) that actually checks the convention logic
  2. The Convention Data type, that provides data that the convention acts upon
  3. The Platform (common logic that verifies the results of the convention. That would most likely live in the Convention static entry class (or whatever we end up calling it)

In terms of how all of that relates to the old code, the Platform would contains most of the common code shared among the ConventionTest base classes, the ConventionData would be similar to the old ConventionData and the Convention would be the middle bit of the two running the logic and passing the results down to the Platform.

Does that make sense? I'll pull in this PR and spike the idea on top of it. Looking forward to your ideas.

kkozmic added a commit that referenced this pull request Jul 30, 2013
@kkozmic kkozmic merged commit bb1f773 into TestStack:master Jul 30, 2013
@JakeGinnivan
Copy link
Member Author

Sounds good, I will wait to see your spike on top of it. Especially around the filters (notice the IRuntimeFilter or whatever it is), which allows you to filter types.

It doesn't quite feel right, separating the convention and the convention data might make that nicer

@kkozmic
Copy link
Contributor

kkozmic commented Jul 30, 2013

yeah, the IRuntimeFilter<>. I do agree, I think what I have in mind might work better, but let's spike it first and see :)

kkozmic added a commit to kkozmic/ConventionTests that referenced this pull request Jul 30, 2013
This relates to issue TestStack#9, also see discussion under pull request TestStack#12 and TestStack#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants