File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
src/test/unit/System.Windows.Forms/System/Windows/Forms Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ namespace System . Windows . Forms . Tests ;
5
+
6
+ public class HtmlElementErrorEventArgsTests
7
+ {
8
+ [ Fact ]
9
+ public void HtmlElementErrorEventArgs_InitializesProperties ( )
10
+ {
11
+ string description = "Script error" ;
12
+ string urlString = "https://example.com/page" ;
13
+ int lineNumber = 42 ;
14
+
15
+ HtmlElementErrorEventArgs args = new ( description , urlString , lineNumber ) ;
16
+
17
+ args . Description . Should ( ) . Be ( description ) ;
18
+ args . LineNumber . Should ( ) . Be ( lineNumber ) ;
19
+ args . Url . Should ( ) . Be ( new Uri ( urlString ) ) ;
20
+ args . Handled . Should ( ) . BeFalse ( ) ;
21
+ args . Handled = true ;
22
+ args . Handled . Should ( ) . BeTrue ( ) ;
23
+ }
24
+
25
+ [ Fact ]
26
+ public void HtmlElementErrorEventArgs_Url_CachesUriInstance ( )
27
+ {
28
+ HtmlElementErrorEventArgs args = new ( "desc" , "https://test" , 1 ) ;
29
+
30
+ Uri url1 = args . Url ;
31
+ Uri url2 = args . Url ;
32
+
33
+ url1 . Should ( ) . BeSameAs ( url2 ) ;
34
+ }
35
+
36
+ [ Fact ]
37
+ public void HtmlElementErrorEventArgs_Url_ThrowsOnInvalidUri ( )
38
+ {
39
+ HtmlElementErrorEventArgs args = new ( "desc" , "not a uri" , 1 ) ;
40
+
41
+ Action action = ( ) => _ = args . Url ;
42
+
43
+ action . Should ( ) . Throw < UriFormatException > ( ) ;
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments