public void RemovesDatabaseIfConnectionStringIsNotEmpty()
 {
     var parameters = new NpgConnectionParameters { Database = "database" };
     _service.ConnectionStringHelperStub
         .Setup(helper => helper.Get(It.IsAny<string>()))
         .Returns(parameters.ConnectionString);
     CreateViewModel();
     Assert.IsNull(_viewModel.ConnectionParameters.Database);
 }
Beispiel #2
0
 public bool IsPHmiDatabase(string connectionString, string database)
 {
     var connectionParameters = new NpgConnectionParameters();
     connectionParameters.Update(connectionString);
     connectionParameters.Database = database;
     var query = new NpgQuery(string.Format("SELECT 1 FROM settings WHERE phmi_guid = '{0}'", PHmiConstants.PHmiGuid));
     var result = _npgHelper.ExecuteScalar(connectionParameters.ConnectionString, query);
     return result != null;
 }
 public void ConnectionStringWithoutDatabaseTest()
 {
     var parameters = new NpgConnectionParameters
         {
             Server = "server", Port = "port", UserId = "user id", Password = "******", Database = "database"
         };
     Assert.AreEqual(
         "Server=server;Port=port;User Id=user id;Password=password;Enlist=true;",
         parameters.ConnectionStringWithoutDatabase);
 }
 public void SetRaisesPropertyChangedTest(Action<NpgConnectionParameters> setAction, string property)
 {
     var p = new NpgConnectionParameters();
     var raised = false;
     string eventProperty = null;
     p.PropertyChanged += (sender, args) =>
         {
             raised = true;
             eventProperty = args.PropertyName;
         };
     setAction.Invoke(p);
     Assert.IsTrue(raised);
     Assert.AreEqual(property, eventProperty);
 }
Beispiel #5
0
        protected override void OnStart(string[] args)
        {
            try
            {
                var connectionStringHelper = new ConnectionStringHelper();
                var connectionString = connectionStringHelper.Get(PHmiConstants.PHmiConnectionStringName);
                connectionStringHelper.Protect();
                var connectionParameters = new NpgConnectionParameters();
                connectionParameters.Update(connectionString);

                _runner = _runnerFactory.Create(connectionParameters.Database, connectionString);
                _runner.Start();
            }
            catch (Exception exception)
            {
                _reporter.Report(Res.StartError, exception);
            }
        }
 public void CloseCommandSetsConnectionParametersToNull()
 {
     var parameters = new NpgConnectionParameters();
     _viewModel.ConnectionParameters = parameters;
     Assert.AreEqual(parameters, _viewModel.ConnectionParameters);
     _viewModel.CloseCommand.Execute(null);
     Assert.IsNull(_viewModel.ConnectionParameters);
 }
 public void StringToParametersTest()
 {
     var p = new NpgConnectionParameters();
     p.Update("Server=server;Port=port;User Id=user id;Password=password;Enlist=true;Database=database");
     Assert.AreEqual("server", p.Server);
     Assert.AreEqual("port", p.Port);
     Assert.AreEqual("user id", p.UserId);
     Assert.AreEqual("password", p.Password);
     Assert.AreEqual("database", p.Database);
 }
 public void StringToParametersReturnsEmptyParametersIfStringIsNull()
 {
     var p = new NpgConnectionParameters();
     p.Update(null);
     Assert.AreEqual(null, p.Server);
     Assert.AreEqual(null, p.Port);
     Assert.AreEqual(null, p.UserId);
     Assert.AreEqual(null, p.Password);
     Assert.AreEqual(null, p.Database);
 }
 public void StringToParametersDoesNotContainDatabaseIfItIsNotPresent()
 {
     var p = new NpgConnectionParameters();
     p.Update("Server=server;Port=port;User Id=user id;Password=password;Enlist=true;");
     Assert.AreEqual(null, p.Database);
 }
Beispiel #10
0
 private void UpdateConnectionStringFromArgs()
 {
     var args = ((App) Application.Current).Args;
     if (!string.IsNullOrWhiteSpace(args))
     {
         var connectionParameters = new NpgConnectionParameters();
         connectionParameters.Update(args);
         ViewModel.ConnectionParameters = connectionParameters;
     }
 }
Beispiel #11
0
 private void UpdateConnectionSringFromConfiguration()
 {
     var connectionStringHelper = new ConnectionStringHelper();
     var configString = connectionStringHelper.Get(PHmiConstants.PHmiConnectionStringName);
     if (configString != null)
     {
         var connectionParameters = new NpgConnectionParameters();
         connectionParameters.Update(configString);
         ViewModel.ConnectionParameters = connectionParameters;
     }
 }