Example #1
0
        public void MailFromDefault_ReturnsPhonyMailAddress_WhenNoConfigExists()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection();
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            MailAddress result = appConfiguration.MailFromDefault;

            Assert.NotNull(result);
            result.DisplayName.ShouldEqual("UNCONFIGURED NOREPLY");
            result.Address.ShouldEqual("*****@*****.**");
        }
Example #2
0
 public void DataProtectionAppName_Returns_ValueFromConfig_Or_AppName(string valueInConfig, string expected)
 {
     var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
     var appSettings = valueInConfig == null
         ? new NameValueCollection()
         : new NameValueCollection
         {
             { "DataProtectionAppName", valueInConfig },
         }
     ;
     mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
     var appConfiguration = new AppConfiguration(mockConfigReader.Object);
     string result = appConfiguration.DataProtectionAppName;
     result.ShouldEqual(expected);
 }
Example #3
0
 public void XsrfKey_Returns_ValueFromConfig(string valueInConfig)
 {
     var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
     var appSettings = valueInConfig == null
         ? new NameValueCollection()
         : new NameValueCollection
         {
             { "XsrfKey", valueInConfig },
         }
     ;
     mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
     var appConfiguration = new AppConfiguration(mockConfigReader.Object);
     string result = appConfiguration.XsrfKey;
     result.ShouldEqual(valueInConfig);
 }
Example #4
0
        public void MailFromDefault_ReturnsMailAddress_BasedOnConfig()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection
            {
                {
                    "MailFromDefault",
                    "Test Default Mail From Display Name <*****@*****.**>"
                },
            };
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            MailAddress mailFromDefault = appConfiguration.MailFromDefault;

            Assert.NotNull(mailFromDefault);
            mailFromDefault.DisplayName.ShouldEqual("Test Default Mail From Display Name");
            mailFromDefault.Address.ShouldEqual("*****@*****.**");
        }
Example #5
0
        public void MailInterceptors_ReturnsMailAddresses_BasedOnConfig()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection
            {
                {
                    "MailInterceptors",
                    "Test Mail Interceptor #1 Display Name <*****@*****.**>;" +
                    "Test Mail Interceptor #2 Display Name <*****@*****.**>"
                },
            };
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            var result = appConfiguration.MailInterceptors;

            Assert.NotNull(result);
            var mailInterceptors = result.ToArray();
            mailInterceptors.Length.ShouldEqual(2);
            mailInterceptors[0].DisplayName.ShouldEqual("Test Mail Interceptor #1 Display Name");
            mailInterceptors[0].Address.ShouldEqual("*****@*****.**");
            mailInterceptors[1].DisplayName.ShouldEqual("Test Mail Interceptor #2 Display Name");
            mailInterceptors[1].Address.ShouldEqual("*****@*****.**");
        }
Example #6
0
        public void MailDeliveryMethod_ReturnsSpecifiedPickupDirectory_WhenNoConfigExists()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            mockConfigReader.Setup(x => x.GetSection("system.net/mailSettings/smtp"))
                .Returns(null as ConfigurationSection);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            SmtpDeliveryMethod result = appConfiguration.MailDeliveryMethod;
            result.ShouldEqual(SmtpDeliveryMethod.SpecifiedPickupDirectory);
        }
Example #7
0
        public void MailDeliveryMethod_ReturnsValue_FromConfig(SmtpDeliveryMethod deliveryMethod)
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var smtpSection = new SmtpSection
            {
                DeliveryMethod = deliveryMethod,
            };
            mockConfigReader.Setup(x => x.GetSection("system.net/mailSettings/smtp")).Returns(smtpSection);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            SmtpDeliveryMethod result = appConfiguration.MailDeliveryMethod;
            result.ShouldEqual(deliveryMethod);
        }
Example #8
0
        public void MailPickupDirectory_ReturnsDefaultValue_WhenNoConfigExists()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection();
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            string result = appConfiguration.MailPickupDirectory;
            result.ShouldEqual(@"App_Data\mail\pickup");
        }
Example #9
0
        public void MailPickupDirectory_ReturnsValue_FromConfig()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection
            {
                {
                    "MailPickupDirectory",
                    @"special\custom/path"
                },
            };
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            string result = appConfiguration.MailPickupDirectory;
            result.ShouldEqual(@"special\custom/path");
        }
Example #10
0
        public void MailExceptionTo_ReturnsPhonyMailAddresses_WhenNoConfigExists()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection();
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            IEnumerable<MailAddress> result = appConfiguration.MailExceptionTo;

            Assert.NotNull(result);
            var mailExceptionTo = result.ToArray();
            mailExceptionTo.Length.ShouldEqual(1);
            mailExceptionTo[0].DisplayName.ShouldEqual("UNCONFIGURED EXCEPTION");
            mailExceptionTo[0].Address.ShouldEqual("*****@*****.**");
        }
Example #11
0
        public void MailExceptionTo_ReturnsMailAddresses_BasedOnConfig()
        {
            var mockConfigReader = new Mock<IReadConfiguration>(MockBehavior.Strict);
            var appSettings = new NameValueCollection
            {
                {
                    "MailExceptionTo",
                    "Test Mail Exception To #1 Display Name <*****@*****.**>;" +
                    "Test Mail Exception To #2 Display Name <*****@*****.**>"
                },
            };
            mockConfigReader.SetupGet(x => x.AppSettings).Returns(appSettings);
            var appConfiguration = new AppConfiguration(mockConfigReader.Object);

            IEnumerable<MailAddress> result = appConfiguration.MailExceptionTo;

            Assert.NotNull(result);
            var mailExceptionTo = result.ToArray();
            mailExceptionTo.Length.ShouldEqual(2);
            mailExceptionTo[0].DisplayName.ShouldEqual("Test Mail Exception To #1 Display Name");
            mailExceptionTo[0].Address.ShouldEqual("*****@*****.**");
            mailExceptionTo[1].DisplayName.ShouldEqual("Test Mail Exception To #2 Display Name");
            mailExceptionTo[1].Address.ShouldEqual("*****@*****.**");
        }