Пример #1
0
        public void AllTogetherIsNotValidWithoutPotentialBadgeApproved()
        {
            var targetActivityId = 1;
            var activityInfo     = new ActivityInfoDTO
            {
                ActivityId = targetActivityId,
                Status     = ActivitySubmissionStatus.Approved,
                EmployeeId = 4
            };
            var potentialBadges = new List <BadgeEditDTO>();

            potentialBadges.Add(new BadgeEditDTO
            {
                Id = 1,
                MultipleAwardsPossible = true,
                EffectiveStartDate     = DateTime.Parse("1/1/2013", CultureInfo.CurrentCulture),
                EffectiveEndDate       = DateTime.Parse("1/1/2015", CultureInfo.CurrentCulture),
                ApprovedById           = 0,
                ActivityPointsAmount   = 1,
                BadgeActivities        = new List <BadgeActivityEditDTO> {
                    new BadgeActivityEditDTO {
                        ActivityId = targetActivityId
                    }
                }
            });
            var earnedBadges       = new List <BadgeAwardDTO>();
            var previousActivities = new List <SubmittedActivityItemDTO>();

            var awardBadges = new AwardBadges();
            var result      = awardBadges.GetBadgeAwardsForActivity(activityInfo, potentialBadges, earnedBadges, previousActivities, DateTime.Parse("1/1/2014", CultureInfo.CurrentCulture));

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count());
        }
        protected override void DataPortal_Update()
        {
            var saveList    = new List <ApproveActivityItemDTO>();
            var badgeList   = new List <BadgeAwardDTO>();
            var awardBadges = IoC.Container.Resolve <IAwardBadges>();

            foreach (ApproveActivityItemForManager i in this)
            {
                if (i.Status == ActivitySubmissionStatus.Approved)
                {
                    var activityInfo = new ActivityInfoDTO
                    {
                        ActivityId = i.ActivityId,
                        EmployeeId = i.EmployeeId,
                        Status     = i.Status
                    };
                    badgeList.AddRange(awardBadges.CreateBadges(activityInfo));
                    if (activityInfo.Status == ActivitySubmissionStatus.Complete)
                    {
                        i.CompleteActivitySubmission();
                    }
                }
                saveList.Add(i.Unload());
            }
            var dal     = IoC.Container.Resolve <IApproveActivityCollectionDAL>();
            var results = dal.Update(saveList);

            AwardBadges.SaveBadges(badgeList.AsQueryable());
            this.Clear();
            this.DeletedList.Clear();
            this.LoadData(results);
        }
Пример #3
0
        public void AllowedNullEffectiveDates()
        {
            var approvalDate = DateTime.Parse("1/1/2014", CultureInfo.CurrentCulture);
            var dto          = new BadgeEditDTO();

            var result = AwardBadges.BadgeValidForDate(approvalDate, dto);

            Assert.IsTrue(result);
        }
Пример #4
0
        public void AllowedNoPreviousOneRequired()
        {
            var dto = new BadgeEditDTO
            {
                ActivityPointsAmount = 1
            };
            var previousActivities = new List <SubmittedActivityItemDTO>();

            var result = AwardBadges.CorrectNumberOfEarnedBadges(1, dto, previousActivities);

            Assert.IsTrue(result);
        }
Пример #5
0
        public void NotAllowedOutsideDateRange()
        {
            var approvalDate = DateTime.Parse("1/1/2012", CultureInfo.CurrentCulture);
            var dto          = new BadgeEditDTO
            {
                EffectiveStartDate = DateTime.Parse("1/1/2013", CultureInfo.CurrentCulture),
                EffectiveEndDate   = DateTime.Parse("1/1/2015", CultureInfo.CurrentCulture)
            };

            var result = AwardBadges.BadgeValidForDate(approvalDate, dto);

            Assert.IsFalse(result);
        }
Пример #6
0
        public void AllowedNeverAwarded()
        {
            var dto = new BadgeEditDTO
            {
                Id = 1,
                MultipleAwardsPossible = false
            };
            var earnedBadges = new List <BadgeAwardDTO>();

            var result = AwardBadges.AllowedToBeAwarded(dto, earnedBadges);

            Assert.IsTrue(result);
        }
Пример #7
0
        public void NotAllowedWithMultipleBadges()
        {
            var dto = new BadgeEditDTO
            {
                Id = 1,
                MultipleAwardsPossible = false
            };
            var earnedBadges = new List <BadgeAwardDTO>();

            earnedBadges.Add(new BadgeAwardDTO {
                BadgeId = 1
            });

            var result = AwardBadges.AllowedToBeAwarded(dto, earnedBadges);

            Assert.IsFalse(result);
        }
Пример #8
0
        public void AllowedOnePreviousOneRequired()
        {
            var dto = new BadgeEditDTO
            {
                ActivityPointsAmount = 1
            };
            var previousActivities = new List <SubmittedActivityItemDTO>();

            previousActivities.Add(new SubmittedActivityItemDTO
            {
                ActivityId = 1,
                Status     = ActivitySubmissionStatus.Complete
            });

            var result = AwardBadges.CorrectNumberOfEarnedBadges(1, dto, previousActivities);

            Assert.IsTrue(result);
        }
 private void SaveBadges(IQueryable <BadgeAwardDTO> badgesToCreate)
 {
     AwardBadges.SaveBadges(badgesToCreate);
 }