/// <summary>
        /// Initializes a new instance of the SearchOrganizationInformationViewModel class.
        /// </summary>
        /// <param name="logger">The logger to be used by the instance.</param>
        /// <param name="mapper">The AutoMapper instance to use by the view model.</param>
        /// <param name="query">The query proxy to use in the actual searches.</param>
        public SearchOrganizationInformationViewModel(ILog logger, IMapper mapper, IRestQuery query)
        {
            this.logger = logger;
            this.mapper = mapper;
            this.query  = query;

            this.Model         = new SearchOrganizationInformationModel();
            this.SearchCommand = new RelayCommand <SearchOrganizationInformationModel>(this.SearchCommandHandler);

            PubSub <ObservableCollection <OrganizationModel> > .AddEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler);

            PubSub <bool> .AddEvent(EventNames.SearchStartedEvent, this.SearchStartedEventHandler);

            PubSub <string> .RegisterEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);
        }
        public void SearchOrganizationInformationViewModelTest_EMailSearch_SearchResultIsUpdated()
        {
            // Arrange
            PubSub <ObservableCollection <RoleModel> > .RegisterEvent(EventNames.RoleSearchResultReceivedEvent, this.RoleSearchResultReceivedEventHandler);

            Mock <ILog> logger = new Mock <ILog>();

            IList <Role> roles = new List <Role>();

            roles.Add(new Role());

            Mock <IRestQuery> query = new Mock <IRestQuery>();
            var ting = new List <KeyValuePair <string, string> >()
            {
            };

            query.Setup(s => s.Get <Role>(It.Is <List <KeyValuePair <string, string> > >(l => l.Count == 2))).Returns(roles);


            SearchRolesAndRightsInformationModel search = new SearchRolesAndRightsInformationModel
            {
                SubjectSearchText  = "16024400143",
                ReporteeSearchText = "910028146"
            };

            SearchRolesAndRightsInformationViewModel target = new SearchRolesAndRightsInformationViewModel(logger.Object, mapper, query.Object);

            // Act
            target.SearchCommand.Execute(search);

            // Wait for tasks to complete.
            Thread.Sleep(1000);

            // Assert
            query.VerifyAll();

            Assert.IsNotNull(this.searchResult);
            Assert.IsNotNull(target.SearchCommand);
            Assert.IsNotNull(target.Model);
        }
示例#3
0
        public void SearchOrganizationInformationViewModelTest_SendsEventWhenSearchResultIsReceived()
        {
            // Arrange
            PubSub <ObservableCollection <OrganizationModel> > .RegisterEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler);

            SearchOrganizationInformationModel search = new SearchOrganizationInformationModel
            {
                SearchType = SearchType.OrganizationNumber,
                SearchText = "910021451"
            };

            SearchOrganizationInformationViewModel target = GetViewModel();

            // Act
            target.SearchCommand.Execute(search);

            // Wait for tasks to complete.
            Thread.Sleep(1000);

            // Asserts
            Assert.IsNotNull(this.searchResult);
        }
        public void SearchRolesAndRightsInformationViewModelTest_SendsEventWhenSearchResultIsReceived()
        {
            // Arrange
            PubSub <ObservableCollection <RoleModel> > .RegisterEvent(EventNames.RoleSearchResultReceivedEvent, this.RoleSearchResultReceivedEventHandler);

            SearchRolesAndRightsInformationModel search = new SearchRolesAndRightsInformationModel
            {
                SubjectSearchText  = "16024400143",
                ReporteeSearchText = "910028146"
            };

            SearchRolesAndRightsInformationViewModel target = GetViewModel();

            // Act
            target.SearchCommand.Execute(search);

            // Wait for tasks to complete.
            Thread.Sleep(1000);

            // Asserts
            Assert.IsNotNull(this.searchResult);
        }
示例#5
0
        public void SearchOrganizationInformationViewModelTest_PhoneNumberSearch_SearchResultIsUpdated()
        {
            // Arrange
            PubSub <ObservableCollection <OrganizationModel> > .RegisterEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler);

            Mock <ILog> logger = new Mock <ILog>();

            IList <Organization> orgs = new List <Organization>();

            orgs.Add(new Organization());

            Mock <IRestQuery> query = new Mock <IRestQuery>();

            query.Setup(s => s.Get <Organization>(It.Is <KeyValuePair <string, string> >(pair => pair.Key == SearchType.PhoneNumber.ToString()))).Returns(orgs);

            SearchOrganizationInformationModel search = new SearchOrganizationInformationModel
            {
                SearchType = SearchType.Smart,
                SearchText = "47419641"
            };

            SearchOrganizationInformationViewModel target = new SearchOrganizationInformationViewModel(logger.Object, mapper, query.Object);

            // Act
            target.SearchCommand.Execute(search);

            // Wait for tasks to complete.
            Thread.Sleep(1000);

            // Assert
            query.VerifyAll();

            Assert.IsNotNull(this.searchResult);
            Assert.IsNotNull(target.SearchCommand);
            Assert.IsNotNull(target.Model);

            Assert.IsTrue(search.LabelText.Contains(Resources.PhoneNumber) && search.LabelText.Contains(search.SearchText));
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the SearchResultViewModel class.
        /// </summary>
        /// <param name="logger">The logger to be used by the instance.</param>
        /// <param name="mapper">The AutoMapper instance to use by the view model.</param>
        /// <param name="restQuery">The query proxy to use in the actual context.</param>
        public SearchResultViewModel(ILog logger, IMapper mapper, IRestQuery restQuery)
        {
            this.logger    = logger;
            this.mapper    = mapper;
            this.restQuery = restQuery;

            this.Model = new SearchResultModel {
                ResultCollection = new ObservableCollection <OrganizationModel>()
            };

            PubSub <ObservableCollection <OrganizationModel> > .RegisterEvent(EventNames.SearchResultReceivedEvent, this.SearchResultReceivedEventHandler);

            PubSub <bool> .RegisterEvent(EventNames.SearchStartedEvent, this.SearchStartedEventHandler);

            PubSub <string> .RegisterEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);

            PubSub <OrganizationModel> .RegisterEvent(EventNames.OrganizationSelectedChangedEvent, this.OrganizationSelectedChangedEventHandler);

            PubSub <SearchResultModel> .RegisterEvent(EventNames.OrganizationSelectedAllChangedEvent, this.OrganizationSelectedAllChangedEventHandler);

            this.GetContactsCommand = new RelayCommand <OrganizationModel>(this.GetContactsCommandHandler);
            this.CopyToClipboardPlainTextCommand   = new RelayCommand(this.CopyToClipboardPlainTextHandler);
            this.CopyToClipboardExcelFormatCommand = new RelayCommand(this.CopyToClipboardExcelFormatHandler);
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the RolesSearchResultViewModel class.
        /// </summary>
        /// <param name="logger">The logger to be used by the instance.</param>
        /// <param name="mapper">The AutoMapper instance to use by the view model.</param>
        /// <param name="restQuery">The query proxy to use in the actual context.</param>
        public RolesSearchResultViewModel(ILog logger, IMapper mapper, IRestQuery restQuery)
        {
            this.logger    = logger;
            this.mapper    = mapper;
            this.restQuery = restQuery;

            this.Model = new RolesSearchResultModel {
                ResultCollection = new ObservableCollection <RoleModel>()
            };
            this.Model.RolesSelectAllChecked = false;

            PubSub <ObservableCollection <RoleModel> > .RegisterEvent(EventNames.RoleSearchResultReceivedEvent, this.RoleSearchResultReceivedEventHandler);

            PubSub <bool> .RegisterEvent(EventNames.RoleSearchStartedEvent, this.RoleSearchStartedEventHandler);

            PubSub <string> .RegisterEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);

            PubSub <RoleModel> .RegisterEvent(EventNames.RoleSelectedChangedEvent, this.RoleSelectedChangedEventHandler);

            PubSub <RolesSearchResultModel> .RegisterEvent(EventNames.RoleSelectedAllChangedEvent, this.RoleSelectedAllChangedEventHandler);

            this.CopyToClipboardPlainTextCommand   = new RelayCommand(this.CopyRolesToClipboardPlainTextHandler);
            this.CopyToClipboardExcelFormatCommand = new RelayCommand(this.CopyRolesToClipboardExcelFormatHandler);
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            PubSub <string> .RegisterEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);

            this.ClosingWindowCommand = new RelayCommand <CancelEventArgs>(this.ClosingWindowCommandHandler);
        }
示例#9
0
 public MyGridViewModel()
 {
     PubSub <object> .RegisterEvent("TBPresses", ToggledHandler);
 }