source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/BMX41000/IHS BMX Framework/IndianHealthService.BMXNet.Test/FrameworkEvents.cs@ 1492

Last change on this file since 1492 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 3.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using NUnit.Framework;
5using System.Data;
6
7namespace IndianHealthService.BMXNet.Tests
8{
9
10 /// <summary>
11 /// BMX ADO SS^BMX TEST FILE^^~~~~~
12 ///
13 /// </summary>
14 ///
15 public class FrameworkEvents : BmxValidUserTestSuite
16 {
17
18 private DataRow _testRow;
19
20 public DataRow TestRow
21 {
22 get { return _testRow; }
23 set { _testRow = value; }
24 }
25 private DataTable _testTable;
26
27 public DataTable TestTable
28 {
29 get { return _testTable; }
30 set { _testTable = value; }
31 }
32
33 public bool GenerateValidTestRow()
34 {
35 try
36 {
37 //smh -- need to remove the old row here...
38 DataTable table = this.RemoteSession.TableFromCommand(this.FetchTableString);
39
40 foreach (DataRow each in table.Rows)
41 {
42 each.Delete();
43 }
44 this.RemoteSession.SaveChanges(table);
45 //smh -end changes
46
47 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
48 DataRow row = table.NewRow();
49 row["NAME"] = "John";
50 row["DATE"] = new DateTime(1970, 10, 10);
51 row["NUMBER"] = 8;
52 row["NUMBER R/O"] = 9;
53 table.Rows.Add(row);
54 Assert.AreEqual(1, table.Rows.Count);
55
56 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
57
58 this.TestTable = this.RemoteSession.TableFromCommand(this.FetchTableString);
59 Assert.AreEqual(1, this.TestTable.Rows.Count);
60 this.TestRow = this.TestTable.Rows[0];
61 Assert.AreEqual(row["NAME"], "John");
62 Assert.AreEqual(row["DATE"], new DateTime(1970, 10, 10));
63 return true;
64 }
65 catch
66 {
67 return false;
68 }
69 }
70
71 public bool RefetchTestRow()
72 {
73 try
74 {
75 this.TestTable = this.RemoteSession.TableFromCommand(this.FetchTableString);
76 Assert.AreEqual(1, this.TestTable.Rows.Count);
77 this.TestRow = this.TestTable.Rows[0];
78 return true;
79 }
80 catch
81 {
82 return false;
83 }
84 }
85
86
87 [Test]
88 public void RowUpdatingEvent()
89 {
90
91 this.RowUpdatingEventMade = false;
92 this.GenerateValidTestRow();
93 this.TestTable.RowChanging += new DataRowChangeEventHandler(TestTable_RowChanging);
94
95 this.TestRow["NAME"] = "T";
96
97 Assert.IsTrue(this.RowUpdatingEventMade);
98
99 }
100
101 private bool _rowUpdatingEventMade = false;
102
103 public bool RowUpdatingEventMade
104 {
105 get { return _rowUpdatingEventMade; }
106 set { _rowUpdatingEventMade = value; }
107 }
108
109
110 void TestTable_RowChanging(object sender, DataRowChangeEventArgs e)
111 {
112 this.RowUpdatingEventMade = true;
113
114 }
115
116
117
118 [Test]
119 public void RowDeletedEvent()
120 {
121
122 this.RowDeleted = false;
123 this.GenerateValidTestRow();
124 this.TestTable.RowDeleted += new DataRowChangeEventHandler(TestTable_RowDeleted);
125
126 this.TestRow.Delete();
127
128 Assert.IsTrue(this.RowDeleted);
129
130 }
131
132 private bool _rowDeleted = false;
133
134 public bool RowDeleted
135 {
136 get { return _rowDeleted; }
137 set { _rowDeleted = value; }
138 }
139
140 void TestTable_RowDeleted(object sender, DataRowChangeEventArgs e)
141 {
142 this.RowDeleted = true;
143 }
144
145
146
147 }
148}
Note: See TracBrowser for help on using the repository browser.