Example #1
0
            public async Task DoesNotCloneDocumentIfNothingChanged()
            {
                // Given
                const string input =
                    @"<html>
                        <head>
                            <title>Foobar</title>
                        </head>
                        <body>
                            <h1>Title</h1>
                            <p>This is some Foobar text</p>
                            <p>This is some other text</p>
                        </body>
                    </html>";
                TestDocument           document = new TestDocument(input);
                ConcurrentBag <string> content  = new ConcurrentBag <string>();
                ProcessHtml            process  = new ProcessHtml("p", x => content.Add(x.TextContent));

                // When
                IReadOnlyList <TestDocument> results = await ExecuteAsync(document, process);

                // Then
                content.ShouldBe(
                    new[]
                {
                    "This is some Foobar text",
                    "This is some other text"
                },
                    true);
                TestDocument result = results.ShouldHaveSingleItem();

                result.ShouldBe(document);
            }
Example #2
0
        private void fillButton_Click(object sender, EventArgs e)
        {
            if (imdbIdTextBox.Text != "")
            {
                try
                {
                    Convert.ToInt32(imdbIdTextBox.Text);
                }

                catch
                {
                    Notifications.ShowError("The IMDB ID can only contain numbers. Please check the given value.",
                                            "Invalid IMDB ID");
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;
                string  url      = "http://www.imdb.com/title/" + "tt" + imdbIdTextBox.Text + "/episodes";
                string  HtmlText = WebRequests.RequestPage(url);
                Episode latestEp = ProcessHtml.GetEpisodesFromHtml(imdbIdTextBox.Text, HtmlText, false)[0];

                if (HtmlText != "")
                {
                    nameTextBox.Text = ProcessHtml.GetNameFromHtml(HtmlText);
                    lastViewedEpisodeTextBox.Text = latestEp.ToString();
                }
            }

            else
            {
                Notifications.ShowError("Please give a valid IMDB ID of the desired series.", "Empty IMDB ID");
            }
        }
Example #3
0
        private void selectButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string imdbId = resultTable.SelectedRows[0].Cells[0].Value.ToString();
            string name   = resultTable.SelectedRows[0].Cells[1].Value.ToString();

            Variables.SelectedSeries = new Series(name, imdbId, new Episode(), new Episode(), new DateTime(), 3);

            string id = resultTable.SelectedRows[0].Cells[0].Value.ToString();

            Variables.SelectedSeries.LastEpisode = ProcessHtml.GetEpisodes(id, true)[0];

            if (Variables.SelectedSeries.LastEpisode.SeasonNumber != 0)
            {
                Variables.IsSelectedSeries = true;
                Close();
            }
        }
Example #4
0
            public async Task ChangesContentAndMetadata()
            {
                // Given
                const string input =
                    @"<html>
                        <head>
                            <title>Foobar</title>
                        </head>
                        <body>
                            <h1>Title</h1>
                            <p>This is some Foobar text</p>
                            <p>This is some other text</p>
                        </body>
                    </html>";
                TestDocument document = new TestDocument(input);
                int          c        = 1;
                ProcessHtml  process  = new ProcessHtml("p", (e, m) =>
                {
                    e.Insert(AngleSharp.Dom.AdjacentPosition.AfterEnd, "Fuzz");
                    m.Add("Foo" + c++.ToString(), e.TextContent);
                });

                // When
                IReadOnlyList <TestDocument> results = await ExecuteAsync(document, process);

                // Then
                TestDocument result = results.ShouldHaveSingleItem();

                result.ShouldNotBe(document);
                result.Content.ShouldBe(
                    @"<html><head>
                            <title>Foobar</title>
                        </head>
                        <body>
                            <h1>Title</h1>
                            <p>This is some Foobar text</p>Fuzz
                            <p>This is some other text</p>Fuzz
                        
                    </body></html>",
                    StringCompareShould.IgnoreLineEndings);
                result["Foo1"].ShouldBe("This is some Foobar text");
                result["Foo2"].ShouldBe("This is some other text");
            }