示例#1
0
        public void TestThatEncryptValueAndDecryptValueOnConfigurationRepositoryEncryptsAndDescryptsValue()
        {
            var fixture  = new Fixture();
            var password = fixture.Create <string>();

            var encryptedPassword = ConfigurationRepository.EncryptValue(password);

            Assert.That(encryptedPassword, Is.Not.Null);
            Assert.That(encryptedPassword, Is.Not.Empty);

            var decryptedPassword = ConfigurationRepository.DecryptValue(encryptedPassword);

            Assert.That(decryptedPassword, Is.Not.Null);
            Assert.That(decryptedPassword, Is.Not.Empty);
            Assert.That(decryptedPassword, Is.EqualTo(password));
        }
示例#2
0
        public void TestThatConstructorInitializeConfigurationRepository()
        {
            var fixture = new Fixture();

            var smtpServer              = fixture.Create <string>();
            var smtpPort                = fixture.Create <int>();
            var useSmtpAuthentication   = fixture.Create <bool>();
            var useSmtpSecureConnection = fixture.Create <bool>();
            var smtpUserName            = fixture.Create <string>();
            var smtpPassword            = fixture.Create <string>();
            var fromMailAddress         = fixture.Create <string>();
            var nameValueCollection     = new NameValueCollection
            {
                { "SmtpServer", smtpServer },
                { "SmtpPort", Convert.ToString(smtpPort) },
                { "UseSmtpAuthentication", Convert.ToString(useSmtpAuthentication) },
                { "SmtpUserName", smtpUserName },
                { "SmtpPassword", ConfigurationRepository.EncryptValue(smtpPassword) },
                { "UseSmtpSecureConnection", Convert.ToString(useSmtpSecureConnection) },
                { "FromMailAddress", fromMailAddress }
            };

            var configurationRepository = new ConfigurationRepository(nameValueCollection);

            Assert.That(configurationRepository, Is.Not.Null);
            Assert.That(configurationRepository.SmtpServer, Is.Not.Null);
            Assert.That(configurationRepository.SmtpServer, Is.Not.Empty);
            Assert.That(configurationRepository.SmtpServer, Is.EqualTo(smtpServer));
            Assert.That(configurationRepository.SmtpPort, Is.EqualTo(smtpPort));
            Assert.That(configurationRepository.SmtpPort, Is.EqualTo(smtpPort));
            Assert.That(configurationRepository.UseSmtpAuthentication, Is.EqualTo(useSmtpAuthentication));
            Assert.That(configurationRepository.SmtpUserName, Is.Not.Null);
            Assert.That(configurationRepository.SmtpUserName, Is.Not.Empty);
            Assert.That(configurationRepository.SmtpUserName, Is.EqualTo(smtpUserName));
            Assert.That(configurationRepository.SmtpPassword, Is.Not.Null);
            Assert.That(configurationRepository.SmtpPassword, Is.Not.Empty);
            Assert.That(configurationRepository.SmtpPassword, Is.EqualTo(smtpPassword));
            Assert.That(configurationRepository.UseSmtpSecureConnection, Is.EqualTo(useSmtpSecureConnection));
            Assert.That(configurationRepository.FromMailAddress, Is.Not.Null);
            Assert.That(configurationRepository.FromMailAddress, Is.Not.Empty);
            Assert.That(configurationRepository.FromMailAddress, Is.EqualTo(fromMailAddress));
        }