Example #1
0
        public void EmailValidationByUserIdFailedTest()
        {
            VerifyCleanedCounters();
            string email     = "*****@*****.**";
            var    emailType = EmailTypes.EmailValidation;
            var    message   = new SendGridMessage()
            {
                To = new MailAddress[] { new MailAddress(email) }
            };
            var userId = 2;

            int emailValidationByEmailQuota  = 1;
            int emailValidationByUserIdQuota = 0;
            int emailValidationsTotalQuota   = 0;
            int totalByEmailQuota            = 0;
            int textChatAlertsQuota          = 0;
            int emailsTotalQuota             = 0;

            EmailQuotaValidator   validator = new EmailQuotaValidator(emailValidationByEmailQuota, emailValidationByUserIdQuota, emailValidationsTotalQuota, totalByEmailQuota, textChatAlertsQuota, emailsTotalQuota);
            QuotaValidationResult result    = validator.ValidateQuota(emailType, message, userId);

            Assert.AreEqual(false, result.IsValid);
            Assert.AreEqual(0, result.ExceedData.Quota);
            Assert.AreEqual(1, result.ExceedData.Value);
            Assert.AreEqual(EmailQuotaType.EmailVerificationByUserId, result.ExceedData.QuotaType);

            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsByEmail[email]);
            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsByUserId[userId]);
            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsTotal.Count);
            Assert.AreEqual(1, EmailCountersStorage.TotalByEmail.Count);
            Assert.AreEqual(0, EmailCountersStorage.TextChatAlertsTotal);
            Assert.AreEqual(1, EmailCountersStorage.Total);
        }
Example #2
0
        public void PasswordRecoverySuccessTest()
        {
            VerifyCleanedCounters();
            string email     = "*****@*****.**";
            var    emailType = EmailTypes.PasswordRecovery;
            var    message   = new SendGridMessage()
            {
                To = new MailAddress[] { new MailAddress(email) }
            };
            var userId = 2;

            int emailValidationByEmailQuota  = 0;
            int emailValidationByUserIdQuota = 0;
            int emailValidationsTotalQuota   = 0;
            int totalByEmailQuota            = 1;
            int textChatAlertsQuota          = 0;
            int emailsTotalQuota             = 1;

            EmailQuotaValidator   validator = new EmailQuotaValidator(emailValidationByEmailQuota, emailValidationByUserIdQuota, emailValidationsTotalQuota, totalByEmailQuota, textChatAlertsQuota, emailsTotalQuota);
            QuotaValidationResult result    = validator.ValidateQuota(emailType, message, userId);

            Assert.AreEqual(true, result.IsValid);
            Assert.AreEqual(null, result.ExceedData);

            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsByEmail.Count);
            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsByUserId.Count);
            Assert.AreEqual(1, EmailCountersStorage.EmailVerificationsTotal.Count);
            Assert.AreEqual(1, EmailCountersStorage.TotalByEmail[email]);
            Assert.AreEqual(0, EmailCountersStorage.TextChatAlertsTotal);
            Assert.AreEqual(1, EmailCountersStorage.Total);
        }