public async Task CallFilterTeamsAsync_WhenCalled() { // Arrange Mock <ITeamService> teamServiceMock = new Mock <ITeamService>(); Mock <IPDFService> pDFServiceMock = new Mock <IPDFService>(); Mock <IMemoryCache> memoryCacheMock = new Mock <IMemoryCache>(); string validSortOrder = string.Empty; string validFilter = string.Empty; int validPageNumber = 1; int validPageSize = 10; IPagedList <Team> teams = new PagedList <Team>(new List <Team>().AsQueryable(), validPageNumber, validPageSize); teamServiceMock.Setup(mock => mock.FilterTeamsAsync(validSortOrder, validFilter, validPageNumber, validPageSize)) .Returns(Task.FromResult(teams)); TeamController SUT = new TeamController( teamServiceMock.Object, pDFServiceMock.Object, memoryCacheMock.Object); // Act await SUT.Filter(validSortOrder, validFilter, validPageNumber, validPageSize); // Assert teamServiceMock .Verify(mock => mock.FilterTeamsAsync(validSortOrder, validFilter, validPageNumber, validPageSize), Times.Once); }
public async Task ReturnCorrectViewModel_WhenCalled() { // Arrange Mock <ITeamService> teamServiceMock = new Mock <ITeamService>(); Mock <IPDFService> pDFServiceMock = new Mock <IPDFService>(); Mock <IMemoryCache> memoryCacheMock = new Mock <IMemoryCache>(); string validSortOrder = string.Empty; string validFilter = string.Empty; int validPageNumber = 1; int validPageSize = 10; IPagedList <Team> teams = new PagedList <Team>(new List <Team>().AsQueryable(), validPageNumber, validPageSize); teamServiceMock.Setup(mock => mock.FilterTeamsAsync(validSortOrder, validFilter, validPageNumber, validPageSize)) .Returns(Task.FromResult(teams)); TeamController SUT = new TeamController( teamServiceMock.Object, pDFServiceMock.Object, memoryCacheMock.Object); // Act var result = await SUT.Filter(validSortOrder, validFilter, validPageNumber, validPageSize) as PartialViewResult; // Assert Assert.IsInstanceOfType(result.Model, typeof(TableViewModel <TeamViewModel>)); }