Exemplo n.º 1
0
        public void Can_Perform_Update_On_RelationRepository()
        {
            // Arrange
            using (IScope scope = ScopeProvider.CreateScope())
            {
                RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType);

                // Act
                IRelation relation = repository.Get(1);
                relation.Comment = "This relation has been updated";
                repository.Save(relation);

                IRelation relationUpdated = repository.Get(1);

                // Assert
                Assert.That(relationUpdated, Is.Not.Null);
                Assert.That(relationUpdated.Comment, Is.EqualTo("This relation has been updated"));
                Assert.AreNotEqual(relationUpdated.UpdateDate, relation.UpdateDate);
            }
        }
        public void Can_Perform_Update_On_RelationRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(1);
            relation.Comment = "This relation has been updated";
            repository.AddOrUpdate(relation);
            unitOfWork.Commit();

            var relationUpdated = repository.Get(1);

            // Assert
            Assert.That(relationUpdated, Is.Not.Null);
            Assert.That(relationUpdated.Comment, Is.EqualTo("This relation has been updated"));
            Assert.AreNotEqual(relationUpdated.UpdateDate, relation.UpdateDate);
        }
Exemplo n.º 3
0
        public void Can_Perform_Update_On_RelationRepository()
        {
            // Arrange
            var provider       = new PetaPocoUnitOfWorkProvider();
            var unitOfWork     = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository     = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(1);

            relation.Comment = "This relation has been updated";
            repository.AddOrUpdate(relation);
            unitOfWork.Commit();

            var relationUpdated = repository.Get(1);

            // Assert
            Assert.That(relationUpdated, Is.Not.Null);
            Assert.That(relationUpdated.Comment, Is.EqualTo("This relation has been updated"));
            Assert.AreNotEqual(relationUpdated.UpdateDate, relation.UpdateDate);
        }
Exemplo n.º 4
0
        public void Can_Perform_Delete_On_RelationRepository()
        {
            // Arrange
            using (IScope scope = ScopeProvider.CreateScope())
            {
                RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType);

                // Act
                IRelation relation = repository.Get(2);
                repository.Delete(relation);

                bool exists = repository.Exists(2);

                // Assert
                Assert.That(exists, Is.False);
            }
        }
Exemplo n.º 5
0
        public void Can_Perform_Get_On_RelationRepository()
        {
            // Arrange
            var provider       = new PetaPocoUnitOfWorkProvider();
            var unitOfWork     = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository     = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(1);

            // Assert
            Assert.That(relation, Is.Not.Null);
            Assert.That(relation.HasIdentity, Is.True);
            Assert.That(relation.ChildId, Is.EqualTo(1047));
            Assert.That(relation.ParentId, Is.EqualTo(1046));
            Assert.That(relation.RelationType.Alias, Is.EqualTo("relateContentOnCopy"));
        }
Exemplo n.º 6
0
        public void Can_Perform_GetByQuery_On_RelationRepository()
        {
            // Arrange
            using (IScope scope = ScopeProvider.CreateScope())
            {
                RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType);

                // Act
                IQuery <IRelation>      query     = ScopeProvider.CreateQuery <IRelation>().Where(x => x.RelationTypeId == _relateContent.Id);
                IEnumerable <IRelation> relations = repository.Get(query);

                // Assert
                Assert.That(relations, Is.Not.Null);
                Assert.That(relations.Any(), Is.True);
                Assert.That(relations.Any(x => x == null), Is.False);
                Assert.That(relations.Count(), Is.EqualTo(2));
            }
        }
Exemplo n.º 7
0
        public void Can_Perform_Get_On_RelationRepository()
        {
            // Arrange
            using (IScope scope = ScopeProvider.CreateScope())
            {
                RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType);

                // Act
                IRelation relation = repository.Get(1);

                // Assert
                Assert.That(relation, Is.Not.Null);
                Assert.That(relation.HasIdentity, Is.True);
                Assert.That(relation.ChildId, Is.EqualTo(_subpage.Id));
                Assert.That(relation.ParentId, Is.EqualTo(_textpage.Id));
                Assert.That(relation.RelationType.Alias, Is.EqualTo("relateContentOnCopy"));
            }
        }
Exemplo n.º 8
0
        public void Can_Perform_Delete_On_RelationRepository()
        {
            // Arrange
            var provider       = new PetaPocoUnitOfWorkProvider();
            var unitOfWork     = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository     = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(2);

            repository.Delete(relation);
            unitOfWork.Commit();

            var exists = repository.Exists(2);

            // Assert
            Assert.That(exists, Is.False);
        }
        public void Can_Perform_Delete_On_RelationRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(2);
            repository.Delete(relation);
            unitOfWork.Commit();

            var exists = repository.Exists(2);

            // Assert
            Assert.That(exists, Is.False);
        }
        public void Can_Perform_Get_On_RelationRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repositoryType = new RelationTypeRepository(unitOfWork);
            var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType);

            // Act
            var relation = repository.Get(1);

            // Assert
            Assert.That(relation, Is.Not.Null);
            Assert.That(relation.HasIdentity, Is.True);
            Assert.That(relation.ChildId, Is.EqualTo(1047));
            Assert.That(relation.ParentId, Is.EqualTo(1046));
            Assert.That(relation.RelationType.Alias, Is.EqualTo("relateContentOnCopy"));
        }