public void ValidateCredentials_ReturnsAuthenticationError_WhenApiKeyIsNotEmptyAndServerIdIsEmpty() { //Arrange const int serverId = int.MinValue; var apiKey = RandomHelper.RandomString(); var validator = new SendValidator(); //Act var actual = validator.ValidateCredentials(serverId, apiKey); //Assert Assert.AreEqual(SendResult.AuthenticationValidationFailed, actual.Result); }
public void HasFromAddress_ReturnsFalse_WhenFromRecipientIsNull() { //Arrange var message = new BasicMessage { From = null }; var validator = new SendValidator(); //Act var actual = validator.HasFromAddress(message); //Assert Assert.IsFalse(actual); }
public void HasApiTemplate_ReturnsFalse_WhenApiTemplateIsMinValue() { //Arrange var message = new BasicMessage { ApiTemplate = int.MinValue }; var validator = new SendValidator(); //Act var actual = validator.HasApiTemplate(message); //Assert Assert.IsFalse(actual); }
public void ValidateRecipients_BulkMessage_ReturnsNoRecipients_WhenToIsEmpty() { //Arrange var message = new BulkMessage { To = new List <IBulkRecipient>() }; var validator = new SendValidator(); //Act var actual = validator.ValidateRecipients(message); //Assert Assert.AreEqual(SendResult.RecipientValidationMissingTo, actual.Result); }
public void HasSubject_ReturnsTrue_WhenSubjectIsNotEmpty() { //Arrange var message = new BasicMessage { Subject = RandomHelper.RandomString() }; var validator = new SendValidator(); //Act var actual = validator.HasSubject(message); //Assert Assert.IsTrue(actual); }
public void FindInvalidRecipients_ListOfBulkRecipient_ReturnsList_WhenInvalidRecipientsFound() { //Arrange var message = new List <IBulkRecipient> { new BulkRecipient(RandomHelper.RandomString()) }; var validator = new SendValidator(); //Act var actual = validator.FindInvalidRecipients(message); //Assert Assert.AreEqual(1, actual.Count); }
public void ValidateIMessageBase_ReturnsMessageValidationEmptySubject_WhenSubjectIsEmpty() { //Arrange var message = new BasicMessage { Subject = string.Empty }; var validator = new SendValidator(); //Act var actual = validator.ValidateIMessageBase(message); //Assert Assert.AreEqual(SendResult.MessageValidationEmptySubject, actual); }
public void FindInvalidRecipients_ListOfBulkRecipient_ReturnsNull_WhenNoInvalidRecipientsFound() { //Arrange var message = new List <IBulkRecipient> { new BulkRecipient(RandomHelper.RandomEmail()) }; var validator = new SendValidator(); //Act var actual = validator.FindInvalidRecipients(message); //Assert Assert.IsNull(actual); }
public void HasSubject_ReturnsFalse_WhenSubjectIsEmpty() { //Arrange var message = new BasicMessage { Subject = string.Empty }; var validator = new SendValidator(); //Act var actual = validator.HasSubject(message); //Assert Assert.IsFalse(actual); }
public void HasValidCustomHeaders_ReturnsFalse_WhenKeyIsEmptyAndValueIsNotEmpty() { //Arrange var customHeaders = new List <ICustomHeader> { new CustomHeader(string.Empty, RandomHelper.RandomString()) }; var validator = new SendValidator(); //Act var actual = validator.HasValidCustomHeaders(customHeaders); //Assert Assert.IsFalse(actual); }
public void HasValidCustomHeaders_ReturnsTrue_WhenDictionaryIsValid() { //Arrange var customHeaders = new List <ICustomHeader> { new CustomHeader(RandomHelper.RandomString(), RandomHelper.RandomString()) }; var validator = new SendValidator(); //Act var actual = validator.HasValidCustomHeaders(customHeaders); //Assert Assert.IsTrue(actual); }
public void HasApiTemplate_ReturnsTrue_WhenApiTemplateIsNotMinValue() { //Arrange var message = new BasicMessage { ApiTemplate = RandomHelper.RandomInt(1, 10) }; var validator = new SendValidator(); //Act var actual = validator.HasApiTemplate(message); //Assert Assert.IsTrue(actual); }
public void HasFromAddress_ReturnsTrue_WhenFromRecipientIsNotEmpty() { //Arrange var message = new BasicMessage { From = new EmailAddress(RandomHelper.RandomEmail()) }; var validator = new SendValidator(); //Act var actual = validator.HasFromAddress(message); //Assert Assert.IsTrue(actual); }
public void ValidateRecipients_BulkMessage_ReturnsTooManyRecipients_WhenToHasToManyRecipients() { //Arrange var validator = new SendValidator(); var message = new BulkMessage { To = RandomHelper.RandomListOfBulkRecipients(validator.MaximumRecipientsPerMessage + 1) }; //Act var actual = validator.ValidateRecipients(message); //Assert Assert.AreEqual(SendResult.RecipientValidationMaxExceeded, actual.Result); }
public void HasValidCustomHeaders_ReturnsFalse_WhenKeyAndValueAreEmpty() { //Arrange var customHeaders = new List <ICustomHeader> { new CustomHeader(string.Empty, string.Empty) }; var validator = new SendValidator(); //Act var actual = validator.HasValidCustomHeaders(customHeaders); //Assert Assert.IsFalse(actual); }
public void ValidateIMessageBase_ReturnsEmailAddressValidationInvalidFrom_WhenFromRecipientIsInvalid() { //Arrange var message = new BasicMessage { Subject = RandomHelper.RandomString(), From = new EmailAddress("$$##%%") }; var validator = new SendValidator(); //Act var actual = validator.ValidateIMessageBase(message); //Assert Assert.AreEqual(SendResult.EmailAddressValidationInvalidFrom, actual); }
public void ValidateIMessageBase_ReturnsMessageValidationEmptyMessage_WhenSubjectAndFromRecipientAndAllBodyFieldsAreEmpty() { //Arrange var message = new BasicMessage { Subject = RandomHelper.RandomString(), From = new EmailAddress(RandomHelper.RandomEmail()) }; var validator = new SendValidator(); //Act var actual = validator.ValidateIMessageBase(message); //Assert Assert.AreEqual(SendResult.MessageValidationEmptyMessage, actual); }
public void ValidateIMessageBase_ReturnsSuccess_WhenSubjectAndFromRecipientAndApiTemplateIsNotEmpty() { //Arrange var message = new BasicMessage { Subject = RandomHelper.RandomString(), From = new EmailAddress(RandomHelper.RandomEmail()), ApiTemplate = RandomHelper.RandomInt() }; var validator = new SendValidator(); //Act var actual = validator.ValidateIMessageBase(message); //Assert Assert.AreEqual(SendResult.Success, actual); }
public void ValidateRecipients_BasicMessage_ReturnsSuccess_WhenBccIsNotEmpty() { //Arrange var message = new BasicMessage { Bcc = new List <IEmailAddress> { new EmailAddress(RandomHelper.RandomEmail()) } }; var validator = new SendValidator(); //Act var actual = validator.ValidateRecipients(message); //Assert Assert.AreEqual(SendResult.Success, actual.Result); }
public void HasMessageBody_ReturnsFalse_WhenHtmlBodyAndPlainTextBodyAndApiTemplateIsEmpty() { //Arrange var message = new BasicMessage { HtmlBody = string.Empty, PlainTextBody = string.Empty, ApiTemplate = null }; var validator = new SendValidator(); //Act var actual = validator.HasMessageBody(message); //Assert Assert.IsFalse(actual); }
public void FeeIsRequired() { // Arrange SendAction.Fee = null; // Act ValidationResult validationResult = SendValidator.Validate(SendAction); // Assert validationResult.IsValid.ShouldBe(false); validationResult.Errors.Count.ShouldBe(1); ValidationFailure validationFailure = validationResult.Errors[0]; validationFailure.PropertyName.ShouldBe(nameof(SendAction.Fee)); validationFailure.ErrorCode.ShouldBe(nameof(NotEmptyValidator)); validationFailure.Severity.ShouldBe(Severity.Error); }
public void GetFullRecipientCount_BasicMessage_ReturnsGT0_WhenOnlyBccRecipientsHasOneValue() { //Arrange var message = new BasicMessage { Bcc = new List <IEmailAddress> { new EmailAddress(RandomHelper.RandomEmail()) } }; var validator = new SendValidator(); //Act var actual = validator.GetFullRecipientCount(message); //Assert Assert.IsTrue(actual > 0); }
public void HasMessageBody_ReturnsTrue_WhenApiTemplateIsNotEmptyAndPlainTextBodyAndHtmlBodyIsEmpty() { //Arrange var message = new BasicMessage { HtmlBody = string.Empty, PlainTextBody = string.Empty, ApiTemplate = RandomHelper.RandomInt() }; var validator = new SendValidator(); //Act var actual = validator.HasMessageBody(message); //Assert Assert.IsTrue(actual); }
public void HasInvalidRecipients_IBulkMessage_ReturnsListOfOne_WhenToHasOneInvalid() { //Arrange var message = new BulkMessage { To = new List <IBulkRecipient> { new BulkRecipient(RandomHelper.RandomString()) } }; var validator = new SendValidator(); //Act var actual = validator.HasInvalidRecipients(message); //Assert Assert.AreEqual(1, actual.Count); }
public void ValidateRecipients_BasicMessage_ReturnsTooManyRecipients_WhenToAndCcAndBccCombinedHasToManyRecipients() { //Arrange var validator = new SendValidator(); var message = new BasicMessage { To = RandomHelper.RandomListOfRecipients(validator.MaximumRecipientsPerMessage / 2), Cc = RandomHelper.RandomListOfRecipients(validator.MaximumRecipientsPerMessage / 2), Bcc = RandomHelper.RandomListOfRecipients(validator.MaximumRecipientsPerMessage / 2) }; //Act var actual = validator.ValidateRecipients(message); //Assert Assert.AreEqual(SendResult.RecipientValidationMaxExceeded, actual.Result); }
public void HasInvalidRecipients_IBasicMessage_ReturnsListOfOne_WhenBccHasOneInvalid() { //Arrange var message = new BasicMessage { Bcc = new List <IEmailAddress> { new EmailAddress(RandomHelper.RandomString()) } }; var validator = new SendValidator(); //Act var actual = validator.HasInvalidRecipients(message); //Assert Assert.AreEqual(1, actual.Count); }
public void NativeAmountMustBeGreaterThanZero() { // Arrange SendAction.NativeAmount = "0000"; // Act ValidationResult validationResult = SendValidator.Validate(SendAction); // Assert validationResult.IsValid.ShouldBe(false); validationResult.Errors.Count.ShouldBe(1); ValidationFailure validationFailure = validationResult.Errors[0]; validationFailure.PropertyName.ShouldBe(nameof(SendAction.NativeAmount)); validationFailure.ErrorCode.ShouldBe(nameof(PredicateValidator)); validationFailure.Severity.ShouldBe(Severity.Error); }
public void WalletMustExist() { SendAction.EdgeCurrencyWalletId = "x"; // Act ValidationResult validationResult = SendValidator.Validate(SendAction); // Assert validationResult.IsValid.ShouldBe(false); validationResult.Errors.Count.ShouldBe(1); ValidationFailure validationFailure = validationResult.Errors[0]; validationFailure.PropertyName.ShouldBe(nameof(SendAction.EdgeCurrencyWalletId)); validationFailure.ErrorCode.ShouldBe(nameof(PredicateValidator)); validationFailure.Severity.ShouldBe(Severity.Error); }
public void DestinationAddressMustBeValid() { // Arrange SendAction.DestinationAddress = "ThisIsNotValid"; // Act ValidationResult validationResult = SendValidator.Validate(SendAction); // Assert validationResult.IsValid.ShouldBe(false); validationResult.Errors.Count.ShouldBe(1); ValidationFailure validationFailure = validationResult.Errors[0]; validationFailure.PropertyName.ShouldBe(nameof(SendAction.DestinationAddress)); validationFailure.ErrorCode.ShouldBe(nameof(PredicateValidator)); validationFailure.Severity.ShouldBe(Severity.Error); }
public void DestinationAddressIsRequired() { // Arrange SendAction.DestinationAddress = ""; // Act ValidationResult validationResult = SendValidator.Validate(SendAction); // Assert validationResult.IsValid.ShouldBe(false); validationResult.Errors.Count.ShouldBeGreaterThan(0); ValidationFailure validationFailure = validationResult.Errors .First(aValidationFailure => aValidationFailure.ErrorCode == nameof(NotEmptyValidator)); validationFailure.PropertyName.ShouldBe(nameof(SendAction.DestinationAddress)); validationFailure.ErrorCode.ShouldBe(nameof(NotEmptyValidator)); validationFailure.Severity.ShouldBe(Severity.Error); }