コード例 #1
0
ファイル: PushTests.cs プロジェクト: dragouf/Parse-SDK-dotNET
    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);
      });
    }
コード例 #2
0
        public IPushState MutatedClone(Action <MutablePushState> func)
        {
            MutablePushState clone = MutableClone();

            func(clone);
            return(clone);
        }
コード例 #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));
    }
コード例 #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);
    }
コード例 #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));
    }
コード例 #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));
        }
コード例 #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);
    }