Esempio n. 1
0
        public void SolutionLoadedInHost_WhenProjectUnloaded_ReturnsCancelledTask()
        {
            var tasksService = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(new CancellationToken(true));
            var service      = CreateInstance(tasksService);

            var result = service.SolutionLoadedInHost;

            Assert.True(result.IsCanceled);
        }
        public void GetProjectGuidAsync_WhenProjectAlreadyUnloaded_ReturnsCancelledTask()
        {
            var tasksService  = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(new CancellationToken(canceled: true));
            var loadDashboard = IProjectAsyncLoadDashboardFactory.ImplementProjectLoadedInHost(() => Task.Delay(Timeout.Infinite));

            var accessor = CreateInstance(tasksService, loadDashboard);

            var result = accessor.GetProjectGuidAsync();

            Assert.True(result.IsCanceled);
        }
Esempio n. 3
0
        public void UnloadCancellationToken_WhenUnderlyingUnloadCancellationTokenCancelled_IsCancelled()
        {
            var source       = new CancellationTokenSource();
            var tasksService = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(source.Token);
            var service      = CreateInstance(tasksService);

            Assert.False(service.UnloadCancellationToken.IsCancellationRequested);

            source.Cancel();

            Assert.True(service.UnloadCancellationToken.IsCancellationRequested);
        }
        public async Task GetProjectGuidAsync_WhenProjectUnloads_CancelsTask()
        {
            var projectUnloaded = new CancellationTokenSource();
            var tasksService    = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(projectUnloaded.Token);
            var loadDashboard   = IProjectAsyncLoadDashboardFactory.ImplementProjectLoadedInHost(() => Task.Delay(Timeout.Infinite));

            var accessor = CreateInstance(tasksService, loadDashboard);

            var result = accessor.GetProjectGuidAsync();

            Assert.False(result.IsCanceled);

            // Now "unload" the project
            projectUnloaded.Cancel();

            await Assert.ThrowsAsync <OperationCanceledException>(() =>
            {
                return(result);
            });
        }