-
-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathPushEncoderTests.cs
55 lines (47 loc) · 1.56 KB
/
PushEncoderTests.cs
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
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Parse.Platform.Push;
namespace Parse.Tests;
[TestClass]
public class PushEncoderTests
{
[TestMethod]
public void TestEncodeEmpty()
{
MutablePushState state = new MutablePushState();
Assert.ThrowsException<InvalidOperationException>(() => ParsePushEncoder.Instance.Encode(state));
state.Alert = "alert";
Assert.ThrowsException<InvalidOperationException>(() => ParsePushEncoder.Instance.Encode(state));
state.Channels = new List<string> { "channel" };
ParsePushEncoder.Instance.Encode(state);
}
[TestMethod]
public void TestEncode()
{
MutablePushState state = new MutablePushState
{
Data = new Dictionary<string, object>
{
["alert"] = "Some Alert"
},
Channels = new List<string> { "channel" }
};
IDictionary<string, object> expected = new Dictionary<string, object>
{
["data"] = new Dictionary<string, object>
{
["alert"] = "Some Alert"
},
["where"] = new Dictionary<string, object>
{
["channels"] = new Dictionary<string, object>
{
["$in"] = new List<string> { "channel" }
}
}
};
Assert.AreEqual(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(ParsePushEncoder.Instance.Encode(state)));
}
}