コード例 #1
0
        public void ControlNeedsViewModel()
        {
            var solutionComponentsContainer = new SolutionComponentsContainer();
            var ex = Record.Exception(() => solutionComponentsContainer.InitializeBindings(null));

            Assert.NotNull(ex);
            Assert.IsType <ArgumentNullException>(ex);
            Assert.Equal("Value cannot be null.\r\nParameter name: toolViewModel", ex.Message);
        }
コード例 #2
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);
        }
コード例 #3
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);
 }
コード例 #4
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);
        }