public async Task AutoCompleteDataReturnsCacheData()
        {
            //Arrange

            //Mock AutoComplete data
            Task <IEnumerable <AutocompleteViewModel> > autoCompleteLst =
                Task.FromResult <IEnumerable <AutocompleteViewModel> >(
                    MockData.GetSchoolResultList(false).ConvertToAutocompleteViewModel()
                    );

            //Return mock AutoComplete list when GetAutoCompleteData is called
            _mockRedisCache.Setup(m => m.GetAutoCompleteData()).Returns(autoCompleteLst);

            //Return an empty list when GetAll is called
            //This should not be called if test is working correctly)
            _mockSchoolResult.Setup(m => m.GetAll(It.IsAny <Expression <Func <SchoolResult, object> >[]>()))
            .Returns(Task.FromResult <IEnumerable <SchoolResult> >(new List <SchoolResult>()));

            _autoCompleteService = new AutoCompleteService(_mockSchoolResult.Object, _mockRedisCache.Object, _logger);

            //Act
            var results = await _autoCompleteService.Get();

            //Assert
            Assert.IsNotNull(results);
        }
        public async Task AutoCompleteDataReturnsStaticList()
        {
            //Arrange
            Task <IEnumerable <AutocompleteViewModel> > autocompleteLstEmpty =
                Task.FromResult <IEnumerable <AutocompleteViewModel> >(new List <AutocompleteViewModel>());

            //Return an empty list when GetAutoCompleteData is called
            //This should not be called if test is working correctly
            _mockRedisCache.Setup(m => m.GetAutoCompleteData()).Returns(autocompleteLstEmpty);

            //Return an empty list when GetAll is called
            //This should not be called if test is working correctly)
            _mockSchoolResult.Setup(m => m.GetAll(It.IsAny <Expression <Func <SchoolResult, object> >[]>()))
            .Returns(Task.FromResult <IEnumerable <SchoolResult> >(new List <SchoolResult>()));

            _autoCompleteService = new AutoCompleteService(_mockSchoolResult.Object, _mockRedisCache.Object, _logger);

            var autoCompleteLst = MockData.GetSchoolResultList(false).ConvertToAutocompleteViewModel();

            //Use reflection to get the private static filed _school from AutoCompleteService
            typeof(AutoCompleteService).GetField("_schools", BindingFlags.NonPublic | BindingFlags.Static)
            .SetValue(_autoCompleteService, autoCompleteLst);

            //Act
            var results = await _autoCompleteService.Get();

            //Assert
            Assert.IsNotNull(results);
        }
        public async Task AutoCompleteDataReturnedIfNoDataIsInCache()
        {
            //Arrange
            Task <IEnumerable <AutocompleteViewModel> > autocompleteLst =
                Task.FromResult <IEnumerable <AutocompleteViewModel> >(new List <AutocompleteViewModel>());

            //Return an empty list when GetAutoCompleteData is called
            _mockRedisCache.Setup(m => m.GetAutoCompleteData()).Returns(autocompleteLst);

            //Return a list of SchoolResult data when get method is called
            _mockSchoolResult.Setup(m => m.GetAll(It.IsAny <Expression <Func <SchoolResult, object> >[]>()))
            .Returns(_schoolResults);

            _autoCompleteService = new AutoCompleteService(_mockSchoolResult.Object, _mockRedisCache.Object, _logger);

            //Act
            var results = await _autoCompleteService.Get();

            //Assert
            Assert.IsNotNull(results);
        }