public void UpdateFromJsonTest2() { var status = new TwitterApiStatus(); var eventCalled = false; status.AccessLimitUpdated += (s, e) => eventCalled = true; var json = "INVALID JSON"; Assert.Throws <XmlException>(() => status.UpdateFromJson(json)); var rateLimit = status.AccessLimit["/statuses/home_timeline"]; Assert.Null(rateLimit); Assert.False(eventCalled); }
public void UpdateFromJsonTest() { var status = new TwitterApiStatus(); var json = "{\"resources\":{\"statuses\":{\"/statuses/home_timeline\":{\"limit\":150,\"remaining\":100,\"reset\":1356998400}}}}"; Assert.Raises <TwitterApiStatus.AccessLimitUpdatedEventArgs>( x => status.AccessLimitUpdated += x, x => status.AccessLimitUpdated -= x, () => status.UpdateFromJson(TwitterRateLimits.ParseJson(json)) ); var rateLimit = status.AccessLimit["/statuses/home_timeline"]; Assert.Equal(150, rateLimit.AccessLimitCount); Assert.Equal(100, rateLimit.AccessLimitRemain); Assert.Equal(new DateTimeUtc(2013, 1, 1, 0, 0, 0), rateLimit.AccessLimitResetDate); }
public void UpdateFromJsonTest() { var status = new TwitterApiStatus(); var eventCalled = false; status.AccessLimitUpdated += (s, e) => eventCalled = true; var json = "{\"resources\":{\"statuses\":{\"/statuses/home_timeline\":{\"limit\":150,\"remaining\":100,\"reset\":1356998400}}}}"; status.UpdateFromJson(json); var rateLimit = status.AccessLimit["/statuses/home_timeline"]; Assert.Equal(150, rateLimit.AccessLimitCount); Assert.Equal(100, rateLimit.AccessLimitRemain); Assert.Equal(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(), rateLimit.AccessLimitResetDate); Assert.True(eventCalled); }
public void UpdateFromJsonTest2() { var status = new TwitterApiStatus(); var eventCalled = false; status.AccessLimitUpdated += (s, e) => eventCalled = true; var json = "INVALID JSON"; Assert.That(() => status.UpdateFromJson(json), Throws.TypeOf<XmlException>()); var rateLimit = status.AccessLimit["/statuses/home_timeline"]; Assert.That(rateLimit, Is.Null); Assert.That(eventCalled, Is.False); }
public void UpdateFromJsonTest() { var status = new TwitterApiStatus(); var eventCalled = false; status.AccessLimitUpdated += (s, e) => eventCalled = true; var json = "{\"resources\":{\"statuses\":{\"/statuses/home_timeline\":{\"limit\":150,\"remaining\":100,\"reset\":1356998400}}}}"; status.UpdateFromJson(json); var rateLimit = status.AccessLimit["/statuses/home_timeline"]; Assert.That(rateLimit.AccessLimitCount, Is.EqualTo(150)); Assert.That(rateLimit.AccessLimitRemain, Is.EqualTo(100)); Assert.That(rateLimit.AccessLimitResetDate, Is.EqualTo(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime())); Assert.That(eventCalled, Is.True); }