Ejemplo n.º 1
0
        public void RavenDBRepository_Add_Inserts_Item_Into_DataBase_With_Correct_ColumnValues()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            using (IDocumentSession _ravenDB = RavenDBDocumentStore.Instance.OpenSession())
            {
                var repository = new RavenDBRepository<Dog>(_ravenDB, mockCache.Object);
                var dog = new Dog
                {
                    Age = TestConstants.PETAPOCO_InsertDogAge,
                    Name = TestConstants.PETAPOCO_InsertDogName
                };

                //Act
                repository.Add(dog);

                //The change is not persisted until the session's changes are saved
                _ravenDB.SaveChanges();
            }

            //Assert
            Thread.Sleep(5000);
            Dog newDog = GetLastItemAdded();
            Assert.AreEqual(TestConstants.PETAPOCO_InsertDogAge, newDog.Age);
            Assert.AreEqual(TestConstants.PETAPOCO_InsertDogName, newDog.Name);
        }
Ejemplo n.º 2
0
        public void RavenDBRepository_Add_Inserts_Item_Into_DataBase()
        {
            //Arrange
            var mockCache = new Mock<ICacheProvider>();
            SetUpDatabase(TestConstants.PETAPOCO_RecordCount);

            using (IDocumentSession _ravenDB = RavenDBDocumentStore.Instance.OpenSession())
            {
                var repository = new RavenDBRepository<Dog>(_ravenDB, mockCache.Object);
                var dog = new Dog
                {
                    Age = TestConstants.PETAPOCO_InsertDogAge,
                    Name = TestConstants.PETAPOCO_InsertDogName
                };

                //Act
                repository.Add(dog);

                //The change is not persisted until the session's changes are saved
                _ravenDB.SaveChanges();
            }

            //Assert
            Thread.Sleep(5000);
            int actualCount;
            using (IDocumentSession session = RavenDBDocumentStore.Instance.OpenSession())
            {
                actualCount = session.Query<Dog>().Count();
            }
            Assert.AreEqual(TestConstants.PETAPOCO_RecordCount + 1, actualCount);
        }