Headless.IntegrationTests.FormTests.FilesOnDynamicPageTest C# (CSharp) Method

FilesOnDynamicPageTest() private method

private FilesOnDynamicPageTest ( ) : void
return void
        public void FilesOnDynamicPageTest()
        {
            var firstFileName = Guid.NewGuid().ToString("N") + ".txt";
            var firstFile = Path.Combine(Path.GetTempPath(), firstFileName);
            var firstFileContent = Guid.NewGuid().ToString();
            var secondFileName = Guid.NewGuid().ToString("N") + ".txt";
            var secondFile = Path.Combine(Path.GetTempPath(), secondFileName);
            var secondFileContent = Guid.NewGuid().ToString();

            try
            {
                File.WriteAllText(firstFile, firstFileContent);
                File.WriteAllText(secondFile, secondFileContent);

                using (var browser = new Browser())
                {
                    var textValue = Guid.NewGuid().ToString();

                    var page = browser.GoTo(Form.Files);

                    ((IPage)page).Result.TraceResults();

                    page.SomeData.Value = textValue;
                    page.files1.Value = firstFile;
                    page.files2.Value = secondFile;

                    var postedPage = page.Submit.Click();

                    ((IPage)postedPage).Result.TraceResults();

                    ((string)postedPage.SomeData.Value).Should().Be(textValue);
                    ((string)postedPage.FileCount.Text).Should().Be("2");

                    var firstFileCells =
                        ((IHtmlElementFinder<HtmlTableRow>)postedPage.Find<HtmlTableRow>()).ByPredicate(
                            x => x.Html.Contains(firstFileName)).Cells.ToList();

                    firstFileCells[0].Text.Should().Be(firstFileName);
                    firstFileCells[1].Text.Should().Be("text/plain");
                    firstFileCells[2].Text.Should().Be(firstFileContent);

                    var secondFileCells =
                        ((IHtmlElementFinder<HtmlTableRow>)postedPage.Find<HtmlTableRow>()).ByPredicate(
                            x => x.Html.Contains(secondFileName)).Cells.ToList();

                    secondFileCells[0].Text.Should().Be(secondFileName);
                    secondFileCells[1].Text.Should().Be("text/plain");
                    secondFileCells[2].Text.Should().Be(secondFileContent);
                }
            }
            finally
            {
                File.Delete(firstFile);
                File.Delete(secondFile);
            }
        }