public void Test_ExecuteScripts_TwoFileContent()
        {
            const bool expectedResult = true;
            const string fileContent = @"create table BackendUser (BackendUserId int, Username nvarchar(30))
                                  ;
                                  insert into BackendUser values(1, ""I must go home.""))
                                  ;";

            var dbConnectionMock = new Mock<IDbConnection>();
            var databaseMock = new Mock<IDatabase>();
            var dbCommandMock = new Mock<IDbCommand>();

            databaseMock.Setup(t => t.GetDbConnection()).Returns(dbConnectionMock.Object);
            databaseMock.Setup(t => t.GetDbCommand()).Returns(dbCommandMock.Object);

            dbConnectionMock.Setup(t => t.Open());
            dbCommandMock.Setup(t => t.ExecuteNonQuery());

            IDbProvider provider = new FireBirdDbProvider(databaseMock.Object);
            var actualResult = provider.ExecuteScript(fileContent);

            dbCommandMock.VerifyAll();
            databaseMock.VerifyAll();
            dbCommandMock.VerifyAll();

            Assert.Equal(expectedResult, actualResult);
        }
        /// <summary>
        /// Gets database provider.
        /// </summary>
        /// <returns><see cref="Vega.DbUpgrade.Interfaces.IDbProvider"/> object.</returns>
        public static IDbProvider GetDbProvider()
        {
            IDbProvider retVal = null;

            string providerName = ConfigurationManager.AppSettings[Constants.AppSettingKeys.DatabaseProvider];
            if (!String.IsNullOrEmpty(providerName))
            {
                if (Enum.IsDefined(typeof(DBProviders), providerName.ToLower()))
                {
                    var provider = (DBProviders)Enum.Parse(typeof(DBProviders), providerName, true);
                    switch (provider)
                    {
                        case DBProviders.mssql:
                            retVal = new MsSqlDbProvider(new MsSqlDatabase());
                            break;
                        case DBProviders.mysql:
                            retVal = new MySqlDbProvider(new MySqlDatabase());
                            break;
                        case DBProviders.firebird:
                            retVal = new FireBirdDbProvider(new FirebirdDatabase());
                            break;
                    }
                }
            }

            return retVal;
        }
        public void Test_GetChangeLogTableScript()
        {
            IDbProvider provider = new FireBirdDbProvider(new FirebirdDatabase());
            var actualString = provider.GetChangeLogTableScript();
            const string expectedString = Constants.ChangeLogTableScripts.FireBirdChangeLogTable;

            Assert.Equal(expectedString, actualString);
        }
        public void Test_ExecuteScripts_OneFileContent()
        {
            const string fileContent = "Firebird Script";
            const bool expectedResult = true;

            var dbConnectionMock = new Mock<IDbConnection>();
            var databaseMock = new Mock<IDatabase>();
            var dbCommandMock = new Mock<IDbCommand>();

            databaseMock.Setup(t => t.GetDbConnection()).Returns(dbConnectionMock.Object);
            databaseMock.Setup(t => t.GetDbCommand()).Returns(dbCommandMock.Object);

            dbConnectionMock.Setup(t => t.Open());
            dbCommandMock.Setup(t => t.ExecuteNonQuery());

            IDbProvider provider = new FireBirdDbProvider(databaseMock.Object);
            var actualResult = provider.ExecuteScript(fileContent);

            dbCommandMock.VerifyAll();
            databaseMock.VerifyAll();
            dbCommandMock.VerifyAll();

            Assert.Equal(expectedResult, actualResult);
        }