Subversion Repository Public Repository

ConnectionOdbcSdk

Diff Revisions 9 vs 10 for /trunk/ConnectionServerOdbcIntegrationTests/UnitTests/ConnectionServerOdbcUnitTests.cs

Diff revisions: vs.
  @@ -1,17 +1,46 @@
1 - using Cisco.UnityConnection.OdbcSdk;
1 + using System;
2 + using System.Data;
3 + using Cisco.UnityConnection.OdbcSdk;
2 4 using Microsoft.VisualStudio.TestTools.UnitTesting;
5 + using Moq;
3 6
4 7 namespace ConnectionServerOdbcIntegrationTests.UnitTests
5 8 {
6 9 [TestClass]
7 - public class ConnectionServerOdbcUnitTests
10 + public class ConnectionServerOdbcUnitTests:BaseUnitTests
8 11 {
12 +
9 13 [ClassInitialize]
10 14 public new static void ClassInitialize(TestContext testContext)
11 15 {
12 16 BaseUnitTests.ClassInitialize(testContext);
13 17 }
14 18
19 + #region Class Creation Tests
20 +
21 + [TestMethod]
22 + [ExpectedException(typeof(ArgumentException))]
23 + public void Constructor_NullConnectionServer_Failure()
24 + {
25 + ConnectionServerOdbc oTest = new ConnectionServerOdbc(null);
26 + Console.WriteLine(oTest);
27 + }
28 +
29 + [TestMethod]
30 + public void Constructor_LocationId_Dispose_Success()
31 + {
32 + ConnectionServerOdbc oTest = new ConnectionServerOdbc("objectid",new ConnectionInformixAdoNetDatabaseFunctions("name"));
33 + Console.WriteLine(oTest);
34 + oTest.Dispose();
35 +
36 + }
37 +
38 +
39 + #endregion
40 +
41 +
42 + #region Static Method Tests
43 +
15 44 [TestMethod]
16 45 public void IsValidExtensionTest_AllowBlank()
17 46 {
  @@ -76,5 +105,52 @@
76 105 Assert.IsTrue(ConnectionServerOdbc.IntFromBool(true)==1,"Bool value did not evaluate to 1 when true");
77 106 Assert.IsTrue(ConnectionServerOdbc.IntFromBool(false) == 0, "Bool value did not evaluate to 0 when false");
78 107 }
108 +
109 + #endregion
110 +
111 +
112 + #region Mocked Tests
113 +
114 + [TestMethod]
115 + public void UpdateDatabaseName_NullNameFailure()
116 + {
117 + Assert.IsFalse(MockServer.ChangeActiveDatabase(null),"Changing database name with null name should fail");
118 + }
119 +
120 + [TestMethod]
121 + public void InitVersionTest_CoRes()
122 + {
123 + MockDbFunctions.Setup(x => x.AttachToDatabase(It.IsAny<string>(),It.IsAny<string>(),It.IsAny<string>(),It.IsAny<string>())).
124 + Returns(new DbFetchResult(){Successful = true});
125 +
126 + MockDbFunctions.Setup(x => x.GetConfigurationString(It.IsAny<string>())).Returns("coresident");
127 +
128 + DataTable oDtVer = new DataTable();
129 + oDtVer.Columns.Add("product", typeof(string));
130 + oDtVer.Rows.Add("9.5.1.0");
131 + MockDbFunctions.Setup(x => x.FillDataTableBlocking(It.IsAny<string>(), out oDtVer, false, null)).
132 + Returns(new DbFetchResult(){Successful = true});
133 +
134 + DataTable oDtLocation = new DataTable();
135 + oDtLocation.Columns.Add("DisplayName", typeof(string));
136 + oDtLocation.Columns.Add("ObjectID", typeof(string));
137 + oDtLocation.Columns.Add("SMTPDomain", typeof(string));
138 + oDtLocation.Columns.Add("HostAddress", typeof(string));
139 + oDtLocation.Rows.Add("name", "objectid", "smtpdomain", "hostaddress");
140 + MockDbFunctions.Setup(x => x.FillDataTableBlocking(It.IsAny<string>(), out oDtLocation, true, null)).
141 + Returns(new DbFetchResult() { Successful = true });
142 +
143 + DataTable oDtNeighbor = new DataTable();
144 + MockDbFunctions.Setup(x => x.FillDataTableBlocking(It.IsAny<string>(), out oDtNeighbor, false, It.IsAny<string>())).
145 + Returns(new DbFetchResult() { Successful = true });
146 +
147 + var res= MockServer.LoginDatabaseBlocking("login", "password", "127.0.0.1");
148 + Assert.IsTrue(res.Successful,"Login failed:"+res);
149 + Assert.IsTrue(MockServer.UnityVersionIsCoRes,"CoRes flag should be set to true");
150 + }
151 +
152 +
153 + #endregion
154 +
79 155 }
80 156 }