Beispiel #1
0
        [InlineData(false)]     // Project Build
        public async Task OnProjectChangedAsync_PassesProjectUpdate(bool evaluation)
        {
            IProjectVersionedValue <IProjectSubscriptionUpdate> updateResult = null;

            void applyChanges(IProjectVersionedValue <IProjectSubscriptionUpdate> u, bool _, CancellationToken __)
            {
                updateResult = u;
            }

            var applyChangesToWorkspaceContext = evaluation ? IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectEvaluation(applyChanges) : IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectBuild(applyChanges);

            var instance = await CreateInitializedInstanceAsync(applyChangesToWorkspaceContext : applyChangesToWorkspaceContext);

            var update = IProjectVersionedValueFactory.CreateEmpty();
            await instance.OnProjectChangedAsync(update, evaluation);

            Assert.Same(updateResult, update);
        }
Beispiel #2
0
        public async Task OnProjectChangedAsync_RespectsIsActiveContext(bool evaluation, bool isActiveContext)
        {
            bool?isActiveContextResult = null;

            void applyChanges(IProjectVersionedValue <IProjectSubscriptionUpdate> u, bool iac, CancellationToken _)
            {
                isActiveContextResult = iac;
            }

            var activeWorkspaceProjectContextTracker = IActiveWorkspaceProjectContextTrackerFactory.ImplementIsActiveContext(context => isActiveContext);
            var applyChangesToWorkspaceContext       = evaluation ? IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectEvaluation(applyChanges) : IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectBuild(applyChanges);


            var instance = await CreateInitializedInstanceAsync(applyChangesToWorkspaceContext : applyChangesToWorkspaceContext, activeWorkspaceProjectContextTracker : activeWorkspaceProjectContextTracker);

            var update = IProjectVersionedValueFactory.CreateEmpty();
            await instance.OnProjectChangedAsync(update, evaluation);

            Assert.Equal(isActiveContext, isActiveContextResult);
        }
Beispiel #3
0
        [InlineData(false)]     // Project Build
        public async Task OnProjectChangedAsync_WhenInstanceDisposed_TriggersCancellation(bool evaluation)
        {
            WorkspaceContextHostInstance instance = null;

            void applyChanges(IProjectVersionedValue <IProjectSubscriptionUpdate> _, bool __, CancellationToken cancellationToken)
            {
                // Dispose the instance underneath us
                instance.Dispose();

                cancellationToken.ThrowIfCancellationRequested();
            }

            var applyChangesToWorkspaceContext = evaluation ? IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectEvaluation(applyChanges) : IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectBuild(applyChanges);

            instance = await CreateInitializedInstanceAsync(applyChangesToWorkspaceContext : applyChangesToWorkspaceContext);

            var update = IProjectVersionedValueFactory.CreateEmpty();
            await Assert.ThrowsAsync <OperationCanceledException>(() =>
            {
                return(instance.OnProjectChangedAsync(update, evaluation));
            });
        }
Beispiel #4
0
        [InlineData(false)]     // Project Build
        public async Task OnProjectChangedAsync_WhenProjectUnloaded_TriggersCancellation(bool evaluation)
        {
            var unloadSource = new CancellationTokenSource();
            var tasksService = IUnconfiguredProjectTasksServiceFactory.ImplementUnloadCancellationToken(unloadSource.Token);

            void applyChanges(IProjectVersionedValue <IProjectSubscriptionUpdate> _, bool __, CancellationToken cancellationToken)
            {
                // Unload project
                unloadSource.Cancel();

                cancellationToken.ThrowIfCancellationRequested();
            }

            var applyChangesToWorkspaceContext = evaluation ? IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectEvaluation(applyChanges) : IApplyChangesToWorkspaceContextFactory.ImplementApplyProjectBuild(applyChanges);

            var instance = await CreateInitializedInstanceAsync(tasksService : tasksService, applyChangesToWorkspaceContext : applyChangesToWorkspaceContext);

            var update = IProjectVersionedValueFactory.CreateEmpty();
            await Assert.ThrowsAsync <OperationCanceledException>(() =>
            {
                return(instance.OnProjectChangedAsync(update, evaluation));
            });
        }