I’ve got a wizard with a bunch of “steps” and in each step a bunch of “inputs” (textboxes, radio button lists, checkbox lists, drop downs).
Everything is working great, but I am now trying to perform some calculations on my final “Submitted” step of the wizard, and I need to do two things:
1) Work out the logic of a+b+(c*2), etc. I don’t need to “test” this, I just have a bunch of if/else clauses and am mapping out the calculations.
2) In order to facilitate the above, and to see the output (including the CSS / UI and stuff) rather quickly, I want to pass fake data from all the steps. How best to do this?
I am using a bunch of Models / ViewModels, so MyModel might have:
public string FirstName { get; set; }
and MyViewModel would have:
public MyModel MyModel { get; set; }
Now, there are about 10 models pulled into one view model, and basically there are like 50+ inputs. My problem is if I want to see the end result of “Submitted” I have to go through the wizard each time.
I’d like to just skip that for this purpose, pass fake data without going through the entire wizard (assume my entry point is my “Confirm” step which has a button to “Submit”, so I’d like to start at “Confirm” and then click “Submit” (otherwise, maybe I can just start at “Submitted” step)).
It sounds like you aren’t unit testing this so a way you could fake this is to create a dummy view model in the controller’s confirm get action:
Then change the properties to the settings you need in order to test out each part of your post logic. It will be a little slow as you will need to change the properties every run until you have tested all the logical flow.
Without a testing framework you are forced to run the program and input each step as you have described. With this you can at least forego doing each step over and over again and you can go straight to the confirm step and have the fake data ready.
Additionally, if you move the logic out of the controller’s post action and into a class that takes in the model you could also more easily test this if you are using a testing framework. You would then be using the controller to only pass the data in and perhaps respond to the classes result that it passes back.