public async Task CallFilterSpellsAsync_WhenCalled() { // Arrange Mock <ISpellService> spellServiceMock = new Mock <ISpellService>(); 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 <Spell> spells = new PagedList <Spell>(new List <Spell>().AsQueryable(), validPageNumber, validPageSize); spellServiceMock.Setup(mock => mock.FilterSpellsAsync(validSortOrder, validFilter, validPageNumber, validPageSize)) .Returns(Task.FromResult(spells)); SpellController SUT = new SpellController( spellServiceMock.Object, pDFServiceMock.Object, memoryCacheMock.Object); // Act await SUT.Filter(validSortOrder, validFilter, validPageNumber, validPageSize); // Assert spellServiceMock .Verify(mock => mock.FilterSpellsAsync(validSortOrder, validFilter, validPageNumber, validPageSize), Times.Once); }
public async Task ReturnCorrectViewModel_WhenCalled() { // Arrange Mock <ISpellService> spellServiceMock = new Mock <ISpellService>(); 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 <Spell> spells = new PagedList <Spell>(new List <Spell>().AsQueryable(), validPageNumber, validPageSize); spellServiceMock.Setup(mock => mock.FilterSpellsAsync(validSortOrder, validFilter, validPageNumber, validPageSize)) .Returns(Task.FromResult(spells)); SpellController SUT = new SpellController( spellServiceMock.Object, pDFServiceMock.Object, memoryCacheMock.Object); // Act var result = await SUT.Filter(validSortOrder, validFilter, validPageNumber, validPageSize) as PartialViewResult; // Assert Assert.IsInstanceOfType(result.Model, typeof(TableViewModel <SpellViewModel>)); }