1
- /*
1
+ /*
2
2
* Copyright 2007 ZXing authors
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
20
20
21
21
namespace ZXing . Client . Result . Test
22
22
{
23
- /// <summary>
24
- /// Tests <see cref="EmailAddressParsedResult" />.
25
- ///
26
- /// <author>Sean Owen</author>
27
- /// </summary>
28
- [ TestFixture ]
29
- public sealed class EmailAddressParsedResultTestCase
30
- {
31
- [ Test ]
32
- public void testEmailAddress ( )
33
- {
34
- doTest ( "srowen@example.org" , "srowen@example.org" , null , null ) ;
35
- doTest ( "mailto:srowen@example.org" , "srowen@example.org" , null , null ) ;
36
- }
23
+ /// <summary>
24
+ /// Tests <see cref="EmailAddressParsedResult" />.
25
+ ///
26
+ /// <author>Sean Owen</author>
27
+ /// </summary>
28
+ [ TestFixture ]
29
+ public sealed class EmailAddressParsedResultTestCase
30
+ {
31
+ [ Test ]
32
+ public void testEmailAddresses ( )
33
+ {
34
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( null ) , Is . False ) ;
35
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "" ) , Is . False ) ;
36
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123.365.com" ) , Is . False ) ;
37
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "abc.def.com" ) , Is . False ) ;
38
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@abcd.c" ) , Is . False ) ;
39
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@abcd" ) , Is . False ) ;
40
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@ab,cd.com" ) , Is . False ) ;
41
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@ab#cd.com" ) , Is . False ) ;
42
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@ab!#cd.com" ) , Is . False ) ;
43
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@ab_cd.com" ) , Is . False ) ;
44
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@-abcd.com" ) , Is . False ) ;
45
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@abcd-.com" ) , Is . False ) ;
46
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@abcd.c-m" ) , Is . False ) ;
47
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@abcd.com" ) , Is . True ) ;
48
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "123@ab-cd.com" ) , Is . True ) ;
49
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "abc.456@ab-cd.com" ) , Is . True ) ;
50
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "abc.456@ab-cd.BB-EZ-12.com" ) , Is . True ) ;
51
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "建設省.456@ab-cd.com" ) , Is . True ) ;
52
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "abc.Z456@ab-Cd9Z.co" ) , Is . True ) ;
53
+ Assert . That ( EmailDoCoMoResultParser . isBasicallyValidEmailAddress ( "建設省.aZ456@Ab-cd9Z.co" ) , Is . True ) ;
54
+ }
37
55
38
- [ Test ]
39
- public void testTos ( )
40
- {
41
- doTest ( "mailto:srowen@example.org,bob@example.org" ,
42
- new String [ ] { "srowen@example.org" , "bob@example.org" } ,
43
- null , null , null , null ) ;
44
- doTest ( "mailto:?to=srowen@example.org,bob@example.org" ,
45
- new String [ ] { "srowen@example.org" , "bob@example.org" } ,
46
- null , null , null , null ) ;
47
- }
56
+ [ Test ]
57
+ public void testEmailAddress ( )
58
+ {
59
+ doTest ( "srowen@example.org" , "srowen@example.org" , null , null ) ;
60
+ doTest ( "mailto:srowen@example.org" , "srowen@example.org" , null , null ) ;
61
+ }
48
62
49
- [ Test ]
50
- public void testCCs ( )
51
- {
52
- doTest ( "mailto:?cc=srowen@example.org" ,
53
- null ,
54
- new String [ ] { "srowen@example.org" } ,
55
- null , null , null ) ;
56
- doTest ( "mailto:?cc=srowen@example.org,bob@example.org" ,
57
- null ,
58
- new String [ ] { "srowen@example.org" , "bob@example.org" } ,
59
- null , null , null ) ;
60
- }
63
+ [ Test ]
64
+ public void testTos ( )
65
+ {
66
+ doTest ( "mailto:srowen@example.org,bob@example.org" ,
67
+ new String [ ] { "srowen@example.org" , "bob@example.org" } ,
68
+ null , null , null , null ) ;
69
+ doTest ( "mailto:?to=srowen@example.org,bob@example.org" ,
70
+ new String [ ] { "srowen@example.org" , "bob@example.org" } ,
71
+ null , null , null , null ) ;
72
+ }
61
73
62
- [ Test ]
63
- public void testBCCs ( )
64
- {
65
- doTest ( "mailto:?bcc =srowen@example.org" ,
66
- null , null ,
67
- new String [ ] { "srowen@example.org" } ,
68
- null , null ) ;
69
- doTest ( "mailto:?bcc =srowen@example.org,bob@example.org" ,
70
- null , null ,
71
- new String [ ] { "srowen@example.org" , "bob@example.org" } ,
72
- null , null ) ;
73
- }
74
+ [ Test ]
75
+ public void testCCs ( )
76
+ {
77
+ doTest ( "mailto:?cc =srowen@example.org" ,
78
+ null ,
79
+ new String [ ] { "srowen@example.org" } ,
80
+ null , null , null ) ;
81
+ doTest ( "mailto:?cc =srowen@example.org,bob@example.org" ,
82
+ null ,
83
+ new String [ ] { "srowen@example.org" , "bob@example.org" } ,
84
+ null , null , null ) ;
85
+ }
74
86
75
- [ Test ]
76
- public void testAll ( )
77
- {
78
- doTest ( "mailto:bob@example.org?cc=foo@example.org&bcc=srowen@example.org&subject=baz&body=buzz" ,
79
- new String [ ] { "bob@example.org" } ,
80
- new String [ ] { "foo@example.org" } ,
81
- new String [ ] { "srowen@example.org" } ,
82
- "baz" ,
83
- "buzz" ) ;
84
- }
87
+ [ Test ]
88
+ public void testBCCs ( )
89
+ {
90
+ doTest ( "mailto:?bcc=srowen@example.org" ,
91
+ null , null ,
92
+ new String [ ] { "srowen@example.org" } ,
93
+ null , null ) ;
94
+ doTest ( "mailto:?bcc=srowen@example.org,bob@example.org" ,
95
+ null , null ,
96
+ new String [ ] { "srowen@example.org" , "bob@example.org" } ,
97
+ null , null ) ;
98
+ }
85
99
86
- [ Test ]
87
- public void testEmailDocomo ( )
88
- {
89
- doTest ( "MATMSG:TO:srowen@example.org;;" , "srowen@example.org" , null , null ) ;
90
- doTest ( "MATMSG:TO:srowen@example.org;SUB:Stuff;;" , "srowen@example.org" , "Stuff" , null ) ;
91
- doTest ( "MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;" , "srowen@example.org" ,
92
- "Stuff" , "This is some text" ) ;
93
- }
100
+ [ Test ]
101
+ public void testAll ( )
102
+ {
103
+ doTest ( "mailto:bob@example.org?cc=foo@example.org&bcc=srowen@example.org&subject=baz&body=buzz" ,
104
+ new String [ ] { "bob@example.org" } ,
105
+ new String [ ] { "foo@example.org" } ,
106
+ new String [ ] { "srowen@example.org" } ,
107
+ "baz" ,
108
+ "buzz" ) ;
109
+ }
94
110
95
- [ Test ]
96
- public void testSMTP ( )
97
- {
98
- doTest ( "smtp: srowen@example.org" , "srowen@example.org" , null , null ) ;
99
- doTest ( "SMTP: srowen@example.org" , "srowen@example.org" , null , null ) ;
100
- doTest ( "smtp: srowen@example.org:foo " , "srowen@example.org" , "foo" , null ) ;
101
- doTest ( "smtp:srowen@example.org:foo:bar" , "srowen@example.org" , "foo ", "bar " ) ;
102
- }
111
+ [ Test ]
112
+ public void testEmailDocomo ( )
113
+ {
114
+ doTest ( "MATMSG:TO: srowen@example.org;; " , "srowen@example.org" , null , null ) ;
115
+ doTest ( "MATMSG:TO: srowen@example.org;SUB:Stuff;; " , "srowen@example.org" , "Stuff" , null ) ;
116
+ doTest ( "MATMSG:TO: srowen@example.org;SUB:Stuff;BODY:This is some text;; " , "srowen@example.org" ,
117
+ "Stuff ", "This is some text " ) ;
118
+ }
103
119
104
- private static void doTest ( String contents ,
105
- String to ,
106
- String subject ,
107
- String body )
108
- {
109
- doTest ( contents , new String [ ] { to } , null , null , subject , body ) ;
110
- }
120
+ [ Test ]
121
+ public void testSMTP ( )
122
+ {
123
+ doTest ( "smtp:srowen@example.org" , "srowen@example.org" , null , null ) ;
124
+ doTest ( "SMTP:srowen@example.org" , "srowen@example.org" , null , null ) ;
125
+ doTest ( "smtp:srowen@example.org:foo" , "srowen@example.org" , "foo" , null ) ;
126
+ doTest ( "smtp:srowen@example.org:foo:bar" , "srowen@example.org" , "foo" , "bar" ) ;
127
+ }
111
128
112
- private static void doTest ( String contents ,
113
- String [ ] tos ,
114
- String [ ] ccs ,
115
- String [ ] bccs ,
116
- String subject ,
117
- String body )
118
- {
119
- var fakeResult = new ZXing . Result ( contents , null , null , BarcodeFormat . QR_CODE ) ;
120
- var result = ResultParser . parseResult ( fakeResult ) ;
121
- Assert . AreEqual ( ParsedResultType . EMAIL_ADDRESS , result . Type ) ;
122
- var emailResult = ( EmailAddressParsedResult ) result ;
123
- Assert . AreEqual ( tos , emailResult . Tos ) ;
124
- Assert . AreEqual ( ccs , emailResult . CCs ) ;
125
- Assert . AreEqual ( bccs , emailResult . BCCs ) ;
126
- Assert . AreEqual ( subject , emailResult . Subject ) ;
127
- Assert . AreEqual ( body , emailResult . Body ) ;
128
- }
129
- }
129
+ private static void doTest ( String contents ,
130
+ String to ,
131
+ String subject ,
132
+ String body )
133
+ {
134
+ doTest ( contents , new String [ ] { to } , null , null , subject , body ) ;
135
+ }
136
+
137
+ private static void doTest ( String contents ,
138
+ String [ ] tos ,
139
+ String [ ] ccs ,
140
+ String [ ] bccs ,
141
+ String subject ,
142
+ String body )
143
+ {
144
+ var fakeResult = new ZXing . Result ( contents , null , null , BarcodeFormat . QR_CODE ) ;
145
+ var result = ResultParser . parseResult ( fakeResult ) ;
146
+ Assert . AreEqual ( ParsedResultType . EMAIL_ADDRESS , result . Type ) ;
147
+ var emailResult = ( EmailAddressParsedResult ) result ;
148
+ Assert . AreEqual ( tos , emailResult . Tos ) ;
149
+ Assert . AreEqual ( ccs , emailResult . CCs ) ;
150
+ Assert . AreEqual ( bccs , emailResult . BCCs ) ;
151
+ Assert . AreEqual ( subject , emailResult . Subject ) ;
152
+ Assert . AreEqual ( body , emailResult . Body ) ;
153
+ }
154
+ }
130
155
}
0 commit comments