-
Notifications
You must be signed in to change notification settings - Fork 7
/
DialogTests-Buttons.cs
87 lines (74 loc) · 2.32 KB
/
DialogTests-Buttons.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Fluqi.Widget.jDialog;
using System.Web;
using System.Web.Routing;
using Fluqi.Tests.Mocks;
using Fluqi.Tests;
using Fluqi.Tests.Helpers;
namespace Fluqi.Tests
{
[TestClass]
public partial class Dialog_Button_Tests
{
[TestMethod]
public void Ensure_One_Button_And_Other_Options_Are_Added_To_Script_Definition_Correctly()
{
// Arrange
var resp = new MockWriter();
Dialog dlg = TestHelper.SetupSimpleDialogObject(resp);
// only testing raw output
dlg
.Options
.AddButton("OK", "addToLog('OK button clicked.');")
.SetDisabled(true)
.SetPosition( Core.Position.ePosition.Left, Core.Position.ePosition.Top )
.Finish()
.Rendering
.Compress()
;
TestHelper.ForceRender(dlg);
// Act - Force output we'd see on the web page
string html = resp.Output.ToString();
// Assert
string expected =
"<script type=\"text/javascript\">" +
"$(document).ready( function() {" +
"$(\"#myDlg\").dialog({disabled: true,position: [ 'left', 'top' ],buttons: {\"OK\": function() {addToLog('OK button clicked.');}}})" +
";});" +
"</script>";
Assert.IsTrue(html.Contains(expected));
}
[TestMethod]
public void Ensure_Two_Buttons_Are_Added_To_Script_Definition_Correctly()
{
// Arrange
var resp = new MockWriter();
Dialog dlg = TestHelper.SetupSimpleDialogObject(resp);
// only testing raw output
dlg
.Options
.AddButton("OK", "addToLog('OK button clicked.');")
.AddButton("Cancel", "addToLog('Cancel button clicked.');")
.Finish()
.Rendering
.Compress()
;
TestHelper.ForceRender(dlg);
// Act - Force output we'd see on the web page
string html = resp.Output.ToString();
// Assert
string expected =
"<script type=\"text/javascript\">" +
"$(document).ready( function() {" +
"$(\"#myDlg\").dialog({buttons: {\"OK\": function() {addToLog('OK button clicked.');},\"Cancel\": function() {addToLog('Cancel button clicked.');}}})" +
";});" +
"</script>";
Assert.IsTrue(html.Contains(expected));
}
} // jDialog_Tests
} // ns