Exemplo n.º 1
0
        public void CanHaveSqlAuthentication()
        {
            var args = new[] {"--server", "server", "--database", "database", "--username", "user", "--password", "pass"};

            var options = new ConnectionStringOptions();
            var passed = ParseArguments(args, options);

            Assert.IsTrue(passed, "failed to parse args");
            var builder = options.ConnectionStringBuilder();
            Assert.AreEqual(false, builder.IntegratedSecurity);
            Assert.AreEqual("user", builder.UserID);
            Assert.AreEqual("pass", builder.Password);
        }
Exemplo n.º 2
0
        public void CanHaveIntegratedSecurity()
        {
            var args = new[] {"--server", "server", "--database", "database", "--integrated"};

            var options = new ConnectionStringOptions();
            var passed = ParseArguments(args, options);

            Assert.IsTrue(passed, "failed to parse args");
            var builder = options.ConnectionStringBuilder();
            Assert.AreEqual("server", builder.DataSource);
            Assert.AreEqual("database", builder.InitialCatalog);
            Assert.AreEqual(true, builder.IntegratedSecurity);
        }
Exemplo n.º 3
0
        public void UseTrustServerCert()
        {
            var args = new[]
            {
                "--server", "server", "--database", "database", "--username", "user", "--password", "pass",
                "--trust-server-certificate"
            };

            var options = new ConnectionStringOptions();
            var passed = ParseArguments(args, options);

            Assert.IsTrue(passed, "failed to parse args");
            var builder = options.ConnectionStringBuilder();
            Assert.AreEqual(true, builder.TrustServerCertificate);
        }
Exemplo n.º 4
0
        public void MustHaveUsernameAndPassword(string argumentName, string value)
        {
            var args = new[] { "--server", "server", "--database", "database", argumentName, value };

            var options = new ConnectionStringOptions();

            var failed = false;
            try
            {
                ParseArguments(args, options);
            }
            catch (Exception)
            {
                failed = true;
            }
            Assert.IsTrue(failed, "expected parsing to fail");
        }
Exemplo n.º 5
0
 private static bool ParseArguments(string[] args, ConnectionStringOptions options)
 {
     var passed = CommandLine.Parser.Default.ParseArguments(args, options);
     options.GuardArgumentsValid();
     return passed;
 }