public void Restore_counter_http_web_app_on_server_restart() { using (var testSetup = WebHostAdminInterfaceTestSetup.Setup(deployAppConfigAndInitElmState: CounterWebApp)) { var eventsAndExpectedResponses = TestSetup.CounterProcessTestEventsAndExpectedResponses( new (int addition, int expectedResponse)[]
static public WebHostAdminInterfaceTestSetup Setup( Func <IWebHostBuilder, IWebHostBuilder> webHostBuilderMap, string adminPassword = null, Composition.Component deployAppConfigAndInitElmState = null, string adminWebHostUrlOverride = null, string publicWebHostUrlOverride = null) { var testDirectory = Filesystem.CreateRandomDirectoryInTempDirectory(); var setup = new WebHostAdminInterfaceTestSetup( testDirectory, adminPassword: adminPassword, deployAppConfigAndInitElmState: deployAppConfigAndInitElmState, webHostBuilderMap: webHostBuilderMap, adminWebHostUrlOverride: adminWebHostUrlOverride, publicWebHostUrlOverride: publicWebHostUrlOverride); return(setup); }
public void Elm_editor_backend_support_format_elm_module_text() { var webAppSource = TestSetup.AppConfigComponentFromFiles( TestSetup.GetElmAppFromDirectoryPath( ImmutableList.Create(".", "..", "..", "..", "..", "example-apps", "elm-editor"))); var elmModuleTextBeforeFormatting = @" module Common exposing (..) a = let b = 1 c = 2 in b + c "; var expectedElmModuleTextAfterFormatting = @" module Common exposing (..) a = let b = 1 c = 2 in b + c "; using var testSetup = WebHostAdminInterfaceTestSetup.Setup(deployAppConfigAndInitElmState: webAppSource); using var server = testSetup.StartWebHost(); using var publicAppClient = testSetup.BuildPublicAppHttpClient(); var formatRequest = new ElmEditorApi.ElmEditorApiRequestStructure ( FormatElmModuleTextRequest: ImmutableList.Create(elmModuleTextBeforeFormatting) ); var httpResponse = publicAppClient .PostAsync("/api", new StringContent(JsonSerializer.Serialize(formatRequest))).Result; var responseContentAsString = httpResponse.Content.ReadAsStringAsync().Result; Assert.AreEqual( HttpStatusCode.OK, httpResponse.StatusCode, "Response status code should be OK.\nresponseContentAsString:\n" + responseContentAsString); var responseStructure = JsonSerializer.Deserialize <ElmEditorApi.ElmEditorApiResponseStructure>(responseContentAsString) !; Assert.IsNull( responseStructure.ErrorResponse, "responseStructure.ErrorResponse should be null.\n" + responseStructure.ErrorResponse); Assert.AreEqual( NormalizeStringTestingElmFormat(expectedElmModuleTextAfterFormatting), NormalizeStringTestingElmFormat(responseStructure ?.FormatElmModuleTextResponse?.FirstOrDefault() ?.formattedText.Just?.FirstOrDefault()), "Response content"); }