Subversion Repository Public Repository

ConnectionOdbcSdk

Diff Revisions 18 vs 19 for /trunk/ConnectionServerOdbcIntegrationTests/UnitTests/ConnectionInformixAdoNetDatabaseFunctionUnitTests.cs

Diff revisions: vs.
  @@ -1,28 +1,429 @@
1 - using Cisco.UnityConnection.OdbcSdk;
1 + using System;
2 + using System.Data;
3 + using Cisco.UnityConnection.OdbcSdk;
2 4 using Microsoft.VisualStudio.TestTools.UnitTesting;
3 5 using Moq;
4 6
5 - namespace ConnectionServerOdbcIntegrationTests.UnitTests
7 + namespace UnityConnectionServerOdbcTests
6 8 {
7 9 [TestClass]
8 10 public class ConnectionInformixAdoNetDatabaseFunctionUnitTests: BaseUnitTests
9 11 {
12 +
13 + static private bool _errorRaised;
14 + static private UnityConnectionServerOdbc _server;
15 +
16 +
17 + private void OnErrorEventHandler(object sender, LogEventArgs logEventArgs)
18 + {
19 + _errorRaised = true;
20 + }
21 +
10 22 [ClassInitialize]
11 23 public new static void ClassInitialize(TestContext testContext)
12 24 {
13 25 BaseUnitTests.ClassInitialize(testContext);
26 + _server = new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing"));
27 + }
28 +
29 +
30 + [TestMethod]
31 + public void FillDataTableBlocking_InvalidConnectionState()
32 + {
33 + using (UnityConnectionServerOdbc oTemp =
34 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
35 + {
36 + DataTable oTable;
37 + var res = oTemp.DatabaseFunctions.FillDataTableBlocking("select * from tbl_user", out oTable);
38 + Assert.IsFalse(res.Successful, "FillDataTableBlocking call should fail with server in non connected state");
39 + }
40 + }
41 +
42 + [TestMethod]
43 + public void CallStoredProc_InvalidConnection_Failure()
44 + {
45 + using (UnityConnectionServerOdbc oTemp =
46 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
47 + {
48 + string strOut;
49 + oTemp.DatabaseFunctions.StartNewCommand("csp_allocatefile");
50 + var res = oTemp.DatabaseFunctions.ExecuteProc(out strOut);
51 + Assert.IsFalse(res.Successful, "Calling stored proc with invalid Connection should fail:" + res);
52 + }
53 + }
54 +
55 + [TestMethod]
56 + public void CallStoredProcNoRet_InvalidConnection_Failure()
57 + {
58 + using (UnityConnectionServerOdbc oTemp =
59 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
60 + {
61 + oTemp.DatabaseFunctions.StartNewCommand("csp_allocatefile");
62 + var res = oTemp.DatabaseFunctions.ExecuteProc();
63 + Assert.IsFalse(res.Successful, "Calling stored proc with invalid Connection should fail:" + res);
64 + }
65 + }
66 +
67 + [TestMethod]
68 + public void FindDistributionListByAliasNameOrExtension_InvalidConnectionState()
69 + {
70 + using (
71 + UnityConnectionServerOdbc oTemp =
72 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
73 + {
74 + int iCount;
75 + string strObjectId, strDescription;
76 + bool bRet = oTemp.DatabaseFunctions.FindDistributionListByAliasNameOrExtension("allvoicemailusers",
77 + "All Voice Mail Users", "99991", out iCount, out strObjectId, out strDescription, true);
78 + Assert.IsFalse(bRet, "FindDistributionList");
79 + }
80 + }
81 +
82 + [TestMethod]
83 + public void FindInterviewHandlerByNameOrExtension_InvalidConnection()
84 + {
85 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
86 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
87 + {
88 + oTemp.ErrorEvents += OnErrorEventHandler;
89 + _errorRaised = false;
90 + int iCount;
91 + string strObjectId, strDescription;
92 + bool bRet = oTemp.FindInterviewHandlerByNameOrExtension("junk", "junk", out iCount, out strObjectId, out strDescription);
93 + Assert.IsFalse(bRet, "Calling FindInterviewHandlerbyNameOrExtension with invalid Connection should fail");
94 + Assert.IsTrue(_errorRaised, "Calling FindInterviewHandlerbyNameOrExtension with invalid Connection should raise error");
95 + }
96 + }
97 +
98 +
99 +
100 + [TestMethod]
101 + public void ExecuteNonQuery_InvalidConnection_Failure()
102 + {
103 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
104 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
105 + {
106 + oTemp.ErrorEvents += OnErrorEventHandler;
107 + _errorRaised = false;
108 + const string strQuery = "SELECT COUNT(*) FORM vw_Subscriber";
109 + int iRet = oTemp.ExecuteNonQuery(strQuery, "junk");
110 + Assert.IsTrue(iRet == 0, "Call to ExecuteNonQuery from invalid connection should return 0");
111 + Assert.IsTrue(_errorRaised, "Call to ExecuteNonQuery from invalid connection should raise error");
112 + }
113 + }
114 +
115 + [TestMethod]
116 + public void GetCount_InvalidConnection_Failure()
117 + {
118 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
119 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
120 + {
121 + oTemp.ErrorEvents += OnErrorEventHandler;
122 + _errorRaised = false;
123 + const string strQuery = "SELECT COUNT(*) FROM tbl_user";
124 + int icount = oTemp.GetCount(strQuery);
125 + Assert.IsTrue(icount == 0, "Call to GetCount from Invalid Connection should return 0");
126 + Assert.IsTrue(_errorRaised, "Call to GetCount from Invalid Connection should raise error");
127 + }
128 + }
129 +
130 + [TestMethod]
131 + public void GetAliasOfObject_InvalidConnection()
132 + {
133 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
134 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
135 + {
136 + oTemp.ErrorEvents += OnErrorEventHandler;
137 + _errorRaised = false;
138 + string strAlias = oTemp.GetAliasOfObject("objectId");
139 + Assert.IsTrue(string.IsNullOrEmpty(strAlias), "Calling GetAliasOfObject with invalid connection should return blank string");
140 + Assert.IsTrue(_errorRaised, "Calling GetAliasOfObject with invalid Connection server should raise an error");
141 + }
142 + }
143 +
144 + [TestMethod]
145 + public void GetPrimaryDtmfAccessId_InvalidConnectionState()
146 + {
147 + using (UnityConnectionServerOdbc oTemp =
148 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
149 + {
150 + oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
151 + _errorRaised = false;
152 + var res = oTemp.DatabaseFunctions.GetPrimaryDtmfAccessId("ObjectId");
153 +
154 + Assert.IsTrue(string.IsNullOrEmpty(res), "GetPrimaryDtmfAccessId call should fail with server in non connected state");
155 + Assert.IsTrue(_errorRaised, "GetPrimaryDtmfAccessId should raise an error when called in a non connected state");
156 + }
157 + }
158 +
159 + [TestMethod]
160 + public void GetMailstoresList_InvalidConnectionServer()
161 + {
162 + using (UnityConnectionServerOdbc oTemp =
163 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("test")))
164 + {
165 + oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
166 + _errorRaised = false;
167 + var oList = oTemp.DatabaseFunctions.GetMailstoresList();
168 + Assert.IsTrue(oList.Count == 0, "Calling GetMailstoresList with an invalid Connection should return 0");
169 + Assert.IsTrue(_errorRaised, "Calling GetMailstoresList with invalid Connection should raise an error");
170 + }
171 + }
172 +
173 + [TestMethod]
174 + public void GetSingleValueFromQuery_InvalidConnectionState()
175 + {
176 + using (UnityConnectionServerOdbc oTemp =
177 + new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
178 + {
179 + oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
180 + _errorRaised = false;
181 + var res = oTemp.DatabaseFunctions.GetSingleValueFromQuery("select objectId from tbl_user", true, "noData");
182 + Assert.IsTrue(res.Equals(""), "GetSingleValueFromQuery call should return blank string with server in non connected state");
183 + Assert.IsTrue(_errorRaised, "GetSingleValueFromQuery should raise an error when called in a non connected state");
184 + }
185 + }
186 +
187 + [TestMethod]
188 + public void GetRemoteFileName_InvalidConnection()
189 + {
190 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
191 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
192 + {
193 + string strName = oTemp.GetRemoteFileName();
194 + Assert.IsTrue(string.IsNullOrEmpty(strName), "Remote file name generation with invalid Connection should return blank");
195 + }
196 + }
197 +
198 +
199 + [TestMethod]
200 + public void AddParameters_Bool()
201 + {
202 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
203 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
204 + {
205 + _errorRaised = false;
206 + const bool pBool = true;
207 + const string strSql = "SELECT COUNT(*) FROM vw_subscirber WHERE AutoAdvanceMsgs=?";
208 + oTemp.GetCount(strSql, pBool);
209 + Assert.IsFalse(_errorRaised,"Adding parrameter of type bool should not raise error");
210 + }
211 + }
212 +
213 + [TestMethod]
214 + public void AddParameters_Int()
215 + {
216 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
217 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
218 + {
219 + _errorRaised = false;
220 + const int pInt = 1;
221 + const string strSql = "SELECT COUNT(*) FROM vw_subscirber WHERE AutoAdvanceMsgs=?";
222 + oTemp.GetCount(strSql, pInt);
223 + Assert.IsFalse(_errorRaised, "Adding parrameter of type int should not raise error");
224 + }
14 225 }
15 226
227 + [TestMethod]
228 + public void AddParameters_Date()
229 + {
230 + using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
231 + new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
232 + {
233 + _errorRaised = false;
234 + DateTime pDate = DateTime.Now;
235 + const string strSql = "SELECT COUNT(*) FROM vw_greeting WHERE timeexpires>?";
236 + oTemp.GetCount(strSql, pDate);
237 + Assert.IsFalse(_errorRaised, "Adding parrameter of type int should not raise error");
238 + }
239 + }
16 240
241 +
17 242 [TestMethod]
18 - public void GetLogingErrorTests()
243 + public void GetActionDescription_InvalidAction()
19 244 {
20 - Assert.IsTrue(string.IsNullOrEmpty(ConnectionInformixAdoNetDatabaseFunctions.GetLoginErrorString(null)),
21 - "Null should return empty error string");
245 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 999, "objectId", "MenuObjectId");
246 + Assert.IsTrue(ret.ToLower().Contains("(error) invalid action id"),"Action Id of 999 not reported as error");
22 247 }
23 248
24 -
25 -
249 +
250 + [TestMethod]
251 + public void GetActionDescription_IgnoreKey()
252 + {
253 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 0, "objectId", "MenuObjectId");
254 + Assert.IsTrue(ret.ToLower().Contains("ignore key"), "Action Id of 0 not reported as ignore key");
255 + }
256 +
257 + [TestMethod]
258 + public void GetActionDescription_HangUp()
259 + {
260 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 1, "objectId", "MenuObjectId");
261 + Assert.IsTrue(ret.ToLower().Contains("hang up"), "Action Id of 1 not reported as hangup");
262 + }
263 + [TestMethod]
264 + public void GetActionDescription_GotoErrorGreeting()
265 + {
266 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 3, "objectId", "MenuObjectId");
267 + Assert.IsTrue(ret.ToLower().Contains("goto error greeting"), "Action Id of 3 not reported as goto error greeting");
268 + }
269 + [TestMethod]
270 + public void GetActionDescription_TakeMessage()
271 + {
272 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 4, "objectId", "MenuObjectId");
273 + Assert.IsTrue(ret.ToLower().Contains("take message"), "Action Id of 4 not reported as Take Message");
274 + }
275 + [TestMethod]
276 + public void GetActionDescription_SkipGreeting()
277 + {
278 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 5, "objectId", "MenuObjectId");
279 + Assert.IsTrue(ret.ToLower().Contains("skip greeting"), "Action Id of 0 not reported as ignore key");
280 + }
281 + [TestMethod]
282 + public void GetActionDescription_RepeatGreeting()
283 + {
284 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 6, "objectId", "MenuObjectId");
285 + Assert.IsTrue(ret.ToLower().Contains("repeat greeting"), "Action Id of 6 not reported as repeat greeting");
286 + }
287 + [TestMethod]
288 + public void GetActionDescription_RouteFromNext()
289 + {
290 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 8, "objectId", "MenuObjectId");
291 + Assert.IsTrue(ret.ToLower().Contains("route from next call routing rule"), "Action Id of 8 not reported as route from next");
292 + }
293 +
294 + [TestMethod]
295 + public void GetActionDescription_AlternateTransferNumber()
296 + {
297 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 7, "objectId", "MenuObjectId");
298 + Assert.IsTrue(ret.ToLower().Contains("transfer to alternate contact number"),
299 + "Action Id of 7 not reported as alternate transfer number");
300 + }
301 +
302 + [TestMethod]
303 + public void GetActionDescription_Goto_EmptyConversationName()
304 + {
305 + string ret = _server.DatabaseFunctions.GetActionDescription("", 2, "objectId", "MenuObjectId");
306 + Assert.IsTrue(ret.ToLower().Contains("(error)"),"Action Id of 2 with no conversation name not reported as error");
307 + }
308 +
309 + [TestMethod]
310 + public void GetActionDescription_Goto_InvalidConversationName()
311 + {
312 + string ret = _server.DatabaseFunctions.GetActionDescription("junk", 2, "objectId", "MenuObjectId");
313 + Assert.IsTrue(ret.ToLower().Contains("(error)"), "Action Id of 2 with invalid conversation name not reported as error");
314 + }
315 +
316 + [TestMethod]
317 + public void GetActionDescription_Goto_SubSignIn()
318 + {
319 + string ret = _server.DatabaseFunctions.GetActionDescription("subsignin", 2, "objectId", "MenuObjectId");
320 + Assert.IsTrue(ret.ToLower().Contains("user sign in"), "Correct goto conversation not recognized");
321 + }
322 +
323 + [TestMethod]
324 + public void GetActionDescription_Goto_GreetingsAdministrator()
325 + {
326 + string ret = _server.DatabaseFunctions.GetActionDescription("greetingsadministrator", 2, "objectId", "MenuObjectId");
327 + Assert.IsTrue(ret.ToLower().Contains("greetings administrator"), "Correct goto conversation not recognized");
328 + }
329 +
330 + [TestMethod]
331 + public void GetActionDescription_Goto_ConvHotelCheckedOut()
332 + {
333 + string ret = _server.DatabaseFunctions.GetActionDescription("convhotelcheckedout", 2, "objectId", "MenuObjectId");
334 + Assert.IsTrue(ret.ToLower().Contains("checked out hotel guest"), "Correct goto conversation not recognized");
335 + }
336 +
337 + [TestMethod]
338 + public void GetActionDescription_Goto_ConvCvmMboxReset()
339 + {
340 + string ret = _server.DatabaseFunctions.GetActionDescription("convcvmmboxreset", 2, "objectId", "MenuObjectId");
341 + Assert.IsTrue(ret.ToLower().Contains("community voice mail box reset"), "Correct goto conversation not recognized");
342 + }
343 +
344 + [TestMethod]
345 + public void GetActionDescription_Goto_SubSystemTransfer()
346 + {
347 + string ret = _server.DatabaseFunctions.GetActionDescription("subsystransfer", 2, "objectId", "MenuObjectId");
348 + Assert.IsTrue(ret.ToLower().Contains("user system transfer"), "Correct goto conversation not recognized");
349 + }
350 +
351 + [TestMethod]
352 + public void GetActionDescription_Goto_SystemTransfer()
353 + {
354 + string ret = _server.DatabaseFunctions.GetActionDescription("systemtransfer", 2, "objectId", "MenuObjectId");
355 + Assert.IsTrue(ret.ToLower().Contains("system transfer"), "Correct goto conversation not recognized");
356 + }
357 +
358 + [TestMethod]
359 + public void GetActionDescription_Goto_EasySignIn()
360 + {
361 + string ret = _server.DatabaseFunctions.GetActionDescription("easysignin", 2, "objectId", "MenuObjectId");
362 + Assert.IsTrue(ret.ToLower().Contains("easy subscriber sign in"), "Correct goto conversation not recognized");
363 + }
364 +
365 + [TestMethod]
366 + public void GetActionDescription_Goto_TransferAlternateContactNumber()
367 + {
368 + string ret = _server.DatabaseFunctions.GetActionDescription("transferaltcontactnumber", 2, "objectId", "MenuObjectId");
369 + Assert.IsTrue(ret.ToLower().Contains("alternate contact number"), "Correct goto conversation not recognized");
370 + }
371 +
372 + [TestMethod]
373 + public void GetActionDescription_Goto_BroadcastMessageAdministrator()
374 + {
375 + string ret = _server.DatabaseFunctions.GetActionDescription("broadcastmessageadministrator", 2, "objectId", "MenuObjectId");
376 + Assert.IsTrue(ret.ToLower().Contains("broadcast message administrator"), "Correct goto conversation not recognized");
377 + }
378 +
379 + [TestMethod]
380 + public void GetActionDescription_Goto_Ad()
381 + {
382 + string ret = _server.DatabaseFunctions.GetActionDescription("ad", 2, "objectId", "MenuObjectId");
383 + Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
384 + }
385 +
386 + [TestMethod]
387 + public void GetActionDescription_Goto_PhTransfer()
388 + {
389 + string ret = _server.DatabaseFunctions.GetActionDescription("PhTransfer", 2, "objectId", "MenuObjectId");
390 + Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
391 + }
392 +
393 + [TestMethod]
394 + public void GetActionDescription_Goto_PhGreeting()
395 + {
396 + string ret = _server.DatabaseFunctions.GetActionDescription("PhGreeting", 2, "objectId", "MenuObjectId");
397 + Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
398 + }
399 +
400 + [TestMethod]
401 + public void GetActionDescription_Goto_PhInterview()
402 + {
403 + string ret = _server.DatabaseFunctions.GetActionDescription("PhInterview", 2, "objectId", "MenuObjectId");
404 + Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
405 + }
406 +
407 + [TestMethod]
408 + public void GetObjectDescription_Handler_Missing()
409 + {
410 + string ret = _server.DatabaseFunctions.GetObjectDescription("junk", ObjectsTypesWithExtensions.Handler);
411 + Assert.IsTrue(ret.Contains("[Unknown Handler Type]"));
412 + }
413 +
414 + [TestMethod]
415 + public void GetObjectDescription_Location_InvalidType()
416 + {
417 + string ret = _server.DatabaseFunctions.GetObjectDescription("Junk", (ObjectsTypesWithExtensions)99);
418 + Assert.IsTrue(ret.Contains("(error)"));
419 + }
420 +
421 + [TestMethod]
422 + public void GetObjectDescription_Contact_NoMatch()
423 + {
424 + string ret = _server.DatabaseFunctions.GetObjectDescription("Junk", ObjectsTypesWithExtensions.Contact);
425 + Assert.IsTrue(ret.Contains("(error)"));
426 + }
26 427
27 428 }
28 429 }