Exemplo n.º 1
0
    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);
      });
    }
Exemplo n.º 2
0
        public IPushState MutatedClone(Action <MutablePushState> func)
        {
            MutablePushState clone = MutableClone();

            func(clone);
            return(clone);
        }
Exemplo n.º 3
0
    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));
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    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));
    }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
    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);
    }