public void TestEncode()
        {
            MutableAVState state = new MutableAVState {
            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, AVPushEncoder.Instance.Encode(state));
        }
Beispiel #2
0
        public IAVState MutatedClone(Action <MutableAVState> func)
        {
            MutableAVState clone = MutableClone();

            func(clone);
            return(clone);
        }
        public void TestMutatedClone()
        {
            MutableAVState state = new MutableAVState();

              IAVState mutated = state.MutatedClone(s => {
            s.Alert = "test";
              });

              Assert.AreEqual(null, state.Alert);
              Assert.AreEqual("test", mutated.Alert);
        }
        public void TestEncodeEmpty()
        {
            MutableAVState state = new MutableAVState();

              Assert.Throws<InvalidOperationException>(() => AVPushEncoder.Instance.Encode(state));
              state.Alert = "alert";

              Assert.Throws<InvalidOperationException>(() => AVPushEncoder.Instance.Encode(state));
              state.Channels = new List<string> { { "channel" } };

              Assert.DoesNotThrow(() => AVPushEncoder.Instance.Encode(state));
        }
        public void TestEquals()
        {
            MutableAVState state = new MutableAVState {
            Alert = "test"
              };

              MutableAVState otherState = new MutableAVState {
            Alert = "test"
              };

              Assert.AreNotEqual(null, state);
              Assert.AreNotEqual("test", state);

              Assert.AreEqual(state, otherState);
        }
        public Task TestSendPush()
        {
            MutableAVState state = new MutableAVState {
            Query = AVInstallation.Query
              };

              AVPush thePush = new AVPush();
              AVPushPlugins.Instance = new AVPushPlugins {
            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);

            AVQuery<AVInstallation> query = new AVQuery<AVInstallation>("aClass");
            thePush.Query = query;
            state.Query = query;

            return thePush.SendAsync();
              }).Unwrap().ContinueWith(t => {
            Assert.True(t.IsCompleted);
            Assert.False(t.IsFaulted);
              });
        }