Пример #1
0
        public async Task PushWithDefaultKey_ReturnsSuccessful()
        {
            //  Arrange
            string title = "Test title";
            string text  = "This is a test push notification message";

            //  Act
            Pushover pclient = new Pushover(TEST_APP_KEY, TEST_USER_KEY);
            var      message = new PushoverMessage()
            {
                Title = title, Text = text
            };
            PushoverResponse response = await pclient.SendPushAsync(message);

            //  Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Status);
        }
Пример #2
0
        public async Task PushWithNoKey_ReturnsError()
        {
            //  Arrange
            string title = "Test title";
            string text  = "This is a test push notification message";

            //  Act
            Pushover pclient = new Pushover(TEST_APP_KEY);
            var      message = new PushoverMessage()
            {
                Title = title, Text = text
            };

            PushoverResponse response = await pclient.SendPushAsync(message);

            //  Assert - above code should error before this
            Assert.Fail();
        }
Пример #3
0
        public void PushWithValidParms_ReturnsSuccessful()
        {
            //  Arrange
            string title = "Test title";
            string text  = "This is a test push notification message";

            //  Act
            Pushover pclient = new Pushover(TEST_APP_KEY);
            var      message = new PushoverMessage()
            {
                Title = title, Text = text
            };

            message.Recipients.Add(TEST_USER_KEY);
            PushoverResponse response = pclient.SendPush(message);

            //  Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Status);
        }
Пример #4
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            System.ServiceModel.ServiceHost _hostApplication = new System.ServiceModel.ServiceHost(typeof(SoftFluent.Presence.Service.PresenceRestService));
            _hostApplication.Open();

            PushoverClient client = new PushoverClient();

            client.SendNotification("first message");

            PushoverRequest request = PushoverRequest.CreateRequest("Test", "Presence", PushoverPriorityNotificationType.LowPriority, "Tel_Softfluent");

            //PushoverRequest request = PushoverRequest.CreateRequest("Test", null, 30, 120, PushoverPriorityNotificationType.EmergencyPriority, "Tel_Softfluent");
            //request.TimeStamp = new DateTime(2016, 1, 31, 10, 5, 0);

            PushoverResponse response = client.SendNotification(request);

            if (response != null && response.Status == 1)
            {
                //OK
                client.CancelEmergency("");
            }
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateLimitExceededException"/> class with a reference to the
 /// <see cref="PushoverResponse"/> and a reference to the inner exception that are the cause of this exception.
 /// </summary>
 /// <param name="response">The <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 /// <param name="innerException">
 /// The exception that is the cause of the current exception, or a null reference if no inner exception.
 /// </param>
 public RateLimitExceededException(PushoverResponse response, Exception innerException)
     : base("Rate limit exceeded", response, innerException)
 {
     this.RateLimitInfo = response.RateLimitInfo;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RateLimitExceededException"/> class with a reference to the
 /// <see cref="PushoverResponse"/> a that is the cause of this exception.
 /// </summary>
 /// <param name="response">The <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 public RateLimitExceededException(PushoverResponse response)
     : this(response, null)
 {
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResponseException"/> class with a specified error message,
 /// a reference to the <see cref="PushoverResponse"/> and a reference to the inner exception that are the cause
 /// of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="response">The  <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 /// <param name="innerException">
 /// The exception that is the cause of the current exception, or a null reference if no inner exception.
 /// </param>
 public ResponseException(string message, PushoverResponse response, Exception innerException)
     : base(message, innerException)
 {
     this.Response = response;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResponseException"/> class with a specified error message and
 /// a reference to the <see cref="PushoverResponse"/> that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="response">The  <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 public ResponseException(string message, PushoverResponse response)
     : this(message, response, null)
 {
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BadRequestException"/> class with a reference to the
 /// <see cref="PushoverResponse"/> and a reference to the inner exception that are the cause of this exception.
 /// </summary>
 /// <param name="response">The <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 /// <param name="innerException">
 /// The exception that is the cause of the current exception, or a null reference if no inner exception.
 /// </param>
 public BadRequestException(PushoverResponse response, Exception innerException)
     : base("Bad request", response, innerException)
 {
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BadRequestException"/> class with a reference to the
 /// <see cref="PushoverResponse"/> a that is the cause of this exception.
 /// </summary>
 /// <param name="response">The <see cref="PushoverResponse"/> that is the cause for the exception.</param>
 public BadRequestException(PushoverResponse response)
     : this(response, null)
 {
 }