private void RefreshCompilationOfSourceFilesInWorkspace(string bicepFileContents, string bicepConfigFileContents, bool saveBicepConfigFile, out Mock <ITextDocumentLanguageServer> document, out Container <Diagnostic>?diagnostics)
        {
            PublishDiagnosticsParams?receivedParams = null;

            document = BicepCompilationManagerHelper.CreateMockDocument(p => receivedParams = p);
            ILanguageServerFacade server = BicepCompilationManagerHelper.CreateMockServer(document).Object;

            string testOutputPath = Path.Combine(TestContext.ResultsDirectory, Guid.NewGuid().ToString());

            var bicepFilePath = FileHelper.SaveResultFile(TestContext, "input.bicep", bicepFileContents, testOutputPath);
            var workspace     = new Workspace();

            var bicepCompilationManager = new BicepCompilationManager(server, BicepCompilationManagerHelper.CreateEmptyCompilationProvider(), workspace, new FileResolver(), BicepCompilationManagerHelper.CreateMockScheduler().Object, new ConfigurationManager(new IOFileSystem()));

            bicepCompilationManager.UpsertCompilation(DocumentUri.From(bicepFilePath), null, bicepFileContents, LanguageConstants.LanguageId);

            var bicepConfigDocumentUri = DocumentUri.FromFileSystemPath(bicepFilePath);

            if (saveBicepConfigFile)
            {
                string bicepConfigFilePath = FileHelper.SaveResultFile(TestContext, "bicepconfig.json", bicepConfigFileContents, testOutputPath);
                bicepConfigDocumentUri = DocumentUri.FromFileSystemPath(bicepConfigFilePath);
            }

            BicepConfigChangeHandler.RefreshCompilationOfSourceFilesInWorkspace(bicepCompilationManager, workspace);

            diagnostics = receivedParams?.Diagnostics;
        }
        public async Task Handle_WithValidInput_VerifyNoEntryInDeploymentFileCompilationCache()
        {
            var bicepFileContents       = @"param name string = 'test'
param location string = 'global
resource dnsZone 'Microsoft.Network/dnsZones@2018-05-01' = {
  name: name
  location: location
}";
            var template                = @"{
  ""$schema"": ""https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"",
  ""contentVersion"": ""1.0.0.0"",
  ""metadata"": {
    ""_generator"": {
      ""name"": ""bicep"",
      ""version"": ""0.6.18.56646"",
      ""templateHash"": ""3422964353444461889""
    }
  },
  ""parameters"": {
    ""name"": {
      ""type"": ""string"",
      ""defaultValue"": ""test""
    },
    ""location"": {
      ""type"": ""string"",
      ""defaultValue"": ""global""
    }
  },
  ""resources"": [
    {
      ""type"": ""Microsoft.Network/dnsZones"",
      ""apiVersion"": ""2018-05-01"",
      ""name"": ""[parameters('name')]"",
      ""location"": ""[parameters('location')]""
    }
  ]
}";
            var bicepFilePath           = FileHelper.SaveResultFile(TestContext, "input.bicep", bicepFileContents);
            var documentUri             = DocumentUri.FromFileSystemPath(bicepFilePath);
            var bicepCompilationManager = BicepCompilationManagerHelper.CreateCompilationManager(documentUri, bicepFileContents, true);
            var compilation             = bicepCompilationManager.GetCompilation(documentUri) !.Compilation;

            DeploymentFileCompilationCache.CacheCompilation(documentUri, compilation);
            var bicepDeploymentParametersHandler = new BicepDeploymentParametersHandler(DeploymentFileCompilationCache, Serializer);

            await bicepDeploymentParametersHandler.Handle(bicepFilePath, string.Empty, template, CancellationToken.None);

            Assert.IsNull(DeploymentFileCompilationCache.FindAndRemoveCompilation(documentUri));
        }