Exemplo n.º 1
0
        public async Task GetHostStatus_TestFunctionAppContentEditable(bool isFileSystemReadOnly, bool azureFilesAppSettingsExist, FunctionAppContentEditingState isFunctionAppContentEditable, bool isLinuxConsumption = true)
        {
            _mockScriptHostManager.SetupGet(p => p.LastError).Returns((Exception)null);
            var mockHostIdProvider = new Mock <IHostIdProvider>(MockBehavior.Strict);

            mockHostIdProvider.Setup(p => p.GetHostIdAsync(CancellationToken.None)).ReturnsAsync("test123");
            var mockserviceProvider = new Mock <IServiceProvider>(MockBehavior.Strict);

            mockserviceProvider.Setup(p => p.GetService(typeof(IExtensionBundleManager))).Returns(null);

            if (isLinuxConsumption)
            {
                _mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.ContainerName)).Returns("test-container");
            }

            _applicationHostOptions.IsFileSystemReadOnly = isFileSystemReadOnly;
            if (azureFilesAppSettingsExist)
            {
                _mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.AzureFilesConnectionString)).Returns("test value");
                _mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.AzureFilesContentShare)).Returns("test value");
            }

            var result = (OkObjectResult)(await _hostController.GetHostStatus(_mockScriptHostManager.Object, mockHostIdProvider.Object, mockserviceProvider.Object));
            var status = (HostStatus)result.Value;

            Assert.Equal(status.FunctionAppContentEditingState, isFunctionAppContentEditable);
        }