public void ShouldContainCandidateFirstNameSubstitution(int noOfDrafts)
        {
            var expiringDrafts = new ExpiringApprenticeshipApplicationDraftsBuilder().WithSpecialCharacterExpiringDrafts(noOfDrafts).Build();
            var emailRequest   = new DailyDigestEmailRequestBuilder().WithExpiringDrafts(expiringDrafts).Build();
            List <SendGridMessageSubstitution> sendGridMessageSubstitutions;
            var sendGridMessage = GetSendGridMessage(out sendGridMessageSubstitutions);

            var emailMessageFormatter = new EmailDailyDigestMessageFormatter();

            emailMessageFormatter.PopulateMessage(emailRequest, sendGridMessage.Object);

            sendGridMessageSubstitutions.Any(s => s.ReplacementTag == CandidateFirstNameTag).Should().BeTrue();
        }
        public void GivenMultipleExpiringDrafts_ThenOrderedByClosingDate()
        {
            var expiringDrafts = new ExpiringApprenticeshipApplicationDraftsBuilder().WithExpiringDrafts(3).Build();

            expiringDrafts[0].ClosingDate = new DateTime(2015, 02, 01);
            expiringDrafts[1].ClosingDate = new DateTime(2015, 01, 01);
            expiringDrafts[2].ClosingDate = new DateTime(2015, 04, 01);
            var emailRequest = new DailyDigestEmailRequestBuilder().WithExpiringDrafts(expiringDrafts).Build();

            //Assert the ascending ordering by ClosingDate of apprenticeships about to expire
            if (emailRequest.Tokens.Count() > 1)
            {
                var orderedList = ConvertToExpiringApprenticeshipApplicationDraftModel(emailRequest);

                Assert.That(orderedList, Is.Ordered.By("ClosingDate"));
            }
        }
        public void GivenMultipleExpiringDraftsSpecialCharacters(int noOfDrafts)
        {
            var expiringDrafts = new ExpiringApprenticeshipApplicationDraftsBuilder().WithSpecialCharacterExpiringDrafts(noOfDrafts).Build();
            var emailRequest   = new DailyDigestEmailRequestBuilder().WithExpiringDrafts(expiringDrafts).Build();
            List <SendGridMessageSubstitution> sendGridMessageSubstitutions;
            var sendGridMessage = GetSendGridMessage(out sendGridMessageSubstitutions);

            var emailMessageFormatter = new EmailDailyDigestMessageFormatter();

            emailMessageFormatter.PopulateMessage(emailRequest, sendGridMessage.Object);

            var countSubstitution = sendGridMessageSubstitutions.Single(s => s.ReplacementTag == ExpiryVacanciesCountTag);

            countSubstitution.SubstitutionValues.Count.Should().Be(1);
            countSubstitution.SubstitutionValues.Single().Should().Be(EmailDailyDigestMessageFormatter.MoreThanOneSaveApplicationAboutToExpire);
            sendGridMessageSubstitutions.Count(s => s.ReplacementTag == ExpiryVacanciesInfoTag).Should().Be(1);
            var infoSubstitution = sendGridMessageSubstitutions.Single(s => s.ReplacementTag == ExpiryVacanciesInfoTag);

            infoSubstitution.SubstitutionValues.Single().Should().Be(GetExpectedInfoSubstitution(expiringDrafts));
        }