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

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

Initial Import of BMX4

File size: 4.0 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 CreateUpdateDeleteStandardRows : BmxValidUserTestSuite
16 {
17
18
19 [SetUp]
20 public override void Setup()
21 {
22 base.Setup();
23 this.SetupTable();
24 }
25
26 public override void SetupTable()
27 {
28 base.SetupTable();
29 this.ClearTable();
30 }
31
32 [Test]
33 public void AddRow()
34 {
35 DataTable table = this.RemoteSession.TableFromCommand(this.FetchTableString);
36 DataRow row = table.NewRow();
37 row["NAME"] = "John";
38 row["DATE"] = new DateTime(1970, 10, 10);
39 row["NUMBER"] = 8;
40 row["NUMBER R/O"] = 9;
41 table.Rows.Add(row);
42 Assert.AreEqual(1, table.Rows.Count);
43
44 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
45
46 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
47 Assert.AreEqual(1, table.Rows.Count);
48 row = table.Rows[0];
49 Assert.AreEqual(row["NAME"], "John");
50 Assert.AreEqual(row["DATE"], new DateTime(1970, 10, 10));
51 }
52
53
54
55 [Test]
56 public void UpdateRow()
57 {
58 DataTable table = this.RemoteSession.TableFromCommand(this.FetchTableString);
59 DataRow row = table.NewRow();
60 row["NAME"] = "John";
61 row["DATE"] = new DateTime(1970, 10, 10);
62 row["NUMBER"] = 8;
63 row["NUMBER R/O"] = 9;
64 table.Rows.Add(row);
65 Assert.AreEqual(1, table.Rows.Count);
66
67 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
68
69 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
70 row = table.Rows[0];
71 row["NAME"]="Fred";
72 row["DATE"]= new DateTime(1970, 11, 11);
73
74 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
75
76 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
77 Assert.AreEqual(1, table.Rows.Count);
78 row = table.Rows[0];
79 Assert.AreEqual(row["NAME"], "Fred");
80 Assert.AreEqual(row["DATE"], new DateTime(1970, 11, 11));
81 }
82
83
84 [Test]
85 public void DeleteRow()
86 {
87 DataTable table = this.RemoteSession.TableFromCommand(this.FetchTableString);
88 DataRow row = table.NewRow();
89 row["NAME"] = "John";
90 row["DATE"] = new DateTime(1970, 10, 10);
91 row["NUMBER"] = 8;
92 row["NUMBER R/O"] = 9;
93 table.Rows.Add(row);
94 Assert.AreEqual(1, table.Rows.Count);
95
96 row = table.NewRow();
97 row["NAME"] = "Jane";
98 row["DATE"] = new DateTime(1972, 10, 10);
99 row["NUMBER"] = 8;
100 row["NUMBER R/O"] = 9;
101 table.Rows.Add(row);
102 Assert.AreEqual(2, table.Rows.Count);
103
104 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
105
106 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
107 Assert.AreEqual(2, table.Rows.Count);
108 row = table.Rows[1];
109 Assert.AreEqual(row["NAME"], "Jane");
110 row.Delete();
111
112 //TODO: Deleting a row does not remove it ... it still counts. Assert below fails
113 //if 1
114 Assert.AreEqual(2, table.Rows.Count);
115
116 Assert.IsTrue(this.RemoteSession.SaveChanges(table));
117
118 table = this.RemoteSession.TableFromCommand(this.FetchTableString);
119 Assert.AreEqual(1, table.Rows.Count);
120 row = table.Rows[0];
121 Assert.AreEqual(row["NAME"],"John");
122
123 }
124
125
126
127
128
129 }
130}
Note: See TracBrowser for help on using the repository browser.