Esempio n. 1
0
        public void PetaPocoRepository_Update_Overload_Updates_Item_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);

            //Act
            repository.Update("SET Age=@1, Name=@2 WHERE ID=@0", Constants.PETAPOCO_UpdateDogId, Constants.PETAPOCO_UpdateDogAge, Constants.PETAPOCO_UpdateDogName);

            //Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);

            foreach (DataRow row in table.Rows)
            {
                if ((int)row[Constants.TABLENAME_Key] == Constants.PETAPOCO_UpdateDogId)
                {
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogAge, row["Age"]);
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogName, row["Name"]);
                }
            }
        }
        public void PetaPocoRepository_Update_Updates_Item_With_Correct_ID()
        {
            //Arrange
            var mockCache = new Mock <ICacheProvider>();

            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(_petaPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                ID   = TestConstants.PETAPOCO_UpdateDogId,
                Age  = TestConstants.PETAPOCO_UpdateDogAge,
                Name = TestConstants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.PETAPOCO_DatabaseName, TestConstants.PETAPOCO_TableName);

            foreach (DataRow row in table.Rows)
            {
                if ((int)row["ID"] == TestConstants.PETAPOCO_UpdateDogId)
                {
                    Assert.AreEqual(TestConstants.PETAPOCO_UpdateDogAge, row["Age"]);
                    Assert.AreEqual(TestConstants.PETAPOCO_UpdateDogName, row["Name"]);
                }
            }
        }
Esempio n. 3
0
        public void PetaPocoRepository_Update_Updates_Item_In_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
            {
                ID   = Constants.PETAPOCO_UpdateDogId,
                Age  = Constants.PETAPOCO_UpdateDogAge,
                Name = Constants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

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

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

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(db, mapper);

            // Act
            repository.Update("SET Age=@1, Name=@2 WHERE ID=@0", Constants.PETAPOCO_UpdateDogId, Constants.PETAPOCO_UpdateDogAge, Constants.PETAPOCO_UpdateDogName);

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

            Assert.AreEqual(Constants.PETAPOCO_RecordCount, actualCount);
        }
Esempio n. 5
0
        public void PetaPocoRepository_Update_Updates_Item_With_Correct_ID_Using_FluentMapper()
        {
            //Arrange
            var db     = 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
            {
                ID   = Constants.PETAPOCO_UpdateDogId,
                Age  = Constants.PETAPOCO_UpdateDogAge,
                Name = Constants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

            //Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);

            foreach (DataRow row in table.Rows)
            {
                if ((int)row[Constants.TABLENAME_Key] == Constants.PETAPOCO_UpdateDogId)
                {
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogAge, row["Age"]);
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogName, row["Name"]);
                }
            }
        }
        public void PetaPocoRepository_Update_Updates_Item_In_DataBase()
        {
            //Arrange
            var mockCache = new Mock <ICacheProvider>();

            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository <Dog>(_petaPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                ID   = TestConstants.PETAPOCO_UpdateDogId,
                Age  = TestConstants.PETAPOCO_UpdateDogAge,
                Name = TestConstants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

            //Assert
            int actualCount = DataUtil.GetRecordCount(TestConstants.PETAPOCO_DatabaseName,
                                                      TestConstants.PETAPOCO_TableName);

            Assert.AreEqual(TestConstants.PETAPOCO_RecordCount, actualCount);
        }
        public void PetaPocoRepository_Update_Overload_Updates_Item_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);

            //Act
            repository.Update("SET Age=@1, Name=@2 WHERE ID=@0", Constants.PETAPOCO_UpdateDogId, Constants.PETAPOCO_UpdateDogAge, Constants.PETAPOCO_UpdateDogName);

            //Assert
            DataTable table = DataUtil.GetTable(Constants.PETAPOCO_DatabaseName, Constants.PETAPOCO_DogTableName);
            foreach (DataRow row in table.Rows)
            {
                if ((int)row[Constants.TABLENAME_Key] == Constants.PETAPOCO_UpdateDogId)
                {
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogAge, row["Age"]);
                    Assert.AreEqual(Constants.PETAPOCO_UpdateDogName, row["Name"]);
                }
            }
        }
        public void PetaPocoRepository_Update_Overload_Updates_Item_In_DataBase()
        {
            //Arrange
            var db = CreatePecaPocoDatabase();
            var mapper = new PetaPocoMapper(String.Empty);

            DataUtil.SetUpDatabase(Constants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(db, mapper);

            //Act
            repository.Update("SET Age=@1, Name=@2 WHERE ID=@0", Constants.PETAPOCO_UpdateDogId, Constants.PETAPOCO_UpdateDogAge, Constants.PETAPOCO_UpdateDogName);

            //Assert
            int actualCount = DataUtil.GetRecordCount(Constants.PETAPOCO_DatabaseName,
                                                      Constants.PETAPOCO_DogTableName);
            Assert.AreEqual(Constants.PETAPOCO_RecordCount, actualCount);
        }
        public void PetaPocoRepository_Update_Updates_Item_With_Correct_ID()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(_petaPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
            {
                ID = TestConstants.PETAPOCO_UpdateDogId,
                Age = TestConstants.PETAPOCO_UpdateDogAge,
                Name = TestConstants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.PETAPOCO_DatabaseName, TestConstants.PETAPOCO_TableName);
            foreach (DataRow row in table.Rows)
            {
                if ((int)row["ID"] == TestConstants.PETAPOCO_UpdateDogId)
                {
                    Assert.AreEqual(TestConstants.PETAPOCO_UpdateDogAge, row["Age"]);
                    Assert.AreEqual(TestConstants.PETAPOCO_UpdateDogName, row["Name"]);
                }
            }
        }
        public void PetaPocoRepository_Update_Updates_Item_In_DataBase()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            var repository = new PetaPocoRepository<Dog>(_petaPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
            {
                ID = TestConstants.PETAPOCO_UpdateDogId,
                Age = TestConstants.PETAPOCO_UpdateDogAge,
                Name = TestConstants.PETAPOCO_UpdateDogName
            };

            //Act
            repository.Update(dog);

            //Assert
            int actualCount = DataUtil.GetRecordCount(TestConstants.PETAPOCO_DatabaseName,
                TestConstants.PETAPOCO_TableName);
            Assert.AreEqual(TestConstants.PETAPOCO_RecordCount, actualCount);
        }