Exemplo n.º 1
0
        public async Task PerformSearch_NegativeCaretPosition_Throws()
        {
            var host    = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var testObj = new LocationSearchService(host);

            _ = await testObj.PerformSearch("", -2);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an instance of <see cref="LocationsViewModel"/>
        /// </summary>
        public LocationsViewModel(Compendium compendium, LocationSearchService locationSearchService, LocationSearchInput locationSearchInput,
                                  StringService stringService, DialogService dialogService, XMLImporter xmlImporter, DocumentService documentService, DataManager dataManager)
        {
            _compendium            = compendium;
            _locationSearchService = locationSearchService;
            _locationSearchInput   = locationSearchInput;
            _stringService         = stringService;
            _dialogService         = dialogService;
            _xmlImporter           = xmlImporter;
            _documentService       = documentService;
            _dataManager           = dataManager;

            _selectLocationCommand     = new RelayCommand(obj => true, obj => SelectLocation(obj as ListItemViewModel <LocationModel>));
            _editLocationCommand       = new RelayCommand(obj => true, obj => EditLocation(obj as LocationViewModel));
            _exportLocationCommand     = new RelayCommand(obj => true, obj => ExportLocation(obj as LocationViewModel));
            _cancelEditLocationCommand = new RelayCommand(obj => true, obj => CancelEditLocation());
            _saveEditLocationCommand   = new RelayCommand(obj => HasUnsavedChanges, obj => SaveEditLocation());
            _resetFiltersCommand       = new RelayCommand(obj => true, obj => InitializeSearch());
            _addCommand            = new RelayCommand(obj => true, obj => Add());
            _copyCommand           = new RelayCommand(obj => _selectedLocation != null, obj => Copy());
            _deleteCommand         = new RelayCommand(obj => _selectedLocation != null, obj => Delete());
            _importCommand         = new RelayCommand(obj => true, obj => Import());
            _selectNextCommand     = new RelayCommand(obj => true, obj => SelectNext());
            _selectPreviousCommand = new RelayCommand(obj => true, obj => SelectPrevious());

            Search();
        }
Exemplo n.º 3
0
        public async Task PerformSearch_CaretPositionBeyondSearchTextLength_Throws()
        {
            var host    = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var testObj = new LocationSearchService(host);

            _ = await testObj.PerformSearch("test", 5);
        }
Exemplo n.º 4
0
        public void ShouldCallToLocationProviderIfTheInputIsALocation()
        {
            var locationLookupService = new LocationSearchService(_locationLookupProvider.Object,
                                                                  _postcodeLookupProvider.Object, _logger.Object);

            locationLookupService.FindLocation(ALocation);

            _locationLookupProvider.Verify(llp => llp.FindLocation(ALocation, 50));
        }
Exemplo n.º 5
0
        public void ShouldCallToPostcodeProviderIfTheInputIsAPartialPostcode()
        {
            var locationLookupService = new LocationSearchService(_locationLookupProvider.Object,
                                                                  _postcodeLookupProvider.Object, _logger.Object);

            locationLookupService.FindLocation(ValidPartialPostcode);

            _postcodeLookupProvider.Verify(plp => plp.GetLocation(ValidPartialPostcode));
        }
Exemplo n.º 6
0
        public async Task PerformSearch_NullSearchText_TreatAsEmpty()
        {
            var    host         = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var    testObj      = new LocationSearchService(host);
            string searchString = null;

            CompletionSet result = await testObj.PerformSearch(searchString, 0);

            Assert.AreEqual(3, result.Completions.Count());
        }
Exemplo n.º 7
0
        public async Task PerformSearch_SearchTextContainsSeparator_ReturnSubdirectoriesOnly()
        {
            var    host         = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var    testObj      = new LocationSearchService(host);
            string searchString = "RootFolder2/";

            CompletionSet result = await testObj.PerformSearch(searchString, searchString.Length);

            Assert.AreEqual(1, result.Completions.Count());
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "RootFolder2/SubFolder/"));
        }
Exemplo n.º 8
0
        public async Task PerformSearch_SearchTextDoesNotContainSeparator_FilterSearchResults()
        {
            var    host         = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var    testObj      = new LocationSearchService(host);
            string searchString = "Root";

            CompletionSet result = await testObj.PerformSearch(searchString, searchString.Length);

            Assert.AreEqual(2, result.Completions.Count());
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "RootFolder1/"));
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "RootFolder2/"));
        }
Exemplo n.º 9
0
        public async Task PerformSearch_EmptySearchText_ReturnsContentsOfWorkingDirectory()
        {
            var    host         = new Mocks.HostInteraction(TestDirectoryRoot, null);
            var    testObj      = new LocationSearchService(host);
            string searchString = "";

            CompletionSet result = await testObj.PerformSearch(searchString, searchString.Length);

            Assert.AreEqual(3, result.Completions.Count());
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "RootFolder1/"));
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "RootFolder2/"));
            Assert.IsTrue(result.Completions.Any(c => c.InsertionText == "DifferentlyNamedFolder/"));
        }
Exemplo n.º 10
0
 void Initialize()
 {
     MainService           = new MainService(this);
     ObjectService         = new ObjectService(this);
     ScriptService         = new ScriptService(this);
     SimbadService         = new SimbadService(this);
     ActionService         = new ActionService(this);
     PropertyService       = new PropertyService(this);
     LocationService       = new LocationService(this);
     LocationSearchService = new LocationSearchService(this);
     ViewService           = new ViewService(this);
     if (OnStellariumInitialized != null)
     {
         OnStellariumInitialized();
     }
 }
        protected LocationServiceTestsBase()
        {
            _mockIdEncoder = new Mock<ILocationIdEncoder>();
            _mockIdEncoder.Setup(e => e.Decode(It.IsAny<string>())).Returns<string>(x => x);
            _mockIdEncoder.Setup(e => e.Encode(It.IsAny<string>())).Returns<string>(x => x);

            var mockMapper = new LocationModelMapper();

            _mockLocationQueryFields = new Mock<ILocationQueryFields>();

            _mockQueryValidator = new Mock<ILocationQueryValidator>();
            _mockQueryValidator.Setup(v => v.IsValid(It.IsAny<string>())).Returns(true);

            _mockLocationRepository = new Mock<ILocationRepository>();
            _mockLocationGroupRepository = new Mock<ILocationGroupRepository>();
            _mockQuerySanitiser = new Mock<ILocationQuerySanitiser>();
            _mockQuerySanitiser.Setup(s => s.Sanitise(It.IsAny<string>())).Returns<string>(q => q.ToLower());

            _mockLocationGroupFormatter = new Mock<IConditionalFormatter<string, LocationDataField>>();
            _mockLocationGroupFormatter.Setup(
                r => r.DetermineConditionsAndFormat(It.IsAny<string>(), It.IsAny<LocationDataField>())).Returns((string value, LocationDataField type) => value);

            _mockLocationFormatter = new Mock<IConditionalFormatter<string, string>>();
            _mockLocationFormatter.Setup(
                r => r.DetermineConditionsAndFormat(It.IsAny<string>(), It.IsAny<string>())).Returns((string value, string type) => value);

            _sutSearch = new LocationSearchService(_mockLocationGroupRepository.Object, _mockQueryValidator.Object, _mockQuerySanitiser.Object, _mockLocationQueryFields.Object, _mockIdEncoder.Object);
            _sutPostcode = new LocationSearchPostcodeService(_mockLocationRepository.Object, _mockQueryValidator.Object, _mockQuerySanitiser.Object, mockMapper);
            _sutGet = new LocationRetrievalService(_mockLocationRepository.Object, _mockIdEncoder.Object, mockMapper);

            _mockDataReader = new Mock<IDataRecord>();
            _mockDataReader.Setup(r => r[It.IsAny<string>()]).Returns("");
            _mockDataReader.Setup(r => r["UPRN"]).Returns("1");
            _mockDataReader.Setup(r => r[It.Is<string>(x => x == "X_COORDINATE")]).Returns("1.0");
            _mockDataReader.Setup(r => r[It.Is<string>(y => y == "Y_COORDINATE")]).Returns("2.0");

            _builder = new LocationGroupBuilder(_mockLocationGroupFormatter.Object);
            _locationQueryFields = new SqlIteLocationQueryFields();
        }
        public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            IController controller = null;

            if (string.Compare(controllerName, EnumControllerName.Account.ToString(), true) == 0)
            {
                IBaseAsyncService <IHireThingsUser> service = new UserService();
                controller = new AccountController((IUserService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Error.ToString(), true) == 0)
            {
                IBaseAsyncService <IErrorViewModel> service = new ErrorService();
                controller = new ErrorController((IErrorService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Country.ToString(), true) == 0)
            {
                IBaseAsyncService <ICountryModel> service = new CountryService();
                controller = new CountryController((ICountryService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.CountrySearch.ToString(), true) == 0)
            {
                IBaseAsyncService <ICountrySearchViewModel> service = new CountrySearchService();
                controller = new CountrySearchController((ICountrySearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.LocationSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <ILocationSearchViewModel> service = new LocationSearchService();
                controller = new LocationSearchController((ILocationSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Location.ToString(), true) == 0)
            {
                IBaseAsyncService <ILocationModel> service = new LocationService();
                controller = new LocationController((ILocationService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.Theme.ToString(), true) == 0)
            {
                IBaseAsyncService <IThemeModel> service = new ThemeService();
                controller = new ThemeController((IThemeService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.ThemeSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IThemeSearchViewModel> service = new ThemeSearchService();
                controller = new ThemeSearchController((IThemeSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Category.ToString(), true) == 0)
            {
                IBaseAsyncService <ICategoryModel> service = new CategoryService();
                controller = new CategoryController((ICategoryService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.CategorySearch.ToString(), true) == 0)
            {
                IBaseAsyncService <ICategorySearchViewModel> service = new CategorySearchService();
                controller = new CategorySearchController((ICategorySearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.EmailServerSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IEmailServerSearchViewModel> service = new EmailServerSearchService();
                controller = new EmailServerSearchController((IEmailServerSearchService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.EmailServer.ToString(), true) == 0)
            {
                IBaseAsyncService <IEmailServerModel> service = new EmailServerService();
                controller = new EmailServerController((IEmailServerService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.UserSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IUserSearchViewModel> service = new UserSearchService();
                controller = new UserSearchController((IUserSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.User.ToString(), true) == 0)
            {
                IBaseAsyncService <IHireThingsUser> service = new UserService();
                controller = new UserController((IUserService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.SecurityQuestion.ToString(), true) == 0)
            {
                IBaseAsyncService <ISecurityQuestionModel> service = new SecurityQuestionService();
                controller = new SecurityQuestionController((ISecurityQuestionService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.SecurityInfo.ToString(), true) == 0)
            {
                IBaseAsyncService <ISecurityInfoViewModel> service = new SecurityInfoService();
                controller = new SecurityInfoController((ISecurityInfoService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.RoleSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IRoleSearchViewModel> service = new RoleSearchService();
                controller = new RoleSearchController((IRoleSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Role.ToString(), true) == 0)
            {
                IBaseAsyncService <IRoleModel> service = new RoleService();
                controller = new RoleController((IRoleService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.ObjectSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IObjectSearchViewModel> service = new ObjectSearchService();
                controller = new ObjectSearchController((IObjectSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Object.ToString(), true) == 0)
            {
                IBaseAsyncService <IObjectModel> service = new ObjectService();
                controller = new ObjectController((IObjectService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Dropdown.ToString(), true) == 0)
            {
                IBaseAsyncService <IDropdownModel> service = new DropdownService();
                controller = new DropdownController((IDropdownService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.RoleObject.ToString(), true) == 0)
            {
                IBaseAsyncService <IRoleObjectViewModel> service = new RoleObjectService();
                controller = new RoleObjectController((IRoleObjectService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.Home.ToString(), true) == 0)
            {
                IBaseAsyncService <IHomeModel> service = new HomeService();
                controller = new HomeController((HomeService)service);
            }

            else if (string.Compare(controllerName, EnumControllerName.ItemDelete.ToString(), true) == 0)
            {
                IBaseAsyncService <IItemDeleteModel> service = new ItemDeleteService();
                controller = new ItemDeleteController((ItemDeleteService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiRoleSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiRoleSearchViewModel> service = new WebApiRoleSearchService();
                controller = new WebApiRoleSearchController((IWebApiRoleSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiRole.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiRoleModel> service = new WebApiRoleService();
                controller = new WebApiRoleController((IWebApiRoleService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiObjectSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiObjectSearchViewModel> service = new WebApiObjectSearchService();
                controller = new WebApiObjectSearchController((IWebApiObjectSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiObject.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiObjectModel> service = new WebApiObjectService();
                controller = new WebApiObjectController((IWebApiObjectService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiUserSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiUserSearchViewModel> service = new WebApiUserSearchService();
                controller = new WebApiUserSearchController((IWebApiUserSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebApiUser.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebApiUser> service = new WebApiUserService();
                controller = new WebApiUserController((IWebApiUserService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.WebAPIRoleObject.ToString(), true) == 0)
            {
                IBaseAsyncService <IWebAPIRoleObjectViewModel> service = new WebAPIRoleObjectService();
                controller = new WebAPIRoleObjectController((IWebAPIRoleObjectService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Main.ToString(), true) == 0)
            {
                IBaseAsyncService <IMainModel> service = new MainService();
                controller = new MainController((MainService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.Advertisement.ToString(), true) == 0)
            {
                IBaseAsyncService <IAdvertisementModel> service = new AdvertisementService();
                controller = new AdvertisementController((AdvertisementService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.PublicAdvertisement.ToString(), true) == 0)
            {
                IBaseAsyncService <IAdvertisementModel> service = new AdvertisementService();
                controller = new PublicAdvertisementController((AdvertisementService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.PublicAdvertisementSearch.ToString(), true) == 0)
            {
                IBaseAsyncService <IAdvertisementSearchViewModel> service = new AdvertisementSearchService();
                controller = new PublicAdvertisementSearchController((AdvertisementSearchService)service);
            }
            else if (string.Compare(controllerName, EnumControllerName.PublicAccount.ToString(), true) == 0)
            {
                IBaseAsyncService <IHireThingsUser> service = new UserService();
                controller = new PublicAccountController((UserService)service);
            }
            else
            {
                throw new HttpException(404, "Page not Found");
            }


            return(controller);
        }