public DefaultVisualStudioDocumentTrackerTest() { RazorCoreContentType = Mock.Of <IContentType>(c => c.IsOfType(RazorLanguage.ContentType) == true); TextBuffer = Mock.Of <ITextBuffer>(b => b.ContentType == RazorCoreContentType); FilePath = TestProjectData.SomeProjectFile1.FilePath; ProjectPath = TestProjectData.SomeProject.FilePath; ImportDocumentManager = Mock.Of <ImportDocumentManager>(); WorkspaceEditorSettings = new DefaultWorkspaceEditorSettings(Mock.Of <ForegroundDispatcher>(), Mock.Of <EditorSettingsManager>()); SomeTagHelpers = new List <TagHelperDescriptor>() { TagHelperDescriptorBuilder.Create("test", "test").Build(), }; ProjectManager = new TestProjectSnapshotManager(Dispatcher, Workspace) { AllowNotifyListeners = true }; HostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_1); UpdatedHostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_0); OtherHostProject = new HostProject(TestProjectData.AnotherProject.FilePath, FallbackRazorConfiguration.MVC_2_0); DocumentTracker = new DefaultVisualStudioDocumentTracker( Dispatcher, FilePath, ProjectPath, ProjectManager, WorkspaceEditorSettings, Workspace, TextBuffer, ImportDocumentManager); }
public void InitialSettingsAreEditorSettingsManagerDefault() { // Arrange var editorSettings = new EditorSettings(true, 123); var editorSettingsManager = Mock.Of <EditorSettingsManager>(m => m.Current == editorSettings, MockBehavior.Strict); // Act var manager = new DefaultWorkspaceEditorSettings(Dispatcher, editorSettingsManager); // Assert Assert.Equal(editorSettings, manager.Current); }
public DefaultVisualStudioDocumentTrackerTest() { RazorCoreContentType = Mock.Of <IContentType>(c => c.IsOfType(RazorLanguage.ContentType) == true); TextBuffer = Mock.Of <ITextBuffer>(b => b.ContentType == RazorCoreContentType); FilePath = "C:/Some/Path/TestDocumentTracker.cshtml"; ProjectPath = "C:/Some/Path/TestProject.csproj"; ImportDocumentManager = Mock.Of <ImportDocumentManager>(); WorkspaceEditorSettings = new DefaultWorkspaceEditorSettings(Mock.Of <ForegroundDispatcher>(), Mock.Of <EditorSettingsManager>()); TagHelperResolver = new TestTagHelperResolver(); SomeTagHelpers = new List <TagHelperDescriptor>() { TagHelperDescriptorBuilder.Create("test", "test").Build(), }; HostServices = TestServices.Create( new IWorkspaceService[] { }, new ILanguageService[] { TagHelperResolver, }); Workspace = TestWorkspace.Create(HostServices, w => { WorkspaceProject = w.AddProject(ProjectInfo.Create( ProjectId.CreateNewId(), new VersionStamp(), "Test1", "TestAssembly", LanguageNames.CSharp, filePath: ProjectPath)); }); ProjectManager = new TestProjectSnapshotManager(Dispatcher, Workspace) { AllowNotifyListeners = true }; HostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_1); OtherHostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_0); DocumentTracker = new DefaultVisualStudioDocumentTracker( Dispatcher, FilePath, ProjectPath, ProjectManager, WorkspaceEditorSettings, Workspace, TextBuffer, ImportDocumentManager); }
public void OnChanged_TriggersChanged() { // Arrange var editorSettingsManager = new Mock <EditorSettingsManager>(MockBehavior.Strict); editorSettingsManager.SetupGet(m => m.Current).Returns((EditorSettings)null); var manager = new DefaultWorkspaceEditorSettings(Dispatcher, editorSettingsManager.Object); var called = false; manager.Changed += (caller, args) => called = true; // Act manager.OnChanged(null, null); // Assert Assert.True(called); }
public void OnChanged_TriggersChanged() { // Arrange var manager = new DefaultWorkspaceEditorSettings(Dispatcher, Mock.Of <EditorSettingsManager>()); var called = false; manager.Changed += (caller, args) => { called = true; }; // Act manager.OnChanged(null, null); // Assert Assert.True(called); }
public DefaultVisualStudioDocumentTrackerTest() { RazorCoreContentType = Mock.Of <IContentType>(c => c.IsOfType(RazorLanguage.ContentType) && c.IsOfType(RazorConstants.LegacyContentType), MockBehavior.Strict); TextBuffer = Mock.Of <ITextBuffer>(b => b.ContentType == RazorCoreContentType, MockBehavior.Strict); FilePath = TestProjectData.SomeProjectFile1.FilePath; ProjectPath = TestProjectData.SomeProject.FilePath; RootNamespace = TestProjectData.SomeProject.RootNamespace; ImportDocumentManager = new Mock <ImportDocumentManager>(MockBehavior.Strict).Object; Mock.Get(ImportDocumentManager).Setup(m => m.OnSubscribed(It.IsAny <VisualStudioDocumentTracker>())).Verifiable(); Mock.Get(ImportDocumentManager).Setup(m => m.OnUnsubscribed(It.IsAny <VisualStudioDocumentTracker>())).Verifiable(); var projectSnapshotManagerDispatcher = new Mock <ProjectSnapshotManagerDispatcher>(MockBehavior.Strict); projectSnapshotManagerDispatcher.Setup(d => d.AssertDispatcherThread(It.IsAny <string>())).Verifiable(); WorkspaceEditorSettings = new DefaultWorkspaceEditorSettings(projectSnapshotManagerDispatcher.Object, Mock.Of <EditorSettingsManager>(MockBehavior.Strict)); SomeTagHelpers = new List <TagHelperDescriptor>() { TagHelperDescriptorBuilder.Create("test", "test").Build(), }; ProjectManager = new TestProjectSnapshotManager(Dispatcher, Workspace) { AllowNotifyListeners = true }; HostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_1, RootNamespace); UpdatedHostProject = new HostProject(ProjectPath, FallbackRazorConfiguration.MVC_2_0, RootNamespace); OtherHostProject = new HostProject(TestProjectData.AnotherProject.FilePath, FallbackRazorConfiguration.MVC_2_0, TestProjectData.AnotherProject.RootNamespace); DocumentTracker = new DefaultVisualStudioDocumentTracker( Dispatcher, JoinableTaskFactory.Context, FilePath, ProjectPath, ProjectManager, WorkspaceEditorSettings, Workspace, TextBuffer, ImportDocumentManager); }