public async Task <TableViewModelAll> GetNationalTableDataAll() { _logger.LogInformation("Executing GetNationalTableDataAll method in RedisCache class."); TableViewModelAll nationalData = null; bool dataInCache = false; try { //Check if National TableViewModelAll data is in cache dataInCache = await _redisCacheClient.Db0.ExistsAsync("NationalTableViewModelAll"); if (dataInCache) { nationalData = await _redisCacheClient .Db0.GetAsync <TableViewModelAll>("NationalTableViewModelAll"); } } catch (Exception e) { _logger.LogError("An exception occurred when attempting to get NationalTableViewModelAll data from cache." + " Stack trace: " + e.StackTrace); } return(nationalData); }
public async Task GetNationalTableDataAllReturnsEmptyObjectIfDataIsNotInCache() { //Arrange SetupRedisCacheClient(); //Act TableViewModelAll result = await _redisCache.GetNationalTableDataAll(); //Assert Assert.IsNull(result); }
public void ResultModelWithNoSchoolObjectToTableViewModelAll() { //Arrange SchoolResult result = MockData.GetSchoolResult(false); //Act TableViewModelAll resultViewModel = result; //Assert //Checks the Schoolresult object gets converted to TableViewModel Assert.IsNotNull(resultViewModel); }
public async Task SaveNationalTableDataAll(TableViewModelAll nationalTableData) { _logger.LogInformation("Executing SaveNationalTableDataAll method in RedisCache class."); try { await _redisCacheClient .Db0 .AddAsync("NationalTableViewModelAll", nationalTableData, DateTimeOffset.Now.AddMinutes(30)); } catch (Exception e) { _logger.LogError("An exception occurred when attempting to save NationalTableViewModelAll data to cache." + " Stack trace: " + e.StackTrace); } }
public void ResultModelToTableViewModelAll() { //Arrange SchoolResult result = MockData.GetSchoolResult(true); //Act TableViewModelAll resultViewModel = result; //Assert //Checks the Schoolresult object gets converted to TableViewModel Assert.IsNotNull(resultViewModel); //Checks the School name in the school model is included //when converting from SchoolResult to TableViewModel Assert.AreEqual(result.School.SCHNAME, resultViewModel.SCHNAME); }