예제 #1
0
        public void NPocoRepository_Delete_Does_Nothing_With_Invalid_ID()
        {
            //Arrange
            var mockCache = new Mock <ICacheProvider>();

            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                ID   = TestConstants.NPOCO_InvalidDogId,
                Age  = TestConstants.NPOCO_DeleteDogAge,
                Name = TestConstants.NPOCO_DeleteDogName
            };

            //Act
            repository.Delete(dog);

            //Assert
            //Assert
            int actualCount = DataUtil.GetRecordCount(TestConstants.NPOCO_DatabaseName,
                                                      TestConstants.NPOCO_TableName);

            Assert.AreEqual(TestConstants.NPOCO_RecordCount, actualCount);
        }
예제 #2
0
        public void NPocoRepository_Delete_Deletes_Item_From_DataBase_With_Correct_ID()
        {
            //Arrange
            var mockCache = new Mock <ICacheProvider>();

            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                ID   = TestConstants.NPOCO_DeleteDogId,
                Age  = TestConstants.NPOCO_DeleteDogAge,
                Name = TestConstants.NPOCO_DeleteDogName
            };

            //Act
            repository.Delete(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName);

            foreach (DataRow row in table.Rows)
            {
                Assert.IsFalse((int)row["ID"] == TestConstants.NPOCO_DeleteDogId);
            }
        }
        public void NPocoRepository_Delete_Does_Nothing_With_Invalid_ID()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
            {
                ID = TestConstants.NPOCO_InvalidDogId,
                Age = TestConstants.NPOCO_DeleteDogAge,
                Name = TestConstants.NPOCO_DeleteDogName
            };

            //Act
            repository.Delete(dog);

            //Assert
            //Assert
            int actualCount = DataUtil.GetRecordCount(TestConstants.NPOCO_DatabaseName,
                TestConstants.NPOCO_TableName);
            Assert.AreEqual(TestConstants.NPOCO_RecordCount, actualCount);
        }
        public void NPocoRepository_Delete_Deletes_Item_From_DataBase_With_Correct_ID()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
            {
                ID = TestConstants.NPOCO_DeleteDogId,
                Age = TestConstants.NPOCO_DeleteDogAge,
                Name = TestConstants.NPOCO_DeleteDogName
            };

            //Act
            repository.Delete(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName);
            foreach (DataRow row in table.Rows)
            {
                Assert.IsFalse((int)row["ID"] == TestConstants.NPOCO_DeleteDogId);
            }
        }