Example #1
0
        public void WhenNewMailHaveNoTopic_ShouldHaveError()
        {
            var validator = new NewMailValidator();

            #region Init variables
            List <string> CCRecipientsAddresses = new List <string> {
                "*****@*****.**"
            };
            List <string> BCCRecipientsAddresses = new List <string> {
                "*****@*****.**"
            };
            string topic = "";
            string text  = "testtext";
            #endregion
            NewMail newMail = new NewMail
            {
                CCRecipientsAddresses  = CCRecipientsAddresses,
                BCCRecipientsAddresses = BCCRecipientsAddresses,
                Topic = topic,
                Text  = text,
            };
            var result = validator.TestValidate(newMail);
            #region Tests
            result.ShouldHaveValidationErrorFor(x => x.Topic);
            #endregion
        }
Example #2
0
        public void WhenNewMailHaveToLongText_ShouldHaveError()
        {
            var validator = new NewMailValidator();

            #region Init variables
            List <string> CCRecipientsAddresses = new List <string> {
                "*****@*****.**"
            };
            List <string> BCCRecipientsAddresses = new List <string> {
                "*****@*****.**"
            };
            string        topic         = "testtopic";
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < validator.textMaxLength + 1; i++)
            {
                stringBuilder.Append('x');
            }
            string text = stringBuilder.ToString();
            #endregion
            NewMail newMail = new NewMail
            {
                CCRecipientsAddresses  = CCRecipientsAddresses,
                BCCRecipientsAddresses = BCCRecipientsAddresses,
                Topic = topic,
                Text  = text,
            };
            var result = validator.TestValidate(newMail);
            #region Tests
            result.ShouldHaveValidationErrorFor(x => x.Text);
            #endregion
        }
Example #3
0
        public void WhenNewMailHaveAtLeastOneBCCRecipients_ShouldNotHaveAnyError()
        {
            var validator = new NewMailValidator();

            #region Init variables
            List <string> CCRecipientsAddresses  = new List <string>();
            List <string> BCCRecipientsAddresses = new List <string> {
                "*****@*****.**"
            };
            string topic = "testtopic";
            string text  = "testtext";
            #endregion
            NewMail newMail = new NewMail
            {
                CCRecipientsAddresses  = CCRecipientsAddresses,
                BCCRecipientsAddresses = BCCRecipientsAddresses,
                Topic = topic,
                Text  = text,
            };
            var result = validator.TestValidate(newMail);
            #region Tests
            result.ShouldNotHaveAnyValidationErrors();
            #endregion
        }