public static IWorkspaceProjectContextProvider ImplementCreateProjectContextAsync(IWorkspaceProjectContext context)
        {
            var mock = new WorkspaceProjectContextProviderMock();

            mock.ImplementCreateProjectContextAsync(project => context);

            return(mock.Object);
        }
Ejemplo n.º 2
0
        public async Task InitializedAsync_WhenInitializedWithContext_RegistersContextWithTracker()
        {
            string contextIdResult = null;
            var    activeWorkspaceProjectContextTracker = IActiveEditorContextTrackerFactory.ImplementRegisterContext(id => { contextIdResult = id; });

            var context  = IWorkspaceProjectContextMockFactory.Create();
            var accessor = IWorkspaceProjectContextAccessorFactory.ImplementContext(context, "ContextId");
            var provider = new WorkspaceProjectContextProviderMock();

            provider.ImplementCreateProjectContextAsync(project => accessor);

            var instance = await CreateInitializedInstanceAsync(workspaceProjectContextProvider : provider.Object, activeWorkspaceProjectContextTracker : activeWorkspaceProjectContextTracker);

            Assert.Equal("ContextId", contextIdResult);
        }
Ejemplo n.º 3
0
        public async Task Dispose_WhenInitializedWithContext_ReleasesContext()
        {
            var accessor = IWorkspaceProjectContextAccessorFactory.Create();

            IWorkspaceProjectContextAccessor result = null;
            var provider = new WorkspaceProjectContextProviderMock();

            provider.ImplementCreateProjectContextAsync(project => accessor);
            provider.ImplementReleaseProjectContextAsync(a => { result = a; });

            var instance = await CreateInitializedInstanceAsync(workspaceProjectContextProvider : provider.Object);

            await instance.DisposeAsync();

            Assert.Same(accessor, result);
        }
Ejemplo n.º 4
0
        public async Task Dispose_WhenInitializedWithContext_UnregistersContextWithTracker()
        {
            IWorkspaceProjectContext result          = null;
            var activeWorkspaceProjectContextTracker = IActiveEditorContextTrackerFactory.ImplementReleaseContext(c => { result = c; });

            var context  = IWorkspaceProjectContextMockFactory.Create();
            var accessor = IWorkspaceProjectContextAccessorFactory.ImplementContext(context);
            var provider = new WorkspaceProjectContextProviderMock();

            provider.ImplementCreateProjectContextAsync(project => accessor);

            var instance = await CreateInitializedInstanceAsync(workspaceProjectContextProvider : provider.Object, activeWorkspaceProjectContextTracker : activeWorkspaceProjectContextTracker);

            await instance.DisposeAsync();

            Assert.Same(context, result);
        }