Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 menu test #1

Closed
wants to merge 4 commits into from
Closed

Conversation

midishero
Copy link

Sorry, I'm not used to writing unit tests. I fixed the code by observing the changes of menu(v3) with distinct arguments was passed. While I was doing so, I noticed that the menu(v3) didn't act as it should.

While @Html.MvcSiteMap().Menu(0, false, true, 2) return:

  • Home
    • About
    • Contact
    • A
      • A1
      • A2
      • A3
    • B
      • B1
      • B2

Then this @Html.MvcSiteMap().Menu(1, false, true, 2) should return:

  • About
  • Contact
  • A
    • A1
    • A2
    • A3
  • B
    • B1
    • B2

But it return nothing instead.
I can make v4 menu act like v3 menu, but how do I know if the v3 menu is correct or not.

@NightOwl888
Copy link
Owner

I can make v4 menu act like v3 menu, but how do I know if the v3 menu is correct or not.

That is a good question, and I wish I had a good answer. I would say that if you find something that is obviously wrong, to make it return the result you think it should. Clearly, if a combination is returning nothing there is probably something wrong if there are nodes defined that should be shown that aren't.

So, what state are you in currently? Is this acting exactly like v3, or have you also attempted to fixed the bugs you observed in the v3 behavior?

There's a scenario make the menu be duplicated. (Fixed)
@midishero
Copy link
Author

Of course, I'm finding the differences between them. But there're many methods, and so many scenarios was given from them. I think I would done the first task before caring about the bugs in the v3 that I don't know if it exists or not. It might be someone else think it is correct.

@NightOwl888
Copy link
Owner

Ok, so if you can get the menu working the same as v3, that is fine. It is also the logical first step if you would like to go further and fix some of the other issues.

Note that the 21 overloads that exist in v3 are really all you need to worry about, and I would focus on the options (startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToCurrent). That is a lot, which is why I suggested unit tests so you can run through a large number of use cases in a few seconds rather than going through them all manually. I am not that comfortable writing tests either, but I can see they clearly have an advantage in this case to manual testing.

FYI - Maarten and I have agreed to make v4 official on Monday. However, we could postpone the release to give people a chance to test out this menu with the fixes you are putting in.

Another thing to be aware of is that we have already discussed creating a new menu in a future 4.x release. The 3.x menu apparently didn't get a lot of adaption, presumably because its options are confusing and it has bugs. That is probably why only 2 people complained about the menu after more than 150 downloads.

Discussion of the new menu can be found in maartenba#125 and maartenba#160.

Add more testcase by modifying TestModels
@midishero
Copy link
Author

I don't know how to write unit tests for MVC Web.
That's why I added the TestController for testing stead of real unit tests.
If you find out a bug, just add a testcase to TestModels so I can fix it easily.

@maartenba
Copy link

Merged it in. We still need to find a way around the unit tests though.

@NightOwl888
Copy link
Owner

The latest build on Nuget has your changes. Note we had to leave out the commit for upgrading Nuget packages because we need to support legacy versions of some packages in order to support .NET 3.5.

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.

3 participants