public void Can_Perform_Update_On_RelationTypeRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

            // Act
            var relationType = repository.Get(3);
            relationType.Alias = relationType.Alias + "Updated";
            relationType.Name = relationType.Name + " Updated";
            repository.AddOrUpdate(relationType);
            unitOfWork.Commit();

            var relationTypeUpdated = repository.Get(3);

            // Assert
            Assert.That(relationTypeUpdated, Is.Not.Null);
            Assert.That(relationTypeUpdated.HasIdentity, Is.True);
            Assert.That(relationTypeUpdated.Alias, Is.EqualTo(relationType.Alias));
            Assert.That(relationTypeUpdated.Name, Is.EqualTo(relationType.Name));
        }
Ejemplo n.º 2
0
        public void Can_Perform_Update_On_RelationTypeRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

            // Act
            var relationType = repository.Get(3);

            relationType.Alias = relationType.Alias + "Updated";
            relationType.Name  = relationType.Name + " Updated";
            repository.AddOrUpdate(relationType);
            unitOfWork.Commit();

            var relationTypeUpdated = repository.Get(3);

            // Assert
            Assert.That(relationTypeUpdated, Is.Not.Null);
            Assert.That(relationTypeUpdated.HasIdentity, Is.True);
            Assert.That(relationTypeUpdated.Alias, Is.EqualTo(relationType.Alias));
            Assert.That(relationTypeUpdated.Name, Is.EqualTo(relationType.Name));
        }
        public void Can_Perform_Update_On_RelationTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                RelationTypeRepository repository = CreateRepository(provider);

                // Act
                IRelationType relationType = repository.Get(3);
                relationType.Alias += "Updated";
                relationType.Name  += " Updated";
                repository.Save(relationType);

                IRelationType relationTypeUpdated = repository.Get(3);

                // Assert
                Assert.That(relationTypeUpdated, Is.Not.Null);
                Assert.That(relationTypeUpdated.HasIdentity, Is.True);
                Assert.That(relationTypeUpdated.Alias, Is.EqualTo(relationType.Alias));
                Assert.That(relationTypeUpdated.Name, Is.EqualTo(relationType.Name));
            }
        }
Ejemplo n.º 4
0
        public void Can_Perform_Get_On_RelationTypeRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

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

            // Assert
            Assert.That(relationType, Is.Not.Null);
            Assert.That(relationType.HasIdentity, Is.True);
            Assert.That(relationType.Alias, Is.EqualTo("relateContentOnCopy"));
            Assert.That(relationType.Name, Is.EqualTo("Relate Content on Copy"));
        }
Ejemplo n.º 5
0
        public void Can_Perform_Delete_On_RelationTypeRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

            // Act
            var relationType = repository.Get(3);

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

            var exists = repository.Exists(3);

            // Assert
            Assert.That(exists, Is.False);
        }
        public void Can_Perform_Add_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 relationType = repositoryType.Get(1);
            var relation = new Relation(1047, 1048, relationType);
            repository.AddOrUpdate(relation);
            unitOfWork.Commit();

            // Assert
            Assert.That(relation, Is.Not.Null);
            Assert.That(relation.HasIdentity, Is.True);
        }
        public void Can_Perform_Delete_On_RelationTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                RelationTypeRepository repository = CreateRepository(provider);

                // Act
                IRelationType relationType = repository.Get(3);
                repository.Delete(relationType);

                bool exists = repository.Exists(3);

                // Assert
                Assert.That(exists, Is.False);
            }
        }
Ejemplo n.º 8
0
        public void Can_Perform_Add_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 relationType = repositoryType.Get(1);
            var relation     = new Relation(1047, 1048, relationType);

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

            // Assert
            Assert.That(relation, Is.Not.Null);
            Assert.That(relation.HasIdentity, Is.True);
        }
        public void Can_Perform_GetByQuery_On_RelationTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                RelationTypeRepository repository = CreateRepository(provider);

                // Act
                System.Guid                 childObjType = Constants.ObjectTypes.DocumentType;
                IQuery <IRelationType>      query        = scope.SqlContext.Query <IRelationType>().Where(x => x.ChildObjectType == childObjType);
                IEnumerable <IRelationType> result       = repository.Get(query);

                // Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Any(), Is.True);
                Assert.That(result.Any(x => x == null), Is.False);
                Assert.That(result.Count(), Is.EqualTo(1));
            }
        }
        public void Can_Perform_Get_On_RelationTypeRepository()
        {
            // Arrange
            IScopeProvider provider = ScopeProvider;

            using (provider.CreateScope())
            {
                RelationTypeRepository repository = CreateRepository(provider);

                // Act
                IRelationType relationType = repository.Get(8);

                // Assert
                Assert.That(relationType, Is.Not.Null);
                Assert.That(relationType.HasIdentity, Is.True);
                Assert.That(relationType.IsBidirectional, Is.True);
                Assert.That(relationType.Alias, Is.EqualTo("relateContentToMedia"));
                Assert.That(relationType.Name, Is.EqualTo("Relate Content to Media"));
                Assert.That(relationType.ChildObjectType, Is.EqualTo(Constants.ObjectTypes.Media));
                Assert.That(relationType.ParentObjectType, Is.EqualTo(Constants.ObjectTypes.Document));
            }
        }
        public void Can_Perform_Delete_On_RelationTypeRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

            // Act
            var relationType = repository.Get(3);
            repository.Delete(relationType);
            unitOfWork.Commit();

            var exists = repository.Exists(3);

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

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

            // Assert
            Assert.That(relationType, Is.Not.Null);
            Assert.That(relationType.HasIdentity, Is.True);
            Assert.That(relationType.Alias, Is.EqualTo("relateContentOnCopy"));
            Assert.That(relationType.Name, Is.EqualTo("Relate Content on Copy"));
        }