public void NPocoRepository_Add_Inserts_Item_Into_DataBase()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
                            {
                                Age = TestConstants.NPOCO_InsertDogAge,
                                Name = TestConstants.NPOCO_InsertDogName
                            };

            //Act
            repository.Add(dog);

            //Assert
            int actualCount = DataUtil.GetRecordCount(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName);
            Assert.AreEqual(TestConstants.NPOCO_RecordCount + 1, actualCount);
        }
예제 #2
0
        public void NPocoRepository_Add_Inserts_Item_Into_DataBase()
        {
            //Arrange
            var mockCache = new Mock <ICacheProvider>();

            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                Age  = TestConstants.NPOCO_InsertDogAge,
                Name = TestConstants.NPOCO_InsertDogName
            };

            //Act
            repository.Add(dog);

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

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

            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository <Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog        = new Dog
            {
                Age  = TestConstants.NPOCO_InsertDogAge,
                Name = TestConstants.NPOCO_InsertDogName
            };

            //Act
            repository.Add(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName);
            DataRow   row   = table.Rows[table.Rows.Count - 1];

            Assert.AreEqual(TestConstants.NPOCO_InsertDogAge, row["Age"]);
            Assert.AreEqual(TestConstants.NPOCO_InsertDogName, row["Name"]);
        }
        public void NPocoRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ColumnValues()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.NPOCO_RecordCount);

            var repository = new NPocoRepository<Dog>(_nPocoUnitOfWork, mockCache.Object);
            var dog = new Dog
            {
                Age = TestConstants.NPOCO_InsertDogAge,
                Name = TestConstants.NPOCO_InsertDogName
            };

            //Act
            repository.Add(dog);

            //Assert
            DataTable table = DataUtil.GetTable(TestConstants.NPOCO_DatabaseName, TestConstants.NPOCO_TableName);
            DataRow row = table.Rows[table.Rows.Count - 1];

            Assert.AreEqual(TestConstants.NPOCO_InsertDogAge, row["Age"]);
            Assert.AreEqual(TestConstants.NPOCO_InsertDogName, row["Name"]);
        }