Exemple #1
0
        public void EmailAggregate_MarkMessageAsDelivered_MessageMarkedAsDelivered()
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue);
            emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);

            emailAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);

            emailAggregate.MessageStatus.ShouldBe(MessageStatus.Delivered);
        }
Exemple #2
0
        public void EmailAggregate_ReceiveResponseFromProvider_ResponseReceived()
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue);
            emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);

            emailAggregate.ProviderRequestReference.ShouldBe(TestData.ProviderRequestReference);
            emailAggregate.ProviderEmailReference.ShouldBe(TestData.ProviderEmailReference);
            emailAggregate.MessageStatus.ShouldBe(MessageStatus.Sent);
        }
Exemple #3
0
        public void EmailAggregate_SendRequestToProvider_RequestSent()
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue);

            emailAggregate.FromAddress.ShouldBe(TestData.FromAddress);
            emailAggregate.Subject.ShouldBe(TestData.Subject);
            emailAggregate.Body.ShouldBe(TestData.Body);
            emailAggregate.IsHtml.ShouldBe(TestData.IsHtmlTrue);
            emailAggregate.MessageStatus.ShouldBe(MessageStatus.InProgress);
            // TODO: Get Recipients
        }
Exemple #4
0
        public void EmailAggregate_SendRequestToProvider_RequestAlreadySent_ErrorThrown()
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue);

            Should.Throw <InvalidOperationException>(() =>
            {
                emailAggregate.SendRequestToProvider(TestData.FromAddress,
                                                     TestData.ToAddresses,
                                                     TestData.Subject,
                                                     TestData.Body,
                                                     TestData.IsHtmlTrue);
            });
        }
Exemple #5
0
        public void EmailAggregate_MarkMessageAsDelivered_IncorrectState_ErrorThrown(MessageStatus messageStatus)
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.SendRequestToProvider(TestData.FromAddress, TestData.ToAddresses, TestData.Subject, TestData.Body, TestData.IsHtmlTrue);

            switch (messageStatus)
            {
            case MessageStatus.Delivered:
                emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);
                emailAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
                break;

            case MessageStatus.Bounced:
                emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);
                emailAggregate.MarkMessageAsBounced(TestData.ProviderStatusDescription, TestData.BouncedDateTime);
                break;

            case MessageStatus.Failed:
                emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);
                emailAggregate.MarkMessageAsFailed(TestData.ProviderStatusDescription, TestData.FailedDateTime);
                break;

            case MessageStatus.Rejected:
                emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);
                emailAggregate.MarkMessageAsRejected(TestData.ProviderStatusDescription, TestData.RejectedDateTime);
                break;

            case MessageStatus.Spam:
                emailAggregate.ReceiveResponseFromProvider(TestData.ProviderRequestReference, TestData.ProviderEmailReference);
                emailAggregate.MarkMessageAsSpam(TestData.ProviderStatusDescription, TestData.SpamDateTime);
                break;

            case MessageStatus.NotSet:
                break;
            }

            Should.Throw <InvalidOperationException>(() =>
            {
                emailAggregate.MarkMessageAsDelivered(TestData.ProviderStatusDescription, TestData.DeliveredDateTime);
            });
        }
Exemple #6
0
        public void EmailAggregate_CanBeCreated_IsCreated()
        {
            EmailAggregate emailAggregate = EmailAggregate.Create(TestData.MessageId);

            emailAggregate.MessageId.ShouldBe(TestData.MessageId);
        }