I've got basic unit testing working, but not sure how to deal with all the calls to setup a SelectList. I can't possibly pass in a dozen or so different mocks for the dropdowns. So, I'm looking for suggestions on how to handle this.
generaly there is no database connection during unit testing so u need to mock for model this is manually tempary data fill in model and use this model as testing or if you have no problem with database connection then you can fill data from database at
the time of Initialization.
Please, Mark as Answer if this reply helped you.
Marked as answer by Angie xu - MSFT on Sep 17, 2012 05:56 AM
Umm.. yes, exactly my point. The way this is generally handled is to pass the mocked context into the constructor of the controller. But, I may have a dozen or more drop downs on a single view. Passing that many parameters is definitely an antipattern. I'm
looking for input on options to handle this.
Umm.. yes, exactly my point. The way this is generally handled is to pass the mocked context into the constructor of the controller.
But, I may have a dozen or more drop downs on a single view. Passing that many parameters is definitely an antipattern. I'm looking for input on options to handle this.
i had the same problem only i had arround 6000 dropdowns in 1 view => huge editable table which made every single browser crash and had a load time equal to coffeetime...
anyway i fixed this by using some jquery to create the controls when they click the field so now i got this huge table but only 1 dropdown at a time...
i also combined another custom dropdown (jquery.ui.selectemenu)
craigber
Member
29 Points
22 Posts
How to unit test controller
Sep 10, 2012 08:11 PM|LINK
I've got basic unit testing working, but not sure how to deal with all the calls to setup a SelectList. I can't possibly pass in a dozen or so different mocks for the dropdowns. So, I'm looking for suggestions on how to handle this.
ashoksudani
Participant
1043 Points
213 Posts
Re: How to unit test controller
Sep 11, 2012 04:23 AM|LINK
generaly there is no database connection during unit testing so u need to mock for model this is manually tempary data fill in model and use this model as testing or if you have no problem with database connection then you can fill data from database at the time of Initialization.
craigber
Member
29 Points
22 Posts
Re: How to unit test controller
Sep 11, 2012 02:33 PM|LINK
Umm.. yes, exactly my point. The way this is generally handled is to pass the mocked context into the constructor of the controller. But, I may have a dozen or more drop downs on a single view. Passing that many parameters is definitely an antipattern. I'm looking for input on options to handle this.
ashoksudani
Participant
1043 Points
213 Posts
Re: How to unit test controller
Sep 12, 2012 05:00 AM|LINK
i can understand what you want. but u need to do this.
sp00k
Participant
1916 Points
435 Posts
Re: How to unit test controller
Sep 12, 2012 09:30 AM|LINK
i had the same problem only i had arround 6000 dropdowns in 1 view => huge editable table which made every single browser crash and had a load time equal to coffeetime...
anyway i fixed this by using some jquery to create the controls when they click the field so now i got this huge table but only 1 dropdown at a time...
i also combined another custom dropdown (jquery.ui.selectemenu)
reffer: http://filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/
reffer: http://www.appelsiini.net/projects/jeditable