Code: Select all
[TestMethod]
public void GotoPageCommand_Calls_PCCollection_SearchPage()
{
var page = 100;
var sut = CreateSut();
sut.SearchPage = page;
sut.GotoPageCommand.Execute(null);
_tableViewModel.Verify(s => s.SearchPage(page), Times.Once());
}
Dies ist eine vereinfachte Version der getesteten Methode (der GotoPageCommand, der dann die SearchPage-Methode aufrufen sollte). ):
im Ansichtsmodell:
Code: Select all
public ICommand GotoPageCommand { get; }
. . .
// in the ctor:
GotoPageCommand = new DelegatingCommand(GotoPage, CanGotoPage);
. . .
// the GotoPage method
private async void GotoPage()
{
// lots of stuff...
try
{
await Task.Run(() =>
{
// This is the problem line that correctly verifies as being
// called once when run locally, but shows zero times when
// run on build server.
_pcCollection.PagData.SearchPage(page);
});
}