/// <summary> /// Creates a new instance of the <see cref="TwitterApiException"/> class. /// </summary> /// <param name="info"> /// The <see cref="System.Runtime.Serialization.SerializationInfo"/> /// that holds the serialized object data about the exception being thrown. /// </param> /// <param name="context"> /// The <see cref="System.Runtime.Serialization.StreamingContext"/> /// that contains contextual information about the source or destination. /// </param> protected TwitterApiException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info != null) { this.error = (TwitterApiError)info.GetValue("Error", typeof(TwitterApiError)); } }
public void BinarySerialization() { string message = "Error message"; TwitterApiError error = TwitterApiError.RateLimitExceeded; TwitterApiException exBefore = new TwitterApiException(message, error); TwitterApiException exAfter = SerializationTestUtils.BinarySerializeAndDeserialize(exBefore) as TwitterApiException; Assert.IsNotNull(exAfter); Assert.AreEqual(message, exAfter.Message, "Invalid message"); Assert.AreEqual(error, exAfter.Error, "Invalid error"); }
public TwitterApiResponse(T content, TwitterApiError error) { Content = content; Error = error; }
protected void AssertTwitterApiException(AggregateException ae, string expectedMessage, TwitterApiError error) { ae.Handle(ex => { if (ex is TwitterApiException) { Assert.AreEqual(expectedMessage, ex.Message); Assert.AreEqual(error, ((TwitterApiException)ex).Error); return true; } return false; }); }
protected void AssertTwitterApiException(Exception ex, string expectedMessage, TwitterApiError error) { if (ex is TwitterApiException) { Assert.AreEqual(expectedMessage, ex.Message); Assert.AreEqual(error, ((TwitterApiException)ex).Error); } else { Assert.Fail("TwitterApiException expected"); } }
/// <summary> /// Creates a new instance of the <see cref="TwitterApiException"/> class. /// </summary> /// <param name="message">A message about the exception.</param> /// <param name="innerException">The inner exception that is the cause of the current exception.</param> public TwitterApiException(string message, Exception innerException) : base(message, innerException) { this.error = TwitterApiError.Unknown; }
/// <summary> /// Creates a new instance of the <see cref="TwitterApiException"/> class. /// </summary> /// <param name="message">A message about the exception.</param> /// <param name="error">The Twitter error.</param> public TwitterApiException(string message, TwitterApiError error) : base(message) { this.error = error; }
protected void AssertTwitterApiException(AggregateException ae, string expectedMessage, TwitterApiError error) { ae.Handle(ex => { if (ex is TwitterApiException) { Assert.AreEqual(expectedMessage, ex.Message); Assert.AreEqual(error, ((TwitterApiException)ex).Error); return(true); } return(false); }); }