public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ColumnValues_Using_FluentMapper()
        {
            // Arrange
            var db     = this.CreatePecaPocoDatabase();
            var mapper = new FluentMapper <Dog>(string.Empty);

            mapper.TableName(Constants.PETAPOCO_DogTableName);
            mapper.PrimaryKey("ID");
            mapper.Property(d => d.ID, "ID");
            mapper.Property(d => d.Age, "Age");
            mapper.Property(d => d.Name, "Name");

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(db, mapper);
            var dog        = new Dog
            {
                Age  = Constants.PETAPOCO_InsertDogAge,
                Name = Constants.PETAPOCO_InsertDogName,
            };

            // Act
            repository.Insert(dog);

            // Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);
            DataRow   row   = table.Rows[table.Rows.Count - 1];

            Assert.AreEqual(Constants.PETAPOCO_InsertDogAge, row["Age"]);
            Assert.AreEqual(Constants.PETAPOCO_InsertDogName, row["Name"]);
        }
Example #2
0
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ColumnValues()
        {
            //Arrange
            var db     = CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(String.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(db, mapper);
            var dog        = new Dog
            {
                Age  = Constants.PETAPOCO_InsertDogAge,
                Name = Constants.PETAPOCO_InsertDogName
            };

            //Act
            repository.Insert(dog);

            //Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);
            DataRow   row   = table.Rows[table.Rows.Count - 1];

            Assert.AreEqual(Constants.PETAPOCO_InsertDogAge, row["Age"]);
            Assert.AreEqual(Constants.PETAPOCO_InsertDogName, row["Name"]);
        }
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ID()
        {
            // Arrange
            var db     = this.CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(string.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(db, mapper);
            var dog        = new Dog
            {
                Age  = Constants.PETAPOCO_InsertDogAge,
                Name = Constants.PETAPOCO_InsertDogName,
            };

            // Act
            repository.Insert(dog);

            // Assert
            int newId = DataUtil.GetLastAddedRecordID(
                Constants.PETAPOCO_DatabaseName,
                Constants.PETAPOCO_DogTableName, Constants.TABLENAME_Key);

            Assert.AreEqual(Constants.PETAPOCO_RecordCount + 1, newId);
        }
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase()
        {
            // Arrange
            var db     = this.CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(string.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(db, mapper);
            var dog        = new Dog
            {
                Age  = Constants.PETAPOCO_InsertDogAge,
                Name = Constants.PETAPOCO_InsertDogName,
            };

            // Act
            repository.Insert(dog);

            // Assert
            int actualCount = DataUtil.GetRecordCount(
                Constants.PETAPOCO_DatabaseName,
                Constants.PETAPOCO_DogTableName);

            Assert.AreEqual(Constants.PETAPOCO_RecordCount + 1, actualCount);
        }
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ColumnValues()
        {
            //Arrange
            var db = CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(String.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(db, mapper);
            var dog = new Dog
                            {
                                Age = Constants.PETAPOCO_InsertDogAge,
                                Name = Constants.PETAPOCO_InsertDogName
                            };

            //Act
            repository.Insert(dog);

            //Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);
            DataRow row = table.Rows[table.Rows.Count - 1];

            Assert.AreEqual(Constants.PETAPOCO_InsertDogAge, row["Age"]);
            Assert.AreEqual(Constants.PETAPOCO_InsertDogName, row["Name"]);
        }
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ID()
        {
            //Arrange
            var db = CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(String.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(db, mapper);
            var dog = new Dog
                            {
                                Age = Constants.PETAPOCO_InsertDogAge,
                                Name = Constants.PETAPOCO_InsertDogName
                            };

            //Act
            repository.Insert(dog);

            //Assert
            int newId = DataUtil.GetLastAddedRecordID(Constants.PETAPOCO_DatabaseName,
                                                      Constants.PETAPOCO_DogTableName, Constants.TABLENAME_Key);
            Assert.AreEqual(Constants.PETAPOCO_RecordCount + 1, newId);
        }
        public void PetaPocoRepository_Add_Inserts_Item_Into_DataBase()
        {
            //Arrange
            var db = CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(String.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(db, mapper);
            var dog = new Dog
                            {
                                Age = Constants.PETAPOCO_InsertDogAge,
                                Name = Constants.PETAPOCO_InsertDogName
                            };

            //Act
            repository.Insert(dog);

            //Assert
            int actualCount = DataUtil.GetRecordCount(Constants.PETAPOCO_DatabaseName,
                                                      Constants.PETAPOCO_DogTableName);
            Assert.AreEqual(Constants.PETAPOCO_RecordCount + 1, actualCount);
        }