public void ParseMethodTest() { // ARRANGE var text = @"<!DOCTYPE html> <html> <head> <title>Hello</title> </head> <body> <p>Hello, world. </body> </html>"; // ACT var contents = HtmlSyntaxParser.Parse(text); // ASSERT Assert.AreEqual("Hello, world.", contents["html"]["body"]["p"].Contents.Text); }
// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { if (this.ParameterSetName == "Path") { foreach (var filepath in SessionLocation.GetResolvedPath(this.SessionState, this.Path)) { // Validation (File Existence Check): if (!File.Exists(filepath)) { throw new FileNotFoundException(); } // Should Process if (this.ShouldProcess($"ファイル '{filepath}'", "HTML コンテンツの構文解析")) { // GET Parsed HTML Contents var contents = HtmlSyntaxParser.Read(filepath, this.Encoding); // OUTPUT HTML Contents this.WriteContents(contents); } } } else if (this.ParameterSetName == "InputObject") { // Should Process if (this.ShouldProcess($"入力文字列", "HTML コンテンツの構文解析")) { // GET Parsed HTML Contents var contents = HtmlSyntaxParser.Parse(this.InputObject); // OUTPUT HTML Contents this.WriteContents(contents); } } else { throw new InvalidOperationException(); } }