예제 #1
0
        public void TestAddingDuplicateKeyThrows()
        {
            var          configProvider = new FixedConfigProvider();
            const string key            = "test key";

            configProvider.AddConfig(key, "abc");
            Assert.Throws <ArgumentException>(() => configProvider.AddConfig(key, "def"));
        }
예제 #2
0
        public void TestConstructorWithConfigProvider()
        {
            var configProvider = new FixedConfigProvider();

            configProvider.AddConfig(SmtpConfig.ConfigKeys.ServerName, ServerName);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.Port, Port.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(SmtpConfig.ConfigKeys.UserName, Username);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.Password, Password);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.EnableSsl, EnableSsl.ToString());
            var smtpConfig = new SmtpConfig(configProvider);

            CheckSmtpConfig(smtpConfig);
        }
예제 #3
0
        public void TestConstructionWithConfigProvider()
        {
            const string name           = "myLoggerName";
            const string location       = "myLogLocation";
            const string type           = "myLogType";
            var          configProvider = new FixedConfigProvider();

            configProvider.AddConfig(LogConfig.ConfigKeys.Name, name);
            configProvider.AddConfig(LogConfig.ConfigKeys.Location, location);
            configProvider.AddConfig(LogConfig.ConfigKeys.Type, type);

            var logConfig = new LogConfig(configProvider);

            Assert.That(logConfig.Name, Is.EqualTo(name));
            Assert.That(logConfig.Type, Is.EqualTo(type));
            Assert.That(logConfig.Location, Is.EqualTo(location));
        }
예제 #4
0
        public void TestConfigProviderConstructor()
        {
            var configProvider = new FixedConfigProvider();

            configProvider.AddConfig(MailSenderConfig.MailSenderConfigKeys.SenderName, SenderName);
            configProvider.AddConfig(MailSenderConfig.MailSenderConfigKeys.SenderAddress, SenderAddress);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.ServerName, ServerName);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.Port, Port.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(SmtpConfig.ConfigKeys.UserName, Username);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.Password, Password);
            configProvider.AddConfig(SmtpConfig.ConfigKeys.EnableSsl, EnableSsl.ToString());

            var config = new MailSenderConfig(configProvider);

            Assert.That(config.ServerName, Is.EqualTo(ServerName));
            Assert.That(config.Port, Is.EqualTo(Port));
            Assert.That(config.UserCredentials, Is.Not.Null);
            Assert.That(config.UserCredentials.UserName, Is.EqualTo(Username));
            Assert.That(config.UserCredentials.Password, Is.EqualTo(Password));
            Assert.That(config.Username, Is.EqualTo(Username));
            Assert.That(config.Password, Is.EqualTo(Password));
            Assert.That(config.Sender, Is.Not.Null);
            Assert.That(config.Sender.Address, Is.EqualTo(SenderAddress));
            Assert.That(config.Sender.DisplayName, Is.EqualTo(SenderName));
            Assert.That(config.SenderName, Is.EqualTo(SenderName));
            Assert.That(config.SenderAddress, Is.EqualTo(SenderAddress));
            Assert.That(config.EnableSsl, Is.EqualTo(EnableSsl));
        }
예제 #5
0
        protected override IConfigProvider CreatePopulatedConfigProvider()
        {
            var configProvider = new FixedConfigProvider();

            configProvider.AddConfig(TestData.Keys.StringKey, TestData.Values.StringValue);
            configProvider.AddConfig(TestData.Keys.StringKeyNull, null);
            configProvider.AddConfig(TestData.Keys.StringKeyEmpty, string.Empty);
            configProvider.AddConfig(TestData.Keys.IntKey, TestData.Values.IntValue.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(TestData.Keys.DoubleKey, TestData.Values.DoubleValue.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(TestData.Keys.BoolKeyFalse, TestData.Values.BoolValueFalse.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(TestData.Keys.BoolKeyTrue, TestData.Values.BoolValueTrue.ToString(CultureInfo.InvariantCulture));
            configProvider.AddConfig(TestData.Keys.BoolKeyInvalid, TestData.Values.BoolValueInvalid);
            return(configProvider);
        }
예제 #6
0
        public void TestAddConfigArgumentGuards()
        {
            var configProvider = new FixedConfigProvider();

            Assert.Throws <ArgumentNullException>(() => configProvider.AddConfig(null, "abc"));
        }