1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
//
// Tests for System.Web.UI.WebControls.ImageMap.cs
//
// Author:
// Hagit Yidov (hagity@mainsoft.com
//
// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.IO;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoTests.stand_alone.WebHarness;
using MonoTests.SystemWeb.Framework;
using System.Threading;
namespace MonoTests.System.Web.UI.WebControls
{
class PokerImageMap : ImageMap
{
// View state Stuff
public PokerImageMap ()
{
TrackViewState ();
}
public object SaveState ()
{
return SaveViewState ();
}
public void LoadState (object o)
{
LoadViewState (o);
}
public StateBag StateBag
{
get { return base.ViewState; }
}
public void DoOnClick (ImageMapEventArgs e)
{
base.OnClick (e);
}
public void DoOnBubbleEven (Object source, ImageMapEventArgs e)
{
base.OnBubbleEvent (source, e);
}
// Render Method
public string Render ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
Render (tw);
return sw.ToString ();
}
}
[TestFixture]
public class ImageMapTest
{
[TestFixtureSetUp]
public void SetUp ()
{
WebTest.CopyResource (GetType (), "NoEventValidation.aspx", "NoEventValidation.aspx");
}
[Test]
public void ImageMap_DefaultProperties ()
{
PokerImageMap imageMap = new PokerImageMap ();
Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count");
Assert.AreEqual (true, imageMap.Enabled, "Enabled");
Assert.AreEqual (HotSpotMode.NotSet, imageMap.HotSpotMode, "HotSpotMode");
Assert.AreEqual (0, imageMap.HotSpots.Count, "HotSpots.Count");
Assert.AreEqual (string.Empty, imageMap.Target, "Target");
}
[Test]
public void ImageMap_AssignToDefaultProperties ()
{
PokerImageMap imageMap = new PokerImageMap ();
Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count");
imageMap.Enabled = true;
Assert.AreEqual (true, imageMap.Enabled, "Enabled");
Assert.AreEqual (0, imageMap.StateBag.Count, "ViewState.Count-1");
imageMap.HotSpotMode = HotSpotMode.Navigate;
Assert.AreEqual (HotSpotMode.Navigate, imageMap.HotSpotMode, "HotSpotMode");
Assert.AreEqual (1, imageMap.StateBag.Count, "ViewState.Count-2");
imageMap.HotSpots.Add (new CircleHotSpot ());
Assert.AreEqual (1, imageMap.HotSpots.Count, "HotSpots.Count");
Assert.AreEqual (1, imageMap.StateBag.Count, "ViewState.Count-3");
imageMap.Target = "Target";
Assert.AreEqual ("Target", imageMap.Target, "Target");
Assert.AreEqual (2, imageMap.StateBag.Count, "ViewState.Count-4");
}
[Test]
public void ImageMap_Defaults_Render ()
{
PokerImageMap imageMap = new PokerImageMap ();
#if NET_4_0
string originalHtml = "<img src=\"\" />";
#else
string originalHtml = "<img src=\"\" style=\"border-width:0px;\" />";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderDefault");
}
[Test]
public void ImageMap_AssignedValues_RenderNavigate ()
{
// HotSpotMode = Navigate using NavigateURL
//-----------------------------------------
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = true;
imageMap.HotSpotMode = HotSpotMode.Navigate;
imageMap.Target = "Target";
CircleHotSpot circle = new CircleHotSpot ();
circle.NavigateUrl = "NavigateURL";
imageMap.HotSpots.Add (circle);
#if NET_4_0
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" href=\"NavigateURL\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
#else
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" style=\"border-width:0px;\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" href=\"NavigateURL\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateTextAssigned");
}
[Test]
public void ImageMap_AssignedValues_RenderNavigateCircle ()
{
// Circle.HotSpotMode = Navigate
//------------------------------
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = true;
CircleHotSpot circle = new CircleHotSpot ();
circle.AccessKey = "A";
circle.AlternateText = "Circle";
circle.HotSpotMode = HotSpotMode.Navigate;
circle.NavigateUrl = "NavigateURL";
circle.TabIndex = 1;
circle.Radius = 10;
circle.X = 30;
circle.Y = 40;
imageMap.HotSpots.Add (circle);
#if NET_4_0
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"30,40,10\" href=\"NavigateURL\" title=\"Circle\" alt=\"Circle\" accesskey=\"A\" tabindex=\"1\" />\r\n</map>";
#else
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" style=\"border-width:0px;\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"30,40,10\" href=\"NavigateURL\" title=\"Circle\" alt=\"Circle\" accesskey=\"A\" tabindex=\"1\" />\r\n</map>";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateCircleTextAssigned");
}
[Test]
public void ImageMap_AssignedValues_RenderNavigateShapes ()
{
// Rectangle/Polygon.HotSpotMode = Navigate
//-----------------------------------------
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = true;
imageMap.HotSpotMode = HotSpotMode.NotSet;
RectangleHotSpot rect = new RectangleHotSpot ();
rect.AccessKey = "R";
rect.AlternateText = "Rectangle";
rect.HotSpotMode = HotSpotMode.Navigate;
rect.NavigateUrl = "NavigateUrlRect";
rect.TabIndex = 1;
rect.Bottom = 10;
rect.Top = 20;
rect.Left = 30;
rect.Right = 40;
imageMap.HotSpots.Add (rect);
imageMap.HotSpotMode = HotSpotMode.Navigate;
PolygonHotSpot poly = new PolygonHotSpot ();
poly.AccessKey = "P";
poly.AlternateText = "Polygon";
poly.NavigateUrl = "NavigateUrlPoly";
poly.TabIndex = 2;
poly.Coordinates = "10,20,30,40,50,60,100,200";
imageMap.HotSpots.Add (poly);
#if NET_4_0
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"rect\" coords=\"30,20,40,10\" href=\"NavigateUrlRect\" title=\"Rectangle\" alt=\"Rectangle\" accesskey=\"R\" tabindex=\"1\" /><area shape=\"poly\" coords=\"10,20,30,40,50,60,100,200\" href=\"NavigateUrlPoly\" title=\"Polygon\" alt=\"Polygon\" accesskey=\"P\" tabindex=\"2\" />\r\n</map>";
#else
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" style=\"border-width:0px;\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"rect\" coords=\"30,20,40,10\" href=\"NavigateUrlRect\" title=\"Rectangle\" alt=\"Rectangle\" accesskey=\"R\" tabindex=\"1\" /><area shape=\"poly\" coords=\"10,20,30,40,50,60,100,200\" href=\"NavigateUrlPoly\" title=\"Polygon\" alt=\"Polygon\" accesskey=\"P\" tabindex=\"2\" />\r\n</map>";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderNavigateShapesTextAssigned");
}
[Test]
public void ImageMap_AssignedValues_RenderInactive ()
{
// HotSpotMode = Inactive
//-----------------------
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = true;
imageMap.HotSpotMode = HotSpotMode.Inactive;
imageMap.Target = "Target";
imageMap.HotSpots.Add (new CircleHotSpot ());
#if NET_4_0
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" nohref=\"true\" title=\"\" alt=\"\" />\r\n</map>";
#else
string originalHtml = "<img src=\"\" usemap=\"#ImageMap\" style=\"border-width:0px;\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" nohref=\"true\" title=\"\" alt=\"\" />\r\n</map>";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderInaciveTextAssigned");
}
[Test]
public void ImageMap_AssignedValues_RenderDisabled ()
{
// Enabled = false
//----------------
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = false;
imageMap.HotSpotMode = HotSpotMode.Navigate;
imageMap.Target = "Target";
CircleHotSpot circle = new CircleHotSpot ();
circle.NavigateUrl = "NavigateURL";
imageMap.HotSpots.Add (circle);
#if NET_4_0
string originalHtml = "<img class=\"aspNetDisabled\" src=\"\" usemap=\"#ImageMap\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
#else
string originalHtml = "<img disabled=\"disabled\" src=\"\" usemap=\"#ImageMap\" style=\"border-width:0px;\" /><map name=\"ImageMap\" id=\"ImageMap\">\r\n\t<area shape=\"circle\" coords=\"0,0,0\" href=\"NavigateURL\" target=\"Target\" title=\"\" alt=\"\" />\r\n</map>";
#endif
string renderedHtml = imageMap.Render ();
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "RenderDisabledTextAssigne");
}
[Test]
public void ImageMap_ViewState ()
{
PokerImageMap imageMap = new PokerImageMap ();
imageMap.Enabled = true;
Assert.AreEqual (true, imageMap.Enabled, "Enabled-beforecopy");
imageMap.HotSpotMode = HotSpotMode.Navigate;
Assert.AreEqual (HotSpotMode.Navigate, imageMap.HotSpotMode, "HotSpotMode-beforecopy");
imageMap.HotSpots.Add (new CircleHotSpot ());
Assert.AreEqual (1, imageMap.HotSpots.Count, "HotSpots.Count-beforecopy");
imageMap.Target = "Target";
Assert.AreEqual ("Target", imageMap.Target, "Target-beforecopy");
object state = imageMap.SaveState ();
PokerImageMap copy = new PokerImageMap ();
copy.LoadState (state);
Assert.AreEqual (true, copy.Enabled, "Enabled-aftercopy");
Assert.AreEqual (HotSpotMode.Navigate, copy.HotSpotMode, "HotSpotMode-aftercopy");
//Assert.AreEqual(1, copy.HotSpots.Count, "HotSpots.Count-aftercopy");
Assert.AreEqual ("Target", copy.Target, "Target-aftercopy");
}
// Events Stuff
private bool clicked = false;
private string pbValue;
private void ImageMapClickHandler (object sender, ImageMapEventArgs e)
{
clicked = true;
pbValue = e.PostBackValue;
}
private void ResetEvents ()
{
clicked = false;
pbValue = "Init";
}
[Test]
public void ImageMap_Event ()
{
PokerImageMap imageMap = new PokerImageMap ();
ResetEvents ();
imageMap.HotSpotMode = HotSpotMode.PostBack;
imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
Assert.AreEqual (false, clicked, "BeforeClick");
imageMap.DoOnClick (new ImageMapEventArgs ("HotSpotName"));
Assert.AreEqual (true, clicked, "AfterClick");
}
[Test]
public void ImageMap_EventCircle ()
{
PokerImageMap imageMap = new PokerImageMap ();
ResetEvents ();
imageMap.HotSpotMode = HotSpotMode.NotSet;
CircleHotSpot circle = new CircleHotSpot ();
circle.HotSpotMode = HotSpotMode.PostBack;
circle.PostBackValue = "myCircle";
imageMap.HotSpots.Add (circle);
imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
Assert.AreEqual ("Init", pbValue, "BeforeClick");
imageMap.DoOnClick (new ImageMapEventArgs (circle.PostBackValue));
Assert.AreEqual ("myCircle", pbValue, "AfterClick");
}
[Test]
public void ImageMap_EventRectangle ()
{
PokerImageMap imageMap = new PokerImageMap ();
ResetEvents ();
imageMap.HotSpotMode = HotSpotMode.PostBack;
RectangleHotSpot rect = new RectangleHotSpot ();
rect.PostBackValue = "myRect";
imageMap.HotSpots.Add (rect);
imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
Assert.AreEqual ("Init", pbValue, "BeforeClick");
imageMap.DoOnClick (new ImageMapEventArgs (rect.PostBackValue));
Assert.AreEqual ("myRect", pbValue, "AfterClick");
}
[Test]
public void ImageMap_EventPolygon ()
{
PokerImageMap imageMap = new PokerImageMap ();
ResetEvents ();
imageMap.HotSpotMode = HotSpotMode.NotSet;
PolygonHotSpot poly = new PolygonHotSpot ();
poly.HotSpotMode = HotSpotMode.PostBack;
poly.PostBackValue = "myPoly";
imageMap.HotSpots.Add (poly);
imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
Assert.AreEqual ("Init", pbValue, "BeforeClick");
imageMap.DoOnClick (new ImageMapEventArgs (poly.PostBackValue));
Assert.AreEqual ("myPoly", pbValue, "AfterClick");
}
public void ImageMap_BubbleEvent ()
{
PokerImageMap imageMap = new PokerImageMap ();
ResetEvents ();
ImageMapEventArgs args = new ImageMapEventArgs ("HotSpotName");
imageMap.Click += new ImageMapEventHandler (ImageMapClickHandler);
Assert.AreEqual (false, clicked, "BeforeClick");
imageMap.DoOnBubbleEven (imageMap, args);
Assert.AreEqual (true, clicked, "AfterClick");
}
private static void ImageMapClickHandler2 (object sender, ImageMapEventArgs e)
{
WebTest.CurrentTest.UserData = e.PostBackValue;
}
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBackRectangle ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
t.Run ();
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
fr.Controls.Add ("__EVENTARGUMENT");
fr.Controls["__EVENTTARGET"].Value = "imgmap";
fr.Controls["__EVENTARGUMENT"].Value = "0";
t.Request = fr;
t.Run ();
Assert.AreEqual ("Rectangle", t.UserData, "AfterPostBack");
}
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBackFireEvent ()
{
WebTest t = new WebTest ("NoEventValidation.aspx");
t.Invoker = PageInvoker.CreateOnLoad (PostBackFireEvent_Init);
t.Run ();
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
fr.Controls.Add ("__EVENTARGUMENT");
fr.Controls["__EVENTTARGET"].Value = "imgmap";
fr.Controls["__EVENTARGUMENT"].Value = "0";
t.Request = fr;
t.Run ();
if (t.UserData == null)
Assert.Fail ("Event not fired fail");
Assert.AreEqual ("ImageMapClickHandler", t.UserData.ToString (), "PostBackFireEvent");
}
#region PostBackFireEvent
public static void PostBackFireEvent_Init (Page p)
{
ImageMap imgmap = new ImageMap ();
imgmap.ID = "imgmap";
imgmap.HotSpotMode = HotSpotMode.NotSet;
imgmap.Click += new ImageMapEventHandler (ImageMapClickHandler3);
RectangleHotSpot rect = new RectangleHotSpot ();
rect.HotSpotMode = HotSpotMode.PostBack;
rect.PostBackValue = "Rectangle";
imgmap.HotSpots.Add (rect);
p.Form.Controls.Add (imgmap);
}
public static void ImageMapClickHandler3 (object sender, ImageMapEventArgs e)
{
WebTest.CurrentTest.UserData = "ImageMapClickHandler";
}
#endregion
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBackCircle ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
t.Run ();
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
fr.Controls.Add ("__EVENTARGUMENT");
fr.Controls["__EVENTTARGET"].Value = "imgmap";
fr.Controls["__EVENTARGUMENT"].Value = "2";
t.Request = fr;
t.Run ();
Assert.AreEqual ("Circle", t.UserData, "AfterPostBack");
}
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBackPolygon ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
t.Run ();
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
fr.Controls.Add ("__EVENTARGUMENT");
fr.Controls["__EVENTTARGET"].Value = "imgmap";
fr.Controls["__EVENTARGUMENT"].Value = "1";
t.Request = fr;
t.Run ();
Assert.AreEqual ("Polygon", t.UserData, "AfterPostBack");
}
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBack_RenderBefore ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
#region orig
#if NET_4_0
string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack('imgmap','0')\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack('imgmap','1')\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack('imgmap','2')\" title=\"\" alt=\"\" />\r\n</map>";
#else
string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" style=\"border-width:0px;\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack('imgmap','0')\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack('imgmap','1')\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack('imgmap','2')\" title=\"\" alt=\"\" />\r\n</map>";
#endif
#endregion
string RenderedPageHtml = t.Run ();
string RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
HtmlDiff.AssertAreEqual (strTarget, RenderedControlHtml, "BeforePostBack");
}
[Test]
[Category ("NunitWeb")]
public void ImageMap_PostBack_RenderAfter ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (myPageLoad));
t.Run ();
FormRequest fr = new FormRequest (t.Response, "form1");
fr.Controls.Add ("__EVENTTARGET");
fr.Controls.Add ("__EVENTARGUMENT");
fr.Controls["__EVENTTARGET"].Value = "imgmap";
fr.Controls["__EVENTARGUMENT"].Value = "0";
t.Request = fr;
#region orig
#if NET_4_0
string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack('imgmap','0')\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack('imgmap','1')\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack('imgmap','2')\" title=\"\" alt=\"\" />\r\n</map>";
#else
string strTarget = "<img id=\"imgmap\" src=\"\" usemap=\"#ImageMapimgmap\" style=\"border-width:0px;\" /><map name=\"ImageMapimgmap\" id=\"ImageMapimgmap\">\r\n\t<area shape=\"rect\" coords=\"0,0,0,0\" href=\"javascript:__doPostBack('imgmap','0')\" title=\"\" alt=\"\" /><area shape=\"poly\" coords=\"\" href=\"javascript:__doPostBack('imgmap','1')\" title=\"\" alt=\"\" /><area shape=\"circle\" coords=\"0,0,0\" href=\"javascript:__doPostBack('imgmap','2')\" title=\"\" alt=\"\" />\r\n</map>";
#endif
#endregion
string RenderedPageHtml = t.Run ();
string RenderedControlHtml = HtmlDiff.GetControlFromPageHtml (RenderedPageHtml);
HtmlDiff.AssertAreEqual (strTarget, RenderedControlHtml, "AfterPostBack");
}
public static void myPageLoad (Page page)
{
WebTest.CurrentTest.UserData = "Init";
ImageMap imgmap = new ImageMap ();
imgmap.ID = "imgmap";
imgmap.HotSpotMode = HotSpotMode.NotSet;
imgmap.Click += new ImageMapEventHandler (ImageMapClickHandler2);
RectangleHotSpot rect = new RectangleHotSpot ();
rect.HotSpotMode = HotSpotMode.PostBack;
rect.PostBackValue = "Rectangle";
imgmap.HotSpots.Add (rect);
PolygonHotSpot poly = new PolygonHotSpot ();
poly.HotSpotMode = HotSpotMode.PostBack;
poly.PostBackValue = "Polygon";
imgmap.HotSpots.Add (poly);
imgmap.HotSpotMode = HotSpotMode.PostBack;
CircleHotSpot circle = new CircleHotSpot ();
circle.PostBackValue = "Circle";
imgmap.HotSpots.Add (circle);
// Two marks for getting controls from form
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
page.Form.Controls.Add (lcb);
page.Form.Controls.Add (imgmap);
page.Form.Controls.Add (lce);
}
[SetUp]
public void SetUpTest ()
{
Thread.Sleep (100);
}
[TestFixtureTearDown]
public void TearDown ()
{
WebTest.Unload ();
}
}
}
#endif
|