Beispiel #1
0
        public void SQLiteUnit_SeveralCommands_ReturnTrue()
        {
            // Arrange
            var names = new string[]
            {
                this.FirstName1,
                this.FirstName2,
                this.FirstName3
            };
            var lastNames = new string[]
            {
                this.LastName1,
                this.LastName2,
                this.LastName3
            };
            var commands = new List <string>();

            for (int i = 0; i < names.Length; i++)
            {
                string command =
                    $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                    + $"VALUES ({i}, '{names[i]}', '{lastNames[i]}')";
                commands.Add(command);
            }

            // Act
            SQLiteManager.ExecuteCommandsInTransaction(
                this.PathToDataBase,
                commands);

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

            for (int i = 0; i < names.Length; i++)
            {
                var firstNameInDb = personsInDatabase[i][0];
                var lastNameInDb  = personsInDatabase[i][1];
                Assert.AreEqual(names[i], firstNameInDb);
                Assert.AreEqual(lastNames[i], lastNameInDb);
            }
        }
Beispiel #2
0
        public void SQLiteUnit_OneCommand_ReturnTrue()
        {
            // Arrange
            string command =
                $"INSERT INTO {this.DbTableName}({this.DbFieldId}, {this.DbFieldFirstName}, {this.DbFieldLastName}) "
                + $"VALUES (1, '{this.FirstName1}', '{this.LastName1}')";

            // Act
            SQLiteManager.ExecuteCommandsInTransaction(
                this.PathToDataBase,
                new List <string> {
                command
            });

            // 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);
        }