lundi 30 mai 2016

Moq framework to test method execute times

Please look at my code below, the verification always failed. Anyone can help?

public class ViewModel
{
    private IMyDataService dataService = null;

    public ViewModel(IMyDataService dataService)
    {
        this.dataService = dataService;
    }

    public Dictionary<string, string> filters {get; set;}

    public void ProcessFilters()
    {
        dataService.ProcessFilters(filters);
    }
}

[TestMethod]
public void ProcessFilters_Test()
{
    var mockService = new Mock<IMyDataService>();
    ViewModel vm = new ViewModel(mockService.Object);
    Dictionary<string,string> filters = null;
    vm.ProcessFilters(filters);
    mockService.Verify(x=>x.ProcessFilters(filters), Times.Once);
}

Aucun commentaire:

Enregistrer un commentaire