public async Task TestMarkReadByIds() { var newActivity = new Stream.Activity("1", "tweet", "1"); var first = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "run", "2"); var second = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "share", "3"); var third = await _not5.AddActivity(newActivity); Thread.Sleep(AddDelay * 3); var activities = await _not5.GetActivities(0, 2); var marker = ActivityMarker.Mark(); foreach (var activity in activities) { marker = marker.Read(activity.Id); } var notActivity = activities.First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); notActivity = activities.Skip(1).First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); activities = await _not5.GetActivities(0, 3, marker : marker); Thread.Sleep(MarkDelay); activities = await _not5.GetActivities(0, 3); Assert.IsNotNull(activities); Assert.AreEqual(3, activities.Count()); notActivity = activities.First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); notActivity = activities.Skip(1).First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); notActivity = activities.Skip(2).First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); }
public async Task TestMarkRead() { var newActivity = new Stream.Activity("1", "tweet", "1"); var first = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "run", "2"); var second = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "share", "3"); var third = await _not5.AddActivity(newActivity); var activities = await _not5.GetActivities(0, 2, marker : ActivityMarker.Mark().AllRead()); Assert.IsNotNull(activities); Assert.AreEqual(2, activities.Count()); var notActivity = activities.First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); notActivity = activities.Skip(1).First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); activities = await _not5.GetActivities(0, 2); Assert.IsNotNull(activities); Assert.AreEqual(2, activities.Count()); notActivity = activities.First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); notActivity = activities.Skip(1).First() as NotificationActivity; Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); }
public async Task TestMarkNotificationsRead() { var newActivity = new Stream.Activity("1", "tweet", "1"); var first = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "run", "2"); var second = await _not5.AddActivity(newActivity); newActivity = new Stream.Activity("1", "share", "3"); var third = await _not5.AddActivity(newActivity); Thread.Sleep(AddDelay * 3); var response = await _not5.GetNotificationActivities(GetOptions.Default.WithLimit(2).WithMarker(ActivityMarker.Mark().AllRead())); Assert.IsNotNull(response); var activities = response.Results; Assert.IsNotNull(activities); Assert.AreEqual(2, activities.Count()); var notActivity = activities.First(); Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); notActivity = activities.Skip(1).First(); Assert.IsNotNull(notActivity); Assert.IsFalse(notActivity.IsRead); Thread.Sleep(MarkDelay); response = await _not5.GetNotificationActivities(GetOptions.Default.WithLimit(2)); Assert.IsNotNull(response); Assert.AreEqual(0, response.Unread); activities = response.Results; Assert.IsNotNull(activities); Assert.AreEqual(2, activities.Count()); notActivity = activities.First(); Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); notActivity = activities.Skip(1).First(); Assert.IsNotNull(notActivity); Assert.IsTrue(notActivity.IsRead); }