Merge "Adding Null Check and Error Enum Updation" into devel
[platform/core/csapi/push.git] / tct-push-tizen-tests / src / Testcase / TSPush.cs
1 using System;
2 using System.Linq;
3 using System.Reflection;
4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Threading;
7 using System.Threading.Tasks;
8 using System.Runtime.CompilerServices;
9 using System.Diagnostics;
10 using TestFramework;
11 using Tizen;
12 using Tizen.Applications;
13 using Tizen.UI;
14 using Tizen.Messaging.Push;
15 using System.Collections.ObjectModel;
16 using System.Collections.Specialized;
17 using System.Runtime.InteropServices;
18
19
20 namespace TizenTest.PushT {
21
22     [TestFixture]
23     [Description("Tizen.Messaging.Push Tests")]
24     public class PushTest {
25
26                 private static string appID = "7c58a4ac98388bba";
27         private static string TAG = "TCT";
28         private static string _message;
29
30         [SetUp]
31         public static void Init() {
32         //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
33         }
34
35         [TearDown]
36         public static void Destroy() {
37         //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
38         }
39
40         [Test]
41         [Category("P1")]
42         [Description("Return Type of PushServiceConnect ...")]
43         [Property("SPEC", " Tizen.Messaging.Push.PushServiceConnect M")]
44         [Property("SPEC_URL", "-")]
45         [Property("CRITERIA", "MR")]
46         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
47         public static void PushServiceConnect_RETURN_VALUE() {
48                 /* TEST CODE */
49                 try
50                 {
51                         Tizen.Log.Info(TAG,"Executing TC:PushServiceConnect_RETURN_VALUE");
52                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceConnect_RETURN_VALUE");
53                         Push.PushServiceConnect(appID);
54                         Assert.Pass();
55                 }
56                 catch(Exception e)
57                 {
58                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
59                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
60                         Assert.Fail();
61                 }               
62         }
63
64         [Test]
65         [Category("P1")]
66         [Description("Return Type of PushServiceDisconnect ...")]
67         [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
68         [Property("SPEC_URL", "-")]
69         [Property("CRITERIA", "MR")]
70         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
71         public static void PushServiceDisconnect_RETURN_VALUE() {
72                 /** PRECONDITION
73                 * 1. Connect to Push Service
74                 */
75                 Push.PushServiceConnect(appID);
76
77                 /* TEST CODE */
78                 try
79                 {
80                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE");
81                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE");
82                         Push.PushServiceDisconnect();
83                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
84                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
85                         Assert.Pass();
86                 }
87                 catch(Exception e)
88                 {
89                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
90                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
91                         Assert.Fail();
92                 }
93         }
94
95         [Test]
96         [Category("P1")]
97         [Description("Calling Multiple PushServiceConnect PushServiceDisconnect ...")]
98         [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
99         [Property("SPEC_URL", "-")]
100         [Property("CRITERIA", "MR")]
101         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
102         public static void PushServiceConnect_PushServiceDisconnect_RETURN_VALUE() {
103                 /** PRECONDITION
104                 * 1. Connect to Push Service
105                 */
106                 
107
108                 /* TEST CODE */
109                 try
110                 {
111                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE");
112                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE");
113                         for(int i=0;i<4;i++){
114                         Push.PushServiceConnect(appID);
115                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE after Connect");
116                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE after Connect");
117                         Push.PushServiceDisconnect();
118                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE after Disconnect");
119                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE after Disconnect");}
120                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
121                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
122                         Assert.Pass();
123                 }
124                 catch(Exception e)
125                 {
126                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
127                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
128                         Assert.Fail();
129                 }
130         }
131
132         [Test]
133         [Category("P1")]
134         [Description("Calling PushServiceDisconnect Multiple times...")]
135         [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
136         [Property("SPEC_URL", "-")]
137         [Property("CRITERIA", "MR")]
138         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
139         public static void PushServiceDisconnect_MULTIPLE() {
140                 /** PRECONDITION
141                 * 1. Connect to Push Service
142                 */
143                 
144
145                 /* TEST CODE */
146                 try
147                 {
148                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE");
149                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE");
150                         for(int i=0;i<4;i++){
151                         Push.PushServiceConnect(appID);
152                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Connect");
153                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Connect");
154                         Push.PushServiceDisconnect();
155                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
156                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");}
157                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE completed");
158                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE completed");
159                         Push.PushServiceDisconnect();
160                         Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
161                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
162                         Assert.Pass();
163                 }
164                 catch(Exception e)
165                 {
166                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
167                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
168                         Assert.Fail();
169                 }
170         }
171
172         [Test]
173         [Category("P1")]
174         [Description("Return Type of PushServerRegister ...")]
175         [Property("SPEC", " Tizen.Messaging.Push.PushServerRegister M")]
176         [Property("SPEC_URL", "-")]
177         [Property("CRITERIA", "MR")]
178         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
179         public static async Task PushServerRegister_RETURN_VALUE() {
180                 /** PRECONDITION
181                 * 1. Connect to Push Service
182                 */
183                 Push.PushServiceConnect(appID);
184
185                 /* TEST CODE */
186                 try
187                 {
188                         Tizen.Log.Info(TAG,"Executing TC:PushServerRegister_RETURN_VALUE");
189                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE");
190                         ServerResponse res = await Push.PushServerRegister();
191                         await Task.Delay(5000);
192                         Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
193                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
194                         Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
195                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
196                         Assert.Pass();
197                 }
198                 catch(Exception e)
199                 {
200                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
201                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
202                         Assert.Fail();
203                 }
204
205                 /** POSTCONDITION
206                 * 1. Disconnect from Push Service
207                 */
208                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE before disconnect");
209                 Push.PushServiceDisconnect();
210                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE after disconnect");
211         }
212
213         [Test]
214         [Category("P1")]
215         [Description("Return Type of PushServerUnregister ...")]
216         [Property("SPEC", " Tizen.Messaging.Push.PushServerUnregister M")]
217         [Property("SPEC_URL", "-")]
218         [Property("CRITERIA", "MR")]
219         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
220         public static async Task PushServerUnregister_RETURN_VALUE() {
221                 /** PRECONDITION
222                 * 1. Connect to Push Service
223                 * 2. Register with Push Service
224                 */
225                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerUnregister_RETURN_VALUE before connect");
226                 Push.PushServiceConnect(appID);
227                 ServerResponse res = await Push.PushServerRegister();
228                 await Task.Delay(5000);
229                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
230                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
231                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
232                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
233                 Tizen.Log.Info(TAG,"Executing TC:PushServerRegister_RETURN_VALUE before pass");
234
235                 /* TEST CODE */
236                 try
237                 {
238                         ServerResponse resUnreg = await Push.PushServerUnregister();
239                         await Task.Delay(5000);
240                         Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
241                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
242                         Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
243                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
244                         Assert.Pass();
245                 }
246                 catch(Exception e)
247                 {
248                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
249                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
250                         Assert.Fail();
251                 }
252
253                 /** POSTCONDITION
254                 * 1. Disconnect from Push Service
255                 */
256                 Push.PushServiceDisconnect();
257         }
258
259         [Test]
260         [Category("P1")]
261         [Description("Return Type of GetRegistrationId ...")]
262         [Property("SPEC", " Tizen.Messaging.Push.GetRegistrationId M")]
263         [Property("SPEC_URL", "-")]
264         [Property("CRITERIA", "MR")]
265         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
266         public static async Task GetRegistrationId_RETURN_VALUE() {
267                 /** PRECONDITION
268                 * 1. Connect to Push Service
269                 * 2. Register with Push Service
270                 */
271                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE before connect");
272                 Push.PushServiceConnect(appID);
273                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE after connect");
274                 ServerResponse resReg = await Push.PushServerRegister();
275                 await Task.Delay(5000);
276                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
277                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
278                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
279                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
280
281                 /* TEST CODE */
282                 try
283                 {
284                         Tizen.Log.Info(TAG,"Executing TC:GetRegistrationId_RETURN_VALUE");
285                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE");
286                         string id = Push.GetRegistrationId();
287                         Tizen.Log.Info(TAG,"Executing TC:GetRegistrationId_RETURN_VALUE Reg Id: "+id);
288                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE Reg Id: "+id);
289                         if(id == null)
290                         {
291                                 Assert.Fail();
292                         }
293                         else
294                         {
295                                 Assert.Pass();
296                         }
297                 }
298                 catch(Exception e)
299                 {
300                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
301                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
302                         Assert.Fail();
303                 }
304
305                 /** POSTCONDITION
306                 * 1. Unregister from Push Service
307                 * 2. Disconnect from Push Service
308                 */              
309                 ServerResponse resUnreg = await Push.PushServerUnregister();
310                 await Task.Delay(5000);
311                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
312                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
313                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
314                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
315                 Push.PushServiceDisconnect();           
316         }
317
318         [Test]
319         [Category("P1")]
320         [Description("Return Type of GetUnreadNotifications ...")]
321         [Property("SPEC", " Tizen.Messaging.Push.GetUnreadNotifications M")]
322         [Property("SPEC_URL", "-")]
323         [Property("CRITERIA", "MR")]
324         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
325         public static async Task GetUnreadNotifications_RETURN_VALUE() {
326                 /** PRECONDITION
327                 * 1. Connect to Push Service
328                 * 2. Register with Push Service
329                 */
330                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetUnreadNotifications_RETURN_VALUE before connect");
331                 Push.PushServiceConnect(appID);
332                 ServerResponse resReg = await Push.PushServerRegister();
333                 await Task.Delay(5000);
334                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
335                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
336                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
337                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
338
339                 /* TEST CODE */
340                 try
341                 {
342                         Tizen.Log.Info(TAG,"Executing TC:GetUnreadNotifications_RETURN_VALUE");
343                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetUnreadNotifications_RETURN_VALUE");
344                         Push.GetUnreadNotifications();
345                         Assert.Pass();
346                 }
347                 catch(Exception e)
348                 {
349                         Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
350                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
351                         Assert.Fail();
352                 }
353
354                 /** POSTCONDITION
355                 * 1. Unregister from Push Service
356                 * 2. Disconnect from Push Service
357                 */              
358                 ServerResponse resUnreg = await Push.PushServerUnregister();
359                 await Task.Delay(5000);
360                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
361                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
362                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
363                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
364                 Push.PushServiceDisconnect();
365         }
366
367                 [Test]
368                 [Category("P1")]
369                 [Description("Getting NotificationReceived Event ...")]
370                 [Property("SPEC", " Tizen.Messaging.Push.NotificationReceived E")]
371                 [Property("SPEC_URL", "-")]
372                 [Property("CRITERIA", "EVL")]
373                 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
374                 public static async Task NotificationReceived_EVENT() {
375                         /** PRECONDITION
376                         * 1. Connect to Push Service
377                         * 2. Register with Push Service
378                         */
379                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT before connect");
380                         Push.PushServiceConnect(appID);
381                         ServerResponse resReg = await Push.PushServerRegister();
382                         await Task.Delay(5000);
383                         Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
384                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
385                         Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
386                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
387
388                         /* TEST CODE */
389                         try
390                         {
391                                 bool caught = false;
392                                 EventHandler<PushMessageEventArgs> handler = (object sender, PushMessageEventArgs e) =>
393                                 {
394                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event AppData"+e.AppData);
395                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Message"+e.Message);
396                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event ReceivedAt"+e.ReceivedAt);
397                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Sender"+e.Sender);
398                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event SessionInfo"+e.SessionInfo);
399                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event RequestID"+e.RequestId);
400                                         Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Type"+e.Type);
401                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event AppData"+e.AppData);
402                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Message"+e.Message);
403                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event ReceivedAt"+e.ReceivedAt);
404                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Sender"+e.Sender);
405                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event SessionInfo"+e.SessionInfo);
406                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event RequestID"+e.RequestId);
407                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Type"+e.Type);
408                                         caught = true;
409                                 };
410                                 Push.NotificationReceived += handler;
411                                 Tizen.Log.Info(TAG,"Executing TC:NotificationReceived_EVENT");
412                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT");
413                                 Push.GetUnreadNotifications();
414                                 Tizen.Log.Info(TAG,"Executing TC:NotificationReceived_EVENT Waiting ................");
415                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT Waiting ................");
416                                 await Task.Delay(10000);
417                                 Assert.True(caught, "Did not recieve NotificationReceived Event");              
418                         }
419                         catch(Exception e)
420                         {
421                                 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
422                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
423                                 Assert.Fail();
424                         }
425
426                         /** POSTCONDITION
427                         * 1. Unregister from Push Service
428                         * 2. Disconnect from Push Service
429                         */              
430                         ServerResponse resUnreg = await Push.PushServerUnregister();
431                         await Task.Delay(5000);
432                         Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
433                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
434                         Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
435                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
436                         Push.PushServiceDisconnect();
437                 }
438
439                 [Test]
440         [Category("P1")]
441         [Description("Getting StateChanged Event ...")]
442         [Property("SPEC", " Tizen.Messaging.Push.StateChanged E")]
443         [Property("SPEC_URL", "-")]
444         [Property("CRITERIA", "EVL")]
445         [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
446         public static async Task StateChanged_EVENT() {
447                         /** PRECONDITION
448                         * 1. Connect to Push Service
449                         */
450                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT before connect");
451                         Push.PushServiceConnect(appID);
452                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT after connect");
453
454
455                         /* TEST CODE 
456                         * 1. Register StateChanged Event
457                         * 2. Register with Push Service
458                         */
459                         try
460                         {
461                                 bool caught = false;
462                                 EventHandler<PushConnectionStateEventArgs> handler = (object sender, PushConnectionStateEventArgs e) =>
463                                 {
464                                         Tizen.Log.Info(TAG, "Executing TC:StateChanged_EVENT got event"+e.State);
465                                         Tizen.Log.Info(TAG, "Executing TC:StateChanged_EVENT got event"+e.Error);
466                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT got event"+e.State);
467                                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT got event"+e.Error);
468                                         caught = true;
469                                 };
470                                 Push.StateChanged += handler;
471                                 ServerResponse res = await Push.PushServerRegister();
472                                 await Task.Delay(5000);
473                                 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
474                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
475                                 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
476                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
477                                 Assert.True(caught, "Did not recieve StateChanged Event");
478                         }
479                         catch(Exception e)
480                         {
481                                 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
482                                 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
483                                 Assert.Fail();
484                         }
485
486                         /** POSTCONDITION
487                         * 1. Unregister from Push Service
488                         * 2. Disconnect from Push Service
489                         */              
490                         ServerResponse resUnreg = await Push.PushServerUnregister();
491                         await Task.Delay(5000);
492                         Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
493                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
494                         Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
495                         LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
496                         Push.PushServiceDisconnect();
497         }
498         }
499 }