Click here to Skip to main content
15,896,437 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Database Connectivity in Silverlight Web Application Pin
Ibrahim.Poonawala1-Feb-11 4:19
Ibrahim.Poonawala1-Feb-11 4:19 
GeneralRe: Database Connectivity in Silverlight Web Application Pin
Pete O'Hanlon1-Feb-11 4:26
mvePete O'Hanlon1-Feb-11 4:26 
AnswerRe: Database Connectivity in Silverlight Web Application Pin
Vimalsoft(Pty) Ltd6-Feb-11 19:47
professionalVimalsoft(Pty) Ltd6-Feb-11 19:47 
QuestionControl to display Html in a string - not WebBrowser control Pin
devvvy27-Jan-11 15:49
devvvy27-Jan-11 15:49 
AnswerRe: Control to display Html in a string - not WebBrowser control Pin
_Maxxx_27-Jan-11 16:49
professional_Maxxx_27-Jan-11 16:49 
GeneralRe: Control to display Html in a string - not WebBrowser control Pin
devvvy27-Jan-11 21:38
devvvy27-Jan-11 21:38 
AnswerRe: Control to display Html in a string - not WebBrowser control Pin
Abhinav S28-Jan-11 2:17
Abhinav S28-Jan-11 2:17 
QuestionTDD - Messenger, Testing Help Request... Pin
_Maxxx_27-Jan-11 15:27
professional_Maxxx_27-Jan-11 15:27 
To be fair, I think this is a TDD question rather than specifically WPF - but it is the use of the messanger in MVVM in WPF that is causing the issue - hence the post here...

WPF with MVVM using the bare bones of the MvvmFoundation.

public CustomerSelectionAndSummaryViewModel(IController controller, FrameworkElement view)
    : base(controller, view)
{
    controller.Messenger.Register(Controller.MSG_Customer_SELECTED, new Action<CustomerListItemViewData>(ProcessSelection));
    CustomerSelectionViewModel = new CustomerSelectionViewModel(controller);
    CustomerSummaryViewModel = new CustomerSummaryViewModel(controller);
}
#endregion

private void ProcessSelection(CustomerListItemViewData CustomerListItemViewData)
{
    // Get the data to show in our small, local summary
    CustomerSummaryViewModel.ViewData = Controller.GetCustomerSummaryViewData((int) CustomerListItemViewData.CustomerId);
    // Ask the controller to handle the selection
    Controller.CustomerSelected((int) CustomerListItemViewData.CustomerId);

}


Briefly, the Constructor is passed an IController - which is just a helper class, and a view (which we can ignore for these purposes)
The base class for our ViewModel stores the IController in a property.
YOu can see I register the message for a customer being selected - so that when a customer is selected I can action the selection. The rest of the constructor just instantiates a couple of other View Models that are children of this one- again this can be ignored.

So the Action passed to the Messenger.Register method 'points to' the ProcessSelection method.

Here I am saying, when something sends the Customer_SELECTED message, this ViewModel wants to handle it by executing the ProcessSelection method.

With me so far? Good Ho!

I've made the method private because the other developers are just plain stoopid (I'm a sole developer on this one, in fact, but ITRW...) and if it's not private they might decide to use it directly, which is NAGT (Not A Good Thing)

OK so, I hear you ask, what's the prob?

I want to be a good little dev and use some tests. I'd like to test the ProcessSelection() method somehow, to ensure that it calls the CustomerSelected() method with the selected Customer ID when passed a valid CustomerListItemViewData.

So (bear in mind I'm very new to TDD here)

The main stumbling block for me here is that the method is private - and I'd like it to remain so.

I can see this being a problem with these messages flying about (as the project expands) as the ViewModels are likely to use private methods to implement the functionality required when handling the message.

Many people seem to say that you shouldn't test private methods. Fair enough - but in this case shouldn't I be testing the functionality of the system when a Customer is selected?

I'm thinking that this particular private method is, in essence, public because it can be executed (be sending a message) from outside of its class. So, perhaps this is a more generic question.

The only alternate option I can think of right now would be to not test this method, but instead test the method by sending the message..?

OK - I've waffled enough! I'm, hoping you have the stamina to read through this and help me out - if not, well, it's been cathartic writing it anyhoo.
___________________________________________
.\\axxx
(That's an 'M')

AnswerRe: TDD - Messenger, Testing Help Request... Pin
Pete O'Hanlon27-Jan-11 22:41
mvePete O'Hanlon27-Jan-11 22:41 
GeneralRe: TDD - Messenger, Testing Help Request... Pin
_Maxxx_30-Jan-11 22:27
professional_Maxxx_30-Jan-11 22:27 
GeneralRe: TDD - Messenger, Testing Help Request... Pin
Pete O'Hanlon31-Jan-11 10:41
mvePete O'Hanlon31-Jan-11 10:41 
QuestionHow to sort list view by clicking column header? [modified] Pin
Tesic Goran27-Jan-11 1:02
professionalTesic Goran27-Jan-11 1:02 
AnswerRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 2:00
mveRichard MacCutchan27-Jan-11 2:00 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 2:32
professionalTesic Goran27-Jan-11 2:32 
GeneralRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 3:10
mveRichard MacCutchan27-Jan-11 3:10 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 3:41
professionalTesic Goran27-Jan-11 3:41 
GeneralRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 3:55
mveRichard MacCutchan27-Jan-11 3:55 
AnswerRe: How to sort list view by clicking column header? Pin
dasblinkenlight27-Jan-11 3:57
dasblinkenlight27-Jan-11 3:57 
AnswerRe: How to sort list view by clicking column header? Pin
beeritger27-Jan-11 14:10
beeritger27-Jan-11 14:10 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 21:19
professionalTesic Goran27-Jan-11 21:19 
Questionpdf to xaml wrapper Pin
BoySetsFire26-Jan-11 3:45
BoySetsFire26-Jan-11 3:45 
AnswerRe: pdf to xaml wrapper Pin
Jason McBurney27-Jan-11 7:32
Jason McBurney27-Jan-11 7:32 
QuestionSilverlight DataGrid throwing error Pin
Santhosh Sebastian Mattathil24-Jan-11 21:48
Santhosh Sebastian Mattathil24-Jan-11 21:48 
AnswerRe: Silverlight DataGrid throwing error Pin
Pete O'Hanlon24-Jan-11 21:55
mvePete O'Hanlon24-Jan-11 21:55 
GeneralRe: Silverlight DataGrid throwing error Pin
Santhosh Sebastian Mattathil24-Jan-11 22:01
Santhosh Sebastian Mattathil24-Jan-11 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.