Example #1
0
        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 MemberJoinedActivityAdd()
        {
            const string guidStr = "515b7240-3be1-43d4-8846-c0b589cd1cd2";
            var activityRepository = Substitute.For<IActivityRepository>();
            IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService);
            var user = new MembershipUser { Id = new Guid(guidStr), UserName = "******" };

            activityService.MemberJoined(user);

            activityRepository.Received().Add((Arg.Is<Activity>(x => x.Data == MemberJoinedActivity.KeyUserId + "=" + guidStr)));
        }
Example #3
0
        public void BadgeAwardedActivityAdd()
        {
            const string guidStrBadge = "515b7240-3be1-43d4-8846-c0b589cd1cd2";
            const string guidStrUser = "******";

            var activityRepository = Substitute.For<IActivityRepository>();
            IActivityService activityService = new ActivityService(activityRepository, _badgeRepository, _membershipRepository, _loggingService);
            var user = new MembershipUser { Id = new Guid(guidStrUser), UserName = "******" };
            var badge = new Badge { Id = new Guid(guidStrBadge) };

            activityService.BadgeAwarded(badge, user, DateTime.UtcNow);

            activityRepository.Received().Add((Arg.Is<Activity>(x => x.Data == BadgeActivity.KeyBadgeId + "=" + guidStrBadge + "," + BadgeActivity.KeyUserId + "=" + guidStrUser)));
        }
Example #4
0
        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);
        }