public void SQLiteUnit_RunAndRollbackUnitWithOneCommandBadCommand_ReturnTrue()
        {
            // Arrange
            var unit = new SQLiteUnit(this.PathToDataBase);

            for (int i = 0; i < this.Names.Length; i++)
            {
                int    id      = i + 1;
                string command =
                    $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                    + $"VALUES ({id}, '{this.Names[i]}', '{this.LastNames[i]}')";
                string rollbackComand = $"DELETE FROM {this.DbTableName} WHERE {DbFieldId} = {id}";

                if (i == 2)
                {
                    string badField = "String instead of integer value";
                    command =
                        $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                        + $"VALUES ({badField}, '{this.FirstName1}', '{this.LastName1}')";
                }

                unit.AddSqliteCommand(command, rollbackComand);
            }

            // Assert
            Assert.Throws <CommitException>(() => unit.Commit());
            var personsInDatabase = this.GetInfOfDataBase();

            Assert.IsTrue(!personsInDatabase.Any());
        }
        public void SQLiteUnit_SeveralCommandsInUnit_ReturnTrue()
        {
            // Arrange
            var unit = new SQLiteUnit(this.PathToDataBase);

            for (int i = 0; i < this.Names.Length; i++)
            {
                string command =
                    $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                    + $"VALUES ({i}, '{this.Names[i]}', '{this.LastNames[i]}')";
                unit.AddSqliteCommand(command, string.Empty);
            }

            // Act
            unit.Commit();

            // Assert
            var personsInDatabase = this.GetInfOfDataBase();

            for (int i = 0; i < this.Names.Length; i++)
            {
                var firstNameInDb = personsInDatabase[i][0];
                var lastNameInDb  = personsInDatabase[i][1];
                Assert.AreEqual(this.Names[i], firstNameInDb);
                Assert.AreEqual(this.LastNames[i], lastNameInDb);
            }
        }
        public void SQLiteUnit_BadCommandInUnitAndThrowException_ReturnTrue()
        {
            // Arrange
            var    unit    = new SQLiteUnit(this.PathToDataBase);
            string command =
                $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}, FAKE_COLUMN) "
                + $"VALUES (1, '{this.FirstName1}', '{this.LastName1}', 'FAKE FIELD')";

            unit.AddSqliteCommand(command, string.Empty);

            // Assert
            Assert.Throws <CommitException>(() => unit.Commit());
        }
        public void SQLiteUnit_BadFieldInCommandAndThrowException_ReturnTrue()
        {
            // Arrange
            var    unit     = new SQLiteUnit(this.PathToDataBase);
            string badField = "String instead of integer value";
            string command  =
                $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                + $"VALUES ({badField}, '{this.FirstName1}', '{this.LastName1}')";

            unit.AddSqliteCommand(command, string.Empty);

            // Assert
            Assert.Throws <CommitException>(() => unit.Commit());
        }
        public void SQLiteUnit_RollbackUnitWithOneCommand_ReturnTrue()
        {
            // Arrange
            var    unit    = new SQLiteUnit(this.PathToDataBase);
            string command =
                $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                + $"VALUES (1, '{this.FirstName1}', '{this.LastName1}')";
            string rollbackCommand = $"DELETE FROM {this.DbTableName} WHERE {DbFieldId} = 1";

            unit.AddSqliteCommand(command, rollbackCommand);

            // Act
            unit.Commit();
            unit.Rollback();

            // Assert
            var personsInDatabase = this.GetInfOfDataBase();

            Assert.IsTrue(!personsInDatabase.Any());
        }
        public void SQLiteUnit_OneCommandInUnit_ReturnTrue()
        {
            // Arrange
            var    unit    = new SQLiteUnit(this.PathToDataBase);
            string command =
                $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                + $"VALUES (1, '{this.FirstName1}', '{this.LastName1}')";

            unit.AddSqliteCommand(command, string.Empty);

            // Act
            unit.Commit();

            // Assert
            var personsInDatabase = this.GetInfOfDataBase();
            var firstNameInDb     = personsInDatabase[0][0];
            var lastNameInDb      = personsInDatabase[0][1];

            Assert.AreEqual(this.FirstName1, firstNameInDb);
            Assert.AreEqual(this.LastName1, lastNameInDb);
        }
        public void SQLiteUnit_RollbackUnitWithSeveralCommands_ReturnTrue()
        {
            // Arrange
            var unit = new SQLiteUnit(this.PathToDataBase);

            for (int i = 0; i < this.Names.Length; i++)
            {
                int    id      = i + 1;
                string command =
                    $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                    + $"VALUES ({id}, '{Names[i]}', '{this.LastNames[i]}')";
                string rollbackComand = $"DELETE FROM {this.DbTableName} WHERE {DbFieldId} = {id}";
                unit.AddSqliteCommand(command, rollbackComand);
            }

            // Act
            unit.Commit();
            unit.Rollback();

            // Assert
            var personsInDatabase = this.GetInfOfDataBase();

            Assert.IsTrue(!personsInDatabase.Any());
        }