Subversion Repository Public Repository

ConnectionOdbcSdk

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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
´╗┐using System;
using System.Data;
using Cisco.UnityConnection.OdbcSdk;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace UnityConnectionServerOdbcTests
{
    [TestClass]
    public class ConnectionInformixAdoNetDatabaseFunctionUnitTests: BaseUnitTests
    {

        static private bool _errorRaised;
        static private UnityConnectionServerOdbc _server;
        

        private void OnErrorEventHandler(object sender, LogEventArgs logEventArgs)
        {
            _errorRaised = true;
        }

        [ClassInitialize]
        public new static void ClassInitialize(TestContext testContext)
        {
            BaseUnitTests.ClassInitialize(testContext);
            _server = new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing"));
        }


        [TestMethod]
        public void FillDataTableBlocking_InvalidConnectionState()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                DataTable oTable;
                var res = oTemp.DatabaseFunctions.FillDataTableBlocking("select * from tbl_user", out oTable);
                Assert.IsFalse(res.Successful, "FillDataTableBlocking call should fail with server in non connected state");
            }
        }

        [TestMethod]
        public void CallStoredProc_InvalidConnection_Failure()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                string strOut;
                oTemp.DatabaseFunctions.StartNewCommand("csp_allocatefile");
                var res = oTemp.DatabaseFunctions.ExecuteProc(out strOut);
                Assert.IsFalse(res.Successful, "Calling stored proc with invalid Connection should fail:" + res);
            }
        }

        [TestMethod]
        public void CallStoredProcNoRet_InvalidConnection_Failure()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                oTemp.DatabaseFunctions.StartNewCommand("csp_allocatefile");
                var res = oTemp.DatabaseFunctions.ExecuteProc();
                Assert.IsFalse(res.Successful, "Calling stored proc with invalid Connection should fail:" + res);
            }
        }

        [TestMethod]
        public void FindDistributionListByAliasNameOrExtension_InvalidConnectionState()
        {
            using (
                UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                int iCount;
                string strObjectId, strDescription;
                bool bRet = oTemp.DatabaseFunctions.FindDistributionListByAliasNameOrExtension("allvoicemailusers",
                    "All Voice Mail Users", "99991", out iCount, out strObjectId, out strDescription, true);
                Assert.IsFalse(bRet, "FindDistributionList");
            }
        }

        [TestMethod]
        public void FindInterviewHandlerByNameOrExtension_InvalidConnection()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                oTemp.ErrorEvents += OnErrorEventHandler; 
                _errorRaised = false;
                int iCount;
                string strObjectId, strDescription;
                bool bRet = oTemp.FindInterviewHandlerByNameOrExtension("junk", "junk", out iCount, out strObjectId, out strDescription);
                Assert.IsFalse(bRet, "Calling FindInterviewHandlerbyNameOrExtension with invalid Connection should fail");
                Assert.IsTrue(_errorRaised, "Calling FindInterviewHandlerbyNameOrExtension with invalid Connection should raise error");
            }
        }

    

        [TestMethod]
        public void ExecuteNonQuery_InvalidConnection_Failure()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                oTemp.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                const string strQuery = "SELECT COUNT(*) FORM vw_Subscriber";
                int iRet = oTemp.ExecuteNonQuery(strQuery, "junk");
                Assert.IsTrue(iRet == 0, "Call to ExecuteNonQuery from invalid connection should return 0");
                Assert.IsTrue(_errorRaised, "Call to ExecuteNonQuery from invalid connection should raise error");
            }
        }

        [TestMethod]
        public void GetCount_InvalidConnection_Failure()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                oTemp.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                const string strQuery = "SELECT COUNT(*) FROM tbl_user";
                int icount = oTemp.GetCount(strQuery);
                Assert.IsTrue(icount == 0, "Call to GetCount from Invalid Connection should return 0");
                Assert.IsTrue(_errorRaised, "Call to GetCount from Invalid Connection should raise error");
            }
        }

        [TestMethod]
        public void GetAliasOfObject_InvalidConnection()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                oTemp.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                string strAlias = oTemp.GetAliasOfObject("objectId");
                Assert.IsTrue(string.IsNullOrEmpty(strAlias), "Calling GetAliasOfObject with invalid connection should return blank string");
                Assert.IsTrue(_errorRaised, "Calling GetAliasOfObject with invalid Connection server should raise an error");
            }
        }

        [TestMethod]
        public void GetPrimaryDtmfAccessId_InvalidConnectionState()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                var res = oTemp.DatabaseFunctions.GetPrimaryDtmfAccessId("ObjectId");

                Assert.IsTrue(string.IsNullOrEmpty(res), "GetPrimaryDtmfAccessId call should fail with server in non connected state");
                Assert.IsTrue(_errorRaised, "GetPrimaryDtmfAccessId should raise an error when called in a non connected state");
            }
        }

        [TestMethod]
        public void GetMailstoresList_InvalidConnectionServer()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("test")))
            {
                oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                var oList = oTemp.DatabaseFunctions.GetMailstoresList();
                Assert.IsTrue(oList.Count == 0, "Calling GetMailstoresList with an invalid Connection should return 0");
                Assert.IsTrue(_errorRaised, "Calling GetMailstoresList with invalid Connection should raise an error");
            }
        }

        [TestMethod]
        public void GetSingleValueFromQuery_InvalidConnectionState()
        {
            using (UnityConnectionServerOdbc oTemp =
                    new UnityConnectionServerOdbc(new UnityConnectionDatabaseFunctionsInformixAdoNet("testing")))
            {
                oTemp.DatabaseFunctions.ErrorEvents += OnErrorEventHandler;
                _errorRaised = false;
                var res = oTemp.DatabaseFunctions.GetSingleValueFromQuery("select objectId from tbl_user", true, "noData");
                Assert.IsTrue(res.Equals(""), "GetSingleValueFromQuery call should return blank string with server in non connected state");
                Assert.IsTrue(_errorRaised, "GetSingleValueFromQuery should raise an error when called in a non connected state");
            }
        }

        [TestMethod]
        public void GetRemoteFileName_InvalidConnection()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                string strName = oTemp.GetRemoteFileName();
                Assert.IsTrue(string.IsNullOrEmpty(strName), "Remote file name generation with invalid Connection should return blank");
            }
        }


        [TestMethod]
        public void AddParameters_Bool()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                _errorRaised = false;
                const bool pBool = true;
                const string strSql = "SELECT COUNT(*) FROM vw_subscirber WHERE AutoAdvanceMsgs=?";
                oTemp.GetCount(strSql, pBool);
                Assert.IsFalse(_errorRaised,"Adding parrameter of type bool should not raise error");
            }
        }

        [TestMethod]
        public void AddParameters_Int()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                _errorRaised = false;
                const int pInt = 1;
                const string strSql = "SELECT COUNT(*) FROM vw_subscirber WHERE AutoAdvanceMsgs=?";
                oTemp.GetCount(strSql, pInt);
                Assert.IsFalse(_errorRaised, "Adding parrameter of type int should not raise error");
            }
        }

        [TestMethod]
        public void AddParameters_Date()
        {
            using (UnityConnectionDatabaseFunctionsInformixAdoNet oTemp =
                    new UnityConnectionDatabaseFunctionsInformixAdoNet("test"))
            {
                _errorRaised = false;
                DateTime pDate = DateTime.Now;
                const string strSql = "SELECT COUNT(*) FROM vw_greeting WHERE timeexpires>?";
                oTemp.GetCount(strSql, pDate);
                Assert.IsFalse(_errorRaised, "Adding parrameter of type int should not raise error");
            }
        }

        
        [TestMethod]
        public void GetActionDescription_InvalidAction()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 999, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("(error) invalid action id"),"Action Id of 999 not reported as error");
        }


        [TestMethod]
        public void GetActionDescription_IgnoreKey()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 0, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("ignore key"), "Action Id of 0 not reported as ignore key");
        }

        [TestMethod]
        public void GetActionDescription_HangUp()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 1, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("hang up"), "Action Id of 1 not reported as hangup");
        }
        [TestMethod]
        public void GetActionDescription_GotoErrorGreeting()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 3, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("goto error greeting"), "Action Id of 3 not reported as goto error greeting");
        }
        [TestMethod]
        public void GetActionDescription_TakeMessage()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 4, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("take message"), "Action Id of 4 not reported as Take Message");
        }
        [TestMethod]
        public void GetActionDescription_SkipGreeting()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 5, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("skip greeting"), "Action Id of 0 not reported as ignore key");
        }
        [TestMethod]
        public void GetActionDescription_RepeatGreeting()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 6, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("repeat greeting"), "Action Id of 6 not reported as repeat greeting");
        }
        [TestMethod]
        public void GetActionDescription_RouteFromNext()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 8, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("route from next call routing rule"), "Action Id of 8 not reported as route from next");
        }

        [TestMethod]
        public void GetActionDescription_AlternateTransferNumber()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 7, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("transfer to alternate contact number"), 
                "Action Id of 7 not reported as alternate transfer number");
        }

        [TestMethod]
        public void GetActionDescription_Goto_EmptyConversationName()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("(error)"),"Action Id of 2 with no conversation name not reported as error");
        }

        [TestMethod]
        public void GetActionDescription_Goto_InvalidConversationName()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("junk", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("(error)"), "Action Id of 2 with invalid conversation name not reported as error");
        }

        [TestMethod]
        public void GetActionDescription_Goto_SubSignIn()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("subsignin", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("user sign in"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_GreetingsAdministrator()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("greetingsadministrator", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("greetings administrator"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_ConvHotelCheckedOut()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("convhotelcheckedout", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("checked out hotel guest"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_ConvCvmMboxReset()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("convcvmmboxreset", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("community voice mail box reset"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_SubSystemTransfer()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("subsystransfer", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("user system transfer"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_SystemTransfer()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("systemtransfer", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("system transfer"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_EasySignIn()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("easysignin", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("easy subscriber sign in"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_TransferAlternateContactNumber()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("transferaltcontactnumber", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("alternate contact number"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_BroadcastMessageAdministrator()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("broadcastmessageadministrator", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("broadcast message administrator"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_Ad()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("ad", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_PhTransfer()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("PhTransfer", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_PhGreeting()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("PhGreeting", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetActionDescription_Goto_PhInterview()
        {
            string ret = _server.DatabaseFunctions.GetActionDescription("PhInterview", 2, "objectId", "MenuObjectId");
            Assert.IsTrue(ret.ToLower().Contains("invalid link"), "Correct goto conversation not recognized");
        }

        [TestMethod]
        public void GetObjectDescription_Handler_Missing()
        {
            string ret = _server.DatabaseFunctions.GetObjectDescription("junk", ObjectsTypesWithExtensions.Handler);
            Assert.IsTrue(ret.Contains("[Unknown Handler Type]"));
        }

        [TestMethod]
        public void GetObjectDescription_Location_InvalidType()
        {
            string ret = _server.DatabaseFunctions.GetObjectDescription("Junk", (ObjectsTypesWithExtensions)99);
            Assert.IsTrue(ret.Contains("(error)"));
        }

        [TestMethod]
        public void GetObjectDescription_Contact_NoMatch()
        {
            string ret = _server.DatabaseFunctions.GetObjectDescription("Junk", ObjectsTypesWithExtensions.Contact);
            Assert.IsTrue(ret.Contains("(error)"));
        }

    }
}

Commits for ConnectionOdbcSdk/trunk/ConnectionServerOdbcIntegrationTests/UnitTests/ConnectionInformixAdoNetDatabaseFunctionUnitTests.cs

Diff revisions: vs.
Revision Author Commited Message
19 Diff Diff jlindborg picture jlindborg Mon 06 Jan, 2014 22:26:38 +0000

renaming and reorganizing unit tests a bit.

13 Diff Diff jlindborg picture jlindborg Fri 06 Sep, 2013 02:57:55 +0000

More unit test work and related bug fixing.

12 jlindborg picture jlindborg Thu 05 Sep, 2013 01:56:48 +0000

more unit test work.