Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

[Fixes #731] Add unit tests for ReflectedActionDescriptorProvider #1087

Merged
merged 1 commit into from
Sep 9, 2014

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Sep 1, 2014

  1. Added tests that cover parameters in actions.
  2. Added tests that cover building the reflected application model.
  3. Added tests that cover attribute routed action constraints and default values.
  4. Added tests that cover conventionally routed action constraints and default values.
  5. Refactored and cleaned up ReflectedActionDescriptorProvider. All the refactors consist
    of extracting blocks of code to separate methods to better display the flow when building
    the action descriptors.

@@ -25,7 +25,7 @@ public void GetDescriptors_GetsDescriptorsOnlyForValidActions()
var actionNames = descriptors.Select(ad => ad.Name);

// Assert
Assert.Equal(new[] { "GetPerson", "ListPeople", }, actionNames);
Assert.Equal(new[] { "GetPerson", "ShowPeople", }, actionNames);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test changed because I added [ActionName] to one of the actions to test that it gets taken into account

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems ok in this specific case, just be careful not to change the meaning of tests. Generally want we want to add new test data if you're adding tests.

@rynowak
Copy link
Member

rynowak commented Sep 2, 2014

test adds/refactoring looks good

@rynowak
Copy link
Member

rynowak commented Sep 2, 2014

Any functional tests that should be added?

@javiercn
Copy link
Member Author

javiercn commented Sep 8, 2014

From what I believe, this task meant to add unit tests to cover the rest of the aspects of this class, test coverage in functional tests should be good already (and not part of this task anyway). I haven't specifically looked at functional tests, but this should have good coverage as part of the coverage for other features.

@javiercn
Copy link
Member Author

javiercn commented Sep 8, 2014

@rynowak Updated, I've addressed everything except whether the comments should be on the call site or inside the method. I don't think we have clear guidance for it and my usual take on it is that I prefer to have the why comments along with the place where I call them so that why and what are clear when I read the code and how (the body of the method) becomes an implementation detail.

With that said, if you think different and have reasons to do it differently I'm happy to change it, I don't have a strong opinion on it.

@rynowak
Copy link
Member

rynowak commented Sep 8, 2014

@javiercn - the updated code looks good.

The difference is subtle and about the level of abstraction. A method call is necessarily at a higher-level of abstraction than the code inside the body.

  1. When reading a method call site I want to know what it means based on the context I have. "The context I have" in the scope of this PR probably means what is the effect on the AD. Often times good method naming takes care of this for you and there's no benefit to having a comment.
  2. When reading the body of a method, I want to know specifically why these lines of code are accomplishing the goal. Often times the purpose can be inferred from reading the code because the naming is good and the API is simple - and often times it can't because the design is complex.

TLDR follow your heart. We all have different thresholds for when we think 1) or 2) above needs a comment, and code reviews help with that.

@rynowak
Copy link
Member

rynowak commented Sep 8, 2014

:shipit:

1. Added tests that cover parameters in actions.
2. Added tests that cover building the reflected application model.
3. Added tests that cover attribute routed action constraints and default values.
4. Added tests that cover conventionally routed action constraints and default values.
5. Refactored and cleaned up ReflectedActionDescriptorProvider. All the refactors consist
   of extracting blocks of code to separate methods to better display the flow when building
   the action descriptors.
@javiercn javiercn merged commit 9345afe into dev Sep 9, 2014
@javiercn javiercn deleted the issue731 branch September 10, 2014 20:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants