Exemple #1
0
        public void ProjectSnapshotManager_WorkspacePopulated_SetsUIContext()
        {
            // Arrange
            var responseRouterReturns = new Mock <IResponseRouterReturns>(MockBehavior.Strict);

            responseRouterReturns.Setup(r => r.ReturningVoid(It.IsAny <CancellationToken>()))
            .Returns(() => Task.CompletedTask);

            var clientNotifierService = new Mock <ClientNotifierServiceBase>(MockBehavior.Strict);

            clientNotifierService.Setup(l => l.SendRequestAsync(_razorServerReadyEndpoint))
            .Returns(Task.FromResult(responseRouterReturns.Object));

            var razorServerReadyPublisher = new RazorServerReadyPublisher(Dispatcher, clientNotifierService.Object);

            var projectManager = TestProjectSnapshotManager.Create(Dispatcher);

            projectManager.AllowNotifyListeners = true;

            razorServerReadyPublisher.Initialize(projectManager);

            var document = TestDocumentSnapshot.Create("C:/file.cshtml");

            document.TryGetText(out var text);
            document.TryGetTextVersion(out var textVersion);
            var textAndVersion = TextAndVersion.Create(text, textVersion);

            // Act
            projectManager.ProjectAdded(document.ProjectInternal.HostProject);
            projectManager.ProjectWorkspaceStateChanged(document.ProjectInternal.HostProject.FilePath, CreateProjectWorkspace());

            // Assert
            clientNotifierService.VerifyAll();
            responseRouterReturns.VerifyAll();
        }
Exemple #2
0
        public void ProjectSnapshotManager_WorkspaceNull_DoesNothing()
        {
            // Arrange
            var clientNotifierService = new Mock <ClientNotifierServiceBase>(MockBehavior.Strict);

            var razorServerReadyPublisher = new RazorServerReadyPublisher(Dispatcher, clientNotifierService.Object);

            var projectManager = TestProjectSnapshotManager.Create(Dispatcher);

            projectManager.AllowNotifyListeners = true;

            razorServerReadyPublisher.Initialize(projectManager);

            var document = TestDocumentSnapshot.Create("C:/file.cshtml");

            document.TryGetText(out var text);
            document.TryGetTextVersion(out var textVersion);
            var textAndVersion = TextAndVersion.Create(text, textVersion);

            // Act
            projectManager.ProjectAdded(document.ProjectInternal.HostProject);
            projectManager.DocumentAdded(document.ProjectInternal.HostProject, document.State.HostDocument, TextLoader.From(textAndVersion));

            // Assert
            // Should not have been called
            clientNotifierService.Verify();
        }