public async Task Handle_ConfigurationFilePath_TrackedMonitor_StopsMonitor() { // Arrange var detector = new TestFileChangeDetector(); var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detector, Dispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>()); var startRequest = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:/dir/project.csproj", ConfigurationFilePath = "C:/externaldir/obj/Debug/project.razor.json", }; await configurationFileEndpoint.Handle(startRequest, CancellationToken.None); var stopRequest = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:/dir/project.csproj", ConfigurationFilePath = null, }; // Act await configurationFileEndpoint.Handle(stopRequest, CancellationToken.None); // Assert Assert.Equal(1, detector.StartCount); Assert.Equal(1, detector.StopCount); }
public async Task Handle_ChangedConfigurationExternalToInternal_StopsWithoutRestarting() { // Arrange var detector = new TestFileChangeDetector(); var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detector, Dispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>()); var externalRequest = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:\\dir\\project.csproj", ConfigurationFilePath = "C:\\externaldir\\obj\\Debug\\project.razor.json", }; var internalRequest = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = externalRequest.ProjectFilePath, ConfigurationFilePath = "C:\\dir\\obj\\Release\\project.razor.json", }; // Act await configurationFileEndpoint.Handle(externalRequest, CancellationToken.None); await configurationFileEndpoint.Handle(internalRequest, CancellationToken.None); // Assert Assert.Equal(new[] { "C:\\externaldir\\obj\\Debug" }, detector.StartedWithDirectory); Assert.Equal(1, detector.StopCount); }
public async Task Handle_ChangedConfigurationOutputPath_StartsWithNewPath() { // Arrange var detector = new TestFileChangeDetector(); var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detector, LegacyDispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>()); var debugOutputPath = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:\\dir\\project.csproj", ConfigurationFilePath = "C:\\externaldir\\obj\\Debug\\project.razor.json", }; var releaseOutputPath = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = debugOutputPath.ProjectFilePath, ConfigurationFilePath = "C:\\externaldir\\obj\\Release\\project.razor.json", }; // Act await configurationFileEndpoint.Handle(debugOutputPath, CancellationToken.None); await configurationFileEndpoint.Handle(releaseOutputPath, CancellationToken.None); // Assert Assert.Equal(new[] { "C:\\externaldir\\obj\\Debug", "C:\\externaldir\\obj\\Release" }, detector.StartedWithDirectory); Assert.Equal(1, detector.StopCount); }
public async Task Handle_MultipleProjects_StartedAndStopped() { // Arrange var callCount = 0; var debug1Detector = new TestFileChangeDetector(); var debug2Detector = new TestFileChangeDetector(); var release1Detector = new TestFileChangeDetector(); var detectors = new[] { debug1Detector, debug2Detector, release1Detector }; var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detectors[callCount++], LegacyDispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>(), LoggerFactory); var debugOutputPath1 = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:\\dir\\project1.csproj", ConfigurationFilePath = "C:\\externaldir1\\obj\\Debug\\project.razor.json", }; var releaseOutputPath1 = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = debugOutputPath1.ProjectFilePath, ConfigurationFilePath = "C:\\externaldir1\\obj\\Release\\project.razor.json", }; var debugOutputPath2 = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:\\dir\\project2.csproj", ConfigurationFilePath = "C:\\externaldir2\\obj\\Debug\\project.razor.json", }; // Act await configurationFileEndpoint.Handle(debugOutputPath1, CancellationToken.None); await configurationFileEndpoint.Handle(debugOutputPath2, CancellationToken.None); await configurationFileEndpoint.Handle(releaseOutputPath1, CancellationToken.None); // Assert Assert.Equal(1, debug1Detector.StartCount); Assert.Equal(1, debug1Detector.StopCount); Assert.Equal(1, debug2Detector.StartCount); Assert.Equal(0, debug2Detector.StopCount); Assert.Equal(1, release1Detector.StartCount); Assert.Equal(0, release1Detector.StopCount); }
public async Task Handle_ProjectPublished() { // Arrange var callCount = 0; var projectOpenDebugDetector = new TestFileChangeDetector(); var releaseDetector = new TestFileChangeDetector(); var postPublishDebugDetector = new TestFileChangeDetector(); var detectors = new[] { projectOpenDebugDetector, releaseDetector, postPublishDebugDetector }; var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detectors[callCount++], LegacyDispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>(), LoggerFactory); var debugOutputPath = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:\\dir\\project1.csproj", ConfigurationFilePath = "C:\\externaldir1\\obj\\Debug\\project.razor.json", }; var releaseOutputPath = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = debugOutputPath.ProjectFilePath, ConfigurationFilePath = "C:\\externaldir1\\obj\\Release\\project.razor.json", }; // Act // Project opened, defaults to Debug output path await configurationFileEndpoint.Handle(debugOutputPath, CancellationToken.None); // Project published (temporarily moves to release output path) await configurationFileEndpoint.Handle(releaseOutputPath, CancellationToken.None); // Project publish finished (moves back to debug output path) await configurationFileEndpoint.Handle(debugOutputPath, CancellationToken.None); // Assert Assert.Equal(1, projectOpenDebugDetector.StartCount); Assert.Equal(1, projectOpenDebugDetector.StopCount); Assert.Equal(1, releaseDetector.StartCount); Assert.Equal(1, releaseDetector.StopCount); Assert.Equal(1, postPublishDebugDetector.StartCount); Assert.Equal(0, postPublishDebugDetector.StopCount); }
public async Task Handle_InWorkspaceDirectory_Noops() { // Arrange var detector = new TestFileChangeDetector(); var configurationFileEndpoint = new TestMonitorProjectConfigurationFilePathEndpoint( () => detector, LegacyDispatcher, FilePathNormalizer, DirectoryPathResolver, Enumerable.Empty <IProjectConfigurationFileChangeListener>(), LoggerFactory); var startRequest = new MonitorProjectConfigurationFilePathParams() { ProjectFilePath = "C:/dir/project.csproj", ConfigurationFilePath = "C:/dir/obj/Debug/project.razor.json", }; // Act await configurationFileEndpoint.Handle(startRequest, CancellationToken.None); // Assert Assert.Equal(0, detector.StartCount); }