Пример #1
0
        public void BuildPostContentStep_WithSubstitution(string token, string value)
        {
            var contentStep = new MessageBuilder.BuildPostContentStep(MailerMessage.Create());

            if (token == null)
            {
                contentStep.Invoking(c => c.WithSubstitution(null, value)).Should().Throw <ArgumentNullException>();
            }
            else
            {
                var stepBuilder = contentStep.WithSubstitution(token, value);

                stepBuilder
                .Should()
                .NotBeNull()
                .And.BeOfType <MessageBuilder.BuildPostContentStep.BuildAttachmentOrSubstitutionStep>()
                .Which.As <IBuilderContext>()
                .Message.Substitutions
                .Should()
                .NotBeEmpty()
                .And.ContainKey(token)
                .WhichValue.Should()
                .Be(value);
            }
        }
Пример #2
0
        public void BuildPostContentStep_WithAttachment(string fileName)
        {
            var contentStep = new MessageBuilder.BuildPostContentStep(MailerMessage.Create());

            if (string.IsNullOrEmpty(fileName))
            {
                contentStep.Invoking(s => s.WithAttachment(fileName)).Should().Throw <FileNotFoundException>();
            }
            else
            {
                var path = Path.Combine(AppContext.BaseDirectory, fileName);

                var stepBuilder = contentStep.WithAttachment(path);

                stepBuilder
                .Should()
                .NotBeNull()
                .And.BeOfType <MessageBuilder.BuildPostContentStep.BuildAttachmentOrSubstitutionStep>()
                .Which.As <IBuilderContext>()
                .Message.Attachments
                .Should()
                .NotBeEmpty()
                .And.Subject.Keys.Select(Path.GetFileName)
                .Should()
                .Contain(Path.GetFileName(path));
            }
        }
Пример #3
0
        public void BuildPostContentStep_Build()
        {
            var contentStep = new MessageBuilder.BuildPostContentStep(MailerMessage.Create());

            var message = contentStep.Build();

            message
            .Should()
            .NotBeNull()
            .And.BeOfType <MailerMessage>();
        }