public Task TestSendPush() { MutablePushState state = new MutablePushState { Query = ParseInstallation.Query }; ParsePush thePush = new ParsePush(); ParsePushPlugins.Instance = new ParsePushPlugins { PushController = GetMockedPushController(state) }; thePush.Alert = "Alert"; state.Alert = "Alert"; return thePush.SendAsync().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); thePush.Channels = new List<string> { { "channel" } }; state.Channels = new List<string> { { "channel" } }; return thePush.SendAsync(); }).Unwrap().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); ParseQuery<ParseInstallation> query = new ParseQuery<ParseInstallation>("aClass"); thePush.Query = query; state.Query = query; return thePush.SendAsync(); }).Unwrap().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); }); }
public IPushState MutatedClone(Action <MutablePushState> func) { MutablePushState clone = MutableClone(); func(clone); return(clone); }
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(expected, ParsePushEncoder.Instance.Encode(state)); }
public void TestMutatedClone() { MutablePushState state = new MutablePushState(); IPushState mutated = state.MutatedClone(s => { s.Alert = "test"; }); Assert.AreEqual(null, state.Alert); Assert.AreEqual("test", mutated.Alert); }
public void TestEncodeEmpty() { MutablePushState state = new MutablePushState(); Assert.Throws<InvalidOperationException>(() => ParsePushEncoder.Instance.Encode(state)); state.Alert = "alert"; Assert.Throws<InvalidOperationException>(() => ParsePushEncoder.Instance.Encode(state)); state.Channels = new List<string> { { "channel" } }; Assert.DoesNotThrow(() => ParsePushEncoder.Instance.Encode(state)); }
public override bool Equals(object obj) { if (obj is null || !(obj is MutablePushState)) { return(false); } MutablePushState other = obj as MutablePushState; return(Equals(Query, other.Query) && Channels.CollectionsEqual(other.Channels) && Equals(Expiration, other.Expiration) && Equals(ExpirationInterval, other.ExpirationInterval) && Equals(PushTime, other.PushTime) && Data.CollectionsEqual(other.Data) && Equals(Alert, other.Alert)); }
public void TestEquals() { MutablePushState state = new MutablePushState { Alert = "test" }; MutablePushState otherState = new MutablePushState { Alert = "test" }; Assert.AreNotEqual(null, state); Assert.AreNotEqual("test", state); Assert.AreEqual(state, otherState); }