File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Runtime . Serialization ;
23using Newtonsoft . Json . Linq ;
34using System . Collections . Generic ;
45using PushSharp . Core ;
@@ -139,7 +140,7 @@ public bool IsDeviceRegistrationIdValid ()
139140 /// Corresponds to iOS APNS priorities (Normal is 5 and high is 10). Default is Normal.
140141 /// </summary>
141142 /// <value>The priority.</value>
142- [ JsonProperty ( "priority" ) ]
143+ [ JsonProperty ( "priority" ) , JsonConverter ( typeof ( Newtonsoft . Json . Converters . StringEnumConverter ) ) ]
143144 public GcmNotificationPriority ? Priority { get ; set ; }
144145
145146 internal string GetJson ( )
@@ -163,7 +164,9 @@ public override string ToString ()
163164
164165 public enum GcmNotificationPriority
165166 {
167+ [ EnumMember ( Value = "normal" ) ]
166168 Normal = 5 ,
169+ [ EnumMember ( Value = "high" ) ]
167170 High = 10
168171 }
169172}
Original file line number Diff line number Diff line change 1+ using System ;
2+ using NUnit . Framework ;
3+ using PushSharp . Google ;
4+ using System . Collections . Generic ;
5+ using Newtonsoft . Json . Linq ;
6+
7+ namespace PushSharp . Tests
8+ {
9+ [ Category ( "GCM" ) ]
10+ [ TestFixture ]
11+ public class GcmTests
12+ {
13+ [ Test ]
14+ public void GcmNotification_Priority_Should_Serialize_As_String_High ( )
15+ {
16+ var n = new GcmNotification ( ) ;
17+ n . Priority = GcmNotificationPriority . High ;
18+
19+ var str = n . ToString ( ) ;
20+
21+ Assert . IsTrue ( str . Contains ( "high" ) ) ;
22+ }
23+
24+ [ Test ]
25+ public void GcmNotification_Priority_Should_Serialize_As_String_Normal ( )
26+ {
27+ var n = new GcmNotification ( ) ;
28+ n . Priority = GcmNotificationPriority . Normal ;
29+
30+ var str = n . ToString ( ) ;
31+
32+ Assert . IsTrue ( str . Contains ( "normal" ) ) ;
33+ }
34+ }
35+ }
36+
Original file line number Diff line number Diff line change 4848 <Compile Include =" BrokerTests.cs" />
4949 <Compile Include =" ApnsRealTest.cs" />
5050 <Compile Include =" WnsRealTests.cs" />
51+ <Compile Include =" GcmTests.cs" />
5152 </ItemGroup >
5253 <Import Project =" $(MSBuildBinPath)\Microsoft.CSharp.targets" />
5354 <ItemGroup >
You can’t perform that action at this time.
0 commit comments