public void Setup()
 {
     CreateDatabase();
     _dataAccess = DataAccessFactory.Create(TestConnectionString);
     _dataAccess.OpenConnection();
     _subject = new DatabaseInitializer(_dataAccess);
 }
Exemple #2
0
        public void ExecuteScript_should_use_CommandTimeout_specified_in_the_connection_string()
        {
            // arrange
            _subject = DataAccessFactory.Create(TestConnectionString + ";CommandTimeout=1");

            // act
            _subject.OpenConnection();
            using (var tran = _subject.BeginTransaction())
            {
                try
                {
                    _subject.ExecuteScript(tran, "WaitFor Delay '00:00:01'");
                }
                catch (Exception ex)
                {
                    // assert

                    // Sql Server Compact (which is being used for these tests) does not
                    // support CommandTimeout values other than 0. So we will assume
                    // that if it barfs it is because our non-zero CommandTimeout was successfully (attempted to be) set.
                    Assert.IsInstanceOfType(typeof(ArgumentException), ex);
                    Assert.AreEqual("SqlCeCommand.CommandTimeout does not support non-zero values.", ex.Message);
                    return;
                }
            }

            Assert.Fail("Expected command timeout exception to be thrown.");
        }
Exemple #3
0
        private void btnSaveTemplate_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveTemplateDialog = new SaveFileDialog();

            saveTemplateDialog.ShowDialog();
            saveTemplateDialog.Title            = "Save Site Template";
            saveTemplateDialog.Filter           = "Json Files| *.json;";
            saveTemplateDialog.InitialDirectory = @"C:\";
            saveTemplateDialog.CheckFileExists  = true;
            saveTemplateDialog.CheckPathExists  = true;

            if (saveTemplateDialog.FileName != "")
            {
                string filename = saveTemplateDialog.FileName;
                if (siteDataModel == null)
                {
                    GetDataFromControls();
                }
                IDataAccessLayer writeFile = DataAccessFactory.Create(0);
                writeFile.Save(filename, siteDataModel);
                MessageBox.Show("Template saved successfully");
            }
            else
            {
                MessageBox.Show("Please Enter Filename");
            }
        }
Exemple #4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            OpenFileDialog op1 = new OpenFileDialog();

            op1.Filter      = "Json Files| *.json;";
            op1.Multiselect = false;
            DialogResult result = op1.ShowDialog();
            DataModel    data   = null;

            if (result == DialogResult.OK)
            {
                string fName = op1.FileName;
                try
                {
                    IDataAccessLayer readFile = DataAccessFactory.Create(0);
                    data = readFile.Get <DataModel>(fName);
                    ShowDataTocontrols(data);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error in Reading File: " + op1.FileName);
                }
            }
            else
            {
                MessageBox.Show("Please Select File");
            }
        }
Exemple #5
0
        private void OnCommandStarting(object sender, CommandEventArgs <TArgs> e)
        {
            //  initialize the data access class
            string connStr = GetConnectionString(e.CommandArguments);

            Database = DataAccessFactory.Create(connStr);

            //  perform the database initialization
            Database.OpenConnection();
            var dbInit = new DatabaseInitializer(Database);

            dbInit.Initialize();
        }
        /// <summary>
        /// Calls DatabaseInitializer.Initialize() for the test database.
        /// </summary>
        protected void InitializeDatabase()
        {
            if (!File.Exists(_testDatabaseFile))
            {
                CreateDatabase();
            }

            using (var da = DataAccessFactory.Create(TestConnectionString))
            {
                da.OpenConnection();
                var dbInit = new DatabaseInitializer(da);
                dbInit.Initialize();
            }
        }
Exemple #7
0
        bool ReadTemplate(string template)
        {
            IDataAccessLayer readFile = DataAccessFactory.Create(0);
            DataModel        data     = readFile.GetTemplate <DataModel>(template);

            data.siteActions = data.siteActionsList.ToDictionary(pair => pair.Key, pair => pair.Value);
            data.pageActions = data.pageActionsList.ToDictionary(pair => pair.Key, pair => pair.Value);
            if (data != null)
            {
                templates.Add(template, data);
                return(true);
            }
            return(false);
        }
Exemple #8
0
        private static void ConfigureServices(IConfiguration configuration, IServiceCollection serviceCollection)
        {
            //Realiza a leitura das configurações para uso de porta Serial.
            ISerialConfiguration serialConfiguration = new SerialConfiguration();

            configuration.GetSection("SerialConnection").Bind(serialConfiguration);

            IElasticsearchConfiguration elasticConfiguration = new ElasticsearchConfiguration();

            configuration.GetSection("elasticSearch").Bind(elasticConfiguration);

            IDataAccess _dataAccess = DataAccessFactory.Create(elasticConfiguration, null);

            // DI
            serviceCollection.AddSingleton <IConfiguration>(configuration);
            serviceCollection.AddSingleton <ISerialConfiguration>(serialConfiguration);
            serviceCollection.AddSingleton <IElasticsearchConfiguration>(elasticConfiguration);
            serviceCollection.AddSingleton <IDataAccess>(_dataAccess);
            serviceCollection.AddSingleton <IScanner, Scanner>();
        }
Exemple #9
0
 public void Setup()
 {
     CreateDatabase();
     _subject = DataAccessFactory.Create(TestConnectionString);
 }
Exemple #10
0
 public BusinessBL()
 {
     this._repository = DataAccessFactory <T> .Create();
 }