public void ProjectConfigurationFileChanged_Changed_CantDeserialize_ResetsProject()
        {
            // Arrange
            var initialHandle = new FullProjectSnapshotHandle(
                "path/to/project.csproj",
                RazorConfiguration.Default,
                rootNamespace: "TestRootNamespace",
                new ProjectWorkspaceState(Array.Empty <TagHelperDescriptor>(), LanguageVersion.CSharp5),
                Array.Empty <DocumentSnapshotHandle>());
            var projectService = new Mock <RazorProjectService>(MockBehavior.Strict);

            projectService.Setup(service => service.AddProject(initialHandle.FilePath)).Verifiable();
            projectService.Setup(service => service.UpdateProject(
                                     initialHandle.FilePath,
                                     initialHandle.Configuration,
                                     initialHandle.RootNamespace,
                                     initialHandle.ProjectWorkspaceState,
                                     initialHandle.Documents)).Verifiable();
            var changedHandle = new FullProjectSnapshotHandle(
                "path/to/project.csproj",
                RazorConfiguration.Create(
                    RazorLanguageVersion.Experimental,
                    "TestConfiguration",
                    Array.Empty <RazorExtension>()),
                rootNamespace: "TestRootNamespace2",
                new ProjectWorkspaceState(Array.Empty <TagHelperDescriptor>(), LanguageVersion.CSharp6),
                Array.Empty <DocumentSnapshotHandle>());

            // This is the request that happens when the server is reset
            projectService.Setup(service => service.UpdateProject(
                                     initialHandle.FilePath,
                                     null,
                                     null,
                                     ProjectWorkspaceState.Default,
                                     Array.Empty <DocumentSnapshotHandle>())).Verifiable();
            var synchronizer    = new ProjectConfigurationStateSynchronizer(Dispatcher, projectService.Object, FilePathNormalizer);
            var addDeserializer = CreateJsonFileDeserializer(initialHandle);
            var addArgs         = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Added, addDeserializer);

            synchronizer.ProjectConfigurationFileChanged(addArgs);
            var changedDeserializer = Mock.Of <JsonFileDeserializer>();
            var changedArgs         = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Changed, changedDeserializer);

            // Act
            synchronizer.ProjectConfigurationFileChanged(changedArgs);

            // Assert
            projectService.VerifyAll();
        }
        public void ProjectConfigurationFileChanged_Added_AddAndUpdatesProject()
        {
            // Arrange
            var handle = new FullProjectSnapshotHandle(
                "path/to/project.csproj",
                RazorConfiguration.Default,
                rootNamespace: "TestRootNamespace",
                new ProjectWorkspaceState(Array.Empty <TagHelperDescriptor>(), LanguageVersion.CSharp5),
                Array.Empty <DocumentSnapshotHandle>());
            var projectService = new Mock <RazorProjectService>(MockBehavior.Strict);

            projectService.Setup(service => service.AddProject(handle.FilePath)).Verifiable();
            projectService.Setup(service => service.UpdateProject(
                                     handle.FilePath,
                                     handle.Configuration,
                                     handle.RootNamespace,
                                     handle.ProjectWorkspaceState,
                                     handle.Documents)).Verifiable();
            var synchronizer         = new ProjectConfigurationStateSynchronizer(Dispatcher, projectService.Object, FilePathNormalizer);
            var jsonFileDeserializer = CreateJsonFileDeserializer(handle);
            var args = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);

            // Act
            synchronizer.ProjectConfigurationFileChanged(args);

            // Assert
            projectService.VerifyAll();
        }
        public void ProjectConfigurationFileChanged_Added_CantDeserialize_Noops()
        {
            // Arrange
            var projectService       = new Mock <RazorProjectService>(MockBehavior.Strict);
            var synchronizer         = new ProjectConfigurationStateSynchronizer(Dispatcher, projectService.Object, FilePathNormalizer);
            var jsonFileDeserializer = Mock.Of <JsonFileDeserializer>();
            var args = new ProjectConfigurationFileChangeEventArgs("/path/to/project.razor.json", RazorFileChangeKind.Added, jsonFileDeserializer);

            // Act
            synchronizer.ProjectConfigurationFileChanged(args);

            // Assert
            projectService.VerifyAll();
        }