Exemplo n.º 1
0
        public void RefreshSolutionListUsesService()
        {
            var iWorkerHostWrapper = A.Fake <IWorkerHostWrapper>();

            var solutionComponentsContainer = new SolutionComponentsContainer();
            var toolViewModel = new ToolViewModel {
                OrganizationService = _service
            };

            toolViewModel.AsyncWorkQueue = new AsyncWorkQueue(iWorkerHostWrapper, toolViewModel);
            solutionComponentsContainer.InitializeBindings(toolViewModel);
            var doWorkEventArgs = new DoWorkEventArgs(null);

            solutionComponentsContainer.RefreshSolutionList(A.Fake <BackgroundWorker>(), doWorkEventArgs);

            A.CallTo(() => _service.RetrieveMultiple(A <QueryExpression> .Ignored)).MustHaveHappened(1, Times.Exactly);
        }
Exemplo n.º 2
0
 public void InitializeBindings(ToolViewModel toolViewModel)
 {
     if (toolViewModel == null)
     {
         throw new ArgumentNullException(nameof(toolViewModel));
     }
     this.Bind(
         t => t.AsyncWorkQueue,
         toolViewModel,
         s => s.AsyncWorkQueue);
     this.Bind(
         t => t.MessageBroker,
         toolViewModel,
         s => s.MessageBroker);
     this.Bind(
         t => t.OrganizationService,
         toolViewModel,
         s => s.OrganizationService);
     solutionComponentsContainer.InitializeBindings(toolViewModel);
     prototypesContainer.InitializeBindings(toolViewModel);
 }
Exemplo n.º 3
0
        public void MnuRefreshSolutionsUsesService()
        {
            _context.Initialize(new Solution[] { new Solution()
                                                 {
                                                     SolutionId   = Guid.NewGuid(),
                                                     FriendlyName = "Active Solution",
                                                     UniqueName   = "Active"
                                                 }, new Solution()
                                                 {
                                                     SolutionId   = Guid.NewGuid(),
                                                     FriendlyName = "Default Solution",
                                                     UniqueName   = "Default"
                                                 } });

            var iWorkerHostWrapper = new DummyBackgroundWorkerHostWrapper();

            var solutionComponentsContainer = new SolutionComponentsContainer();
            var toolViewModel = new ToolViewModel {
                OrganizationService = _service
            };

            toolViewModel.AsyncWorkQueue = new AsyncWorkQueue(iWorkerHostWrapper, toolViewModel);
            solutionComponentsContainer.InitializeBindings(toolViewModel);

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            solutionComponentsContainer.MnuRefreshSolutions_Click(null, new EventArgs());

            while (iWorkerHostWrapper.Working > 0 && stopwatch.ElapsedMilliseconds < 10000) //10 seconds threshold for the asynchronous operation
            {
                Thread.Sleep(15);
            }


            Assert.Equal("Default", (solutionComponentsContainer.cmbFilteringSolution.SelectedItem as Solution)?.UniqueName);
        }
 public AsyncWorkQueue(IWorkerHostWrapper solutionPackagerControl, ToolViewModel toolViewModel)
 {
     this.queue = new Queue <Job>();
     this.solutionPackagerControl = solutionPackagerControl;
     this.toolViewModel           = toolViewModel;
 }