0

I currently have an event trigger firing a custom trigger action.

The action passes back a EventArgs type of object to the view's view-model.

This is all well and good when I run the code it works perfectly. However, when I come to test this portion of code it all goes a bit rubbish.

As stated We are using an MVVM type pattern so I'm testing the 'Doing' end of the event trigger in my view-model and what I want to do is create a 'mocked' EventArgs object to pass into the execute method of my command under test. However it requires a RoutedEvent as it's ID property as stated above and I don't have access to it's constructor!

Cannot Access Internal Constructor for 'RoutedEvent' here.

Has anyone got any ideas? The code converage in test is more important than the current implimentation so if this is thought to be 'untestable', then I can make changes.


Why do I get an error with .Click() Event for an Asp:LinkButton in Firefox?

I am attempting to fire the click() event when a button is clicked.

This currently works for me in IE however I receive the following error in firefox:

"link.click is not a function"

I have been trawling google regarding this and found out the .click event is not supported in all versions of firefox.

Is anyone able to provide an alternative? Code below:

<asp:LinkButton ID="ButtonNext" runat="server" CssClass="RemoveLinkStyle" TabIndex="1"></asp:LinkButton>
<table id="tblButtonNext" runat="server" cellpadding="0" cellspacing="0" class="pwbtn" onclick="ButtonClick(ButtonNext);" TabIndex="1" onmouseout="this.className='pwbtn';" onmouseover="this.className='pwbtnh';">
<tr>
    <td class="a1"></td>
    <td class="a2">
        <%= this.resourceManager.GetString("nextstep") %>
    </td>
    <td class="a3"></td>
    <td class="spacer"></td>
</tr>
</table>

function ExecuteLink(linkID)
{
    var link = document.getElementById(linkID);
    link.click();
}

function ButtonClick(linkID)
{
    PreNavigationScript();
    CallShowBlocker();
    ExecuteLink(linkID); 
}
4

1 に答える 1

0

私は自分の質問に答えたと思います。

以前の時点でビューから返されたオブジェクトをキャストするということは、テスト中のメソッドに渡すオブジェクトがより簡単に作成されることを意味します。

これは、テスト対象のメソッドに対して現在持っているものです。

public void DoItemsChanged(IList param)

私が持っていた前に

public void DoItemsChanged(object param)

param が SelectedItemCollection である場合 (以前は RoutedEventArgs でしたが、現在はビューのイベント トリガーで IvokeCommandAction を使用し、SelectedItems を割り当てます)。パラメータは、テスト用のメソッドに簡単に渡されるようになり、コードもより説明的になりました。だから、それは誰にとっても良いことです。

于 2011-06-30T08:37:25.333 に答える