public void BadgeAwardedActivityGet() { const string guidStr = "515b7240-3be1-43d4-8846-c0b589cd1cd2"; const string guidStrUser = "******"; var timestamp = DateTime.UtcNow; var activityRepository = Substitute.For<IActivityRepository>(); var badgeActivitiesInDb = new List<Activity> { new Activity { Type = ActivityType.BadgeAwarded.ToString(), Timestamp = timestamp, Data = BadgeActivity.KeyBadgeId + "=" + guidStr + "," + BadgeActivity.KeyUserId + "=" + guidStrUser } }; var pagedBadgeActivities = new PagedList<Activity>(badgeActivitiesInDb, 1, 20, 1); activityRepository.GetPagedGroupedActivities(1, 20).Returns(pagedBadgeActivities); _badgeRepository.Get(new Guid(guidStr)).Returns(new Badge()); _membershipRepository.Get(new Guid(guidStrUser)).Returns(new MembershipUser()); IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService); var badgeActivities = activityService.GetPagedGroupedActivities(1, 20); Assert.IsTrue(badgeActivities[0] is BadgeActivity); }
public void MemberJoinedActivityGet() { const string guidStr = "515b7240-3be1-43d4-8846-c0b589cd1cd2"; var timestamp = DateTime.UtcNow; var activityRepository = Substitute.For<IActivityRepository>(); _membershipRepository.Get(new Guid(guidStr)).Returns(new MembershipUser()); var memberJoinedActivitiesInDb = new List<Activity> { new Activity { Type = ActivityType.MemberJoined.ToString(), Timestamp = timestamp, Data = MemberJoinedActivity.KeyUserId + "=" + guidStr } }; var pagedJoinedActivities = new PagedList<Activity>(memberJoinedActivitiesInDb, 1, 20, 1); activityRepository.GetPagedGroupedActivities(1, 20).Returns(pagedJoinedActivities); IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService); var memberJoinedActivities = activityService.GetPagedGroupedActivities(1, 20); Assert.IsTrue(memberJoinedActivities[0] is MemberJoinedActivity); }