static void Main() { IBDRepository bdRepository = new BDRepository(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool appliOuverte = true; while (appliOuverte) { IPersonneRepository personneRepository = new PersonneRepository(); IRelationRepository relationRepository = new RelationRepository(); LoginForm loginForm = new LoginForm(personneRepository, bdRepository); if (loginForm.ShowDialog() == DialogResult.OK) { int idUtilisateur = personneRepository.GetIdUtilisateur(loginForm.Login, loginForm.Password); MainForm mainForm = new MainForm(bdRepository, relationRepository, personneRepository, idUtilisateur); Application.Run(mainForm); } DeconnexionForm deconnexionForm = new DeconnexionForm(); if (deconnexionForm.ShowDialog() == DialogResult.No) { appliOuverte = false; } } }
public TreeContextExtension(TaxonomyTree tree, RelationRepository relationRepo, NHibernateBoxTransformation<RelationBoxMap, RelationEntity> relationTransformer) { _tree = tree; _relationRepo = relationRepo; this.relationTransformer = relationTransformer; }
private async Task GetMovieGenres(Movie movie) { var relationRepository = new RelationRepository(Configuration, MemoryCache); var isExist = MemoryCache.TryGetValue("CACHEMOVIERELATIONS" + movie.GetId(), out List <Relation> movieRelations); if (!isExist) { movieRelations = await relationRepository.GetRelationsByParent( movie.GetEntityCategoryId(), movie.GetId()); MemoryCache.Set("CACHEMOVIERELATIONS" + movie.GetId(), movieRelations); TrakkerCache.SaveCacheEntry("CACHEMOVIERELATIONS" + movie.GetId()); } var movieGenreRepository = new MovieGenreRepository(Configuration, MemoryCache); foreach (var relation in movieRelations) { if (relation.CategoryTo == MovieGenre.ENTITY_CATEGORY_ID) { movie.AddGenre(await movieGenreRepository.GetById(relation.EntityTo)); } } }
private RelationRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out RelationTypeRepository relationTypeRepository) { relationTypeRepository = new RelationTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of <ILogger>(), SqlSyntax); var repository = new RelationRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of <ILogger>(), SqlSyntax, relationTypeRepository); return(repository); }
public TreeContextExtension(TaxonomyTree tree, RelationRepository relationRepo, NHibernateBoxTransformation <RelationBoxMap, RelationEntity> relationTransformer) { _tree = tree; _relationRepo = relationRepo; this.relationTransformer = relationTransformer; }
public void Get_Paged_Parent_Child_Entities_With_Same_Entity_Relation() { // Create a media item and create a relationship between itself (parent -> child) MediaType imageType = MediaTypeBuilder.CreateImageMediaType("myImage"); MediaTypeService.Save(imageType); Media media = MediaBuilder.CreateMediaImage(imageType, -1); MediaService.Save(media); IRelationType relType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedMediaAlias); RelationService.Relate(media.Id, media.Id, relType); using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository relationTypeRepository); // Get parent entities for child id var parents = repository.GetPagedParentEntitiesByChildId(media.Id, 0, 10, out long totalRecords).ToList(); Assert.AreEqual(1, totalRecords); Assert.AreEqual(1, parents.Count); // Get child entities for parent id var children = repository.GetPagedChildEntitiesByParentId(media.Id, 0, 10, out totalRecords).ToList(); Assert.AreEqual(1, totalRecords); Assert.AreEqual(1, children.Count); } }
private RelationRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out RelationTypeRepository relationTypeRepository) { relationTypeRepository = new RelationTypeRepository(unitOfWork, NullCacheProvider.Current); var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, relationTypeRepository); return(repository); }
public void CreateTestData() { _relateContent = new RelationType( "Relate Content on Copy", "relateContentOnCopy", true, Constants.ObjectTypes.Document, new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972")); _relateContentType = new RelationType( "Relate ContentType on Copy", "relateContentTypeOnCopy", true, Constants.ObjectTypes.DocumentType, new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB")); using (IScope scope = ScopeProvider.CreateScope()) { var accessor = (IScopeAccessor)ScopeProvider; var relationTypeRepository = new RelationTypeRepository(accessor, AppCaches.Disabled, Mock.Of <ILogger <RelationTypeRepository> >()); var entityRepository = new EntityRepository(accessor, AppCaches.Disabled); var relationRepository = new RelationRepository(accessor, Mock.Of <ILogger <RelationRepository> >(), relationTypeRepository, entityRepository); relationTypeRepository.Save(_relateContent); relationTypeRepository.Save(_relateContentType); Template template = TemplateBuilder.CreateTextPageTemplate(); FileService.SaveTemplate(template); // Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed) _contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id); ContentTypeService.Save(_contentType); // Create and Save Content "Homepage" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 1) _textpage = ContentBuilder.CreateSimpleContent(_contentType); ContentService.Save(_textpage, 0); // Create and Save Content "Text Page 1" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 2) _subpage = ContentBuilder.CreateSimpleContent(_contentType, "Text Page 1", _textpage.Id); ContentService.Save(_subpage, 0); // Create and Save Content "Text Page 1" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 3) _subpage2 = ContentBuilder.CreateSimpleContent(_contentType, "Text Page 2", _textpage.Id); ContentService.Save(_subpage2, 0); _relation = new Relation(_textpage.Id, _subpage.Id, _relateContent) { Comment = string.Empty }; _relation2 = new Relation(_textpage.Id, _subpage2.Id, _relateContent) { Comment = string.Empty }; relationRepository.Save(_relation); relationRepository.Save(_relation2); scope.Complete(); } }
public void Initialize() { RepositoryTest.InitDB(); relationRepository = new RelationRepository(); bdRepository = new BDRepository(); personneRepository = new PersonneRepository(); }
private RelationRepository CreateRepository(IScopeProvider provider, out RelationTypeRepository relationTypeRepository) { var accessor = (IScopeAccessor)provider; relationTypeRepository = new RelationTypeRepository(accessor, CacheHelper.Disabled, Mock.Of <ILogger>()); var repository = new RelationRepository(accessor, Mock.Of <ILogger>(), relationTypeRepository); return(repository); }
public MediaListPopulating(IConfiguration configuration, IMemoryCache cache) { _configuration = configuration; _cache = cache; _movieRepository = new MovieRepository(configuration, cache); _relationRepository = new RelationRepository(configuration, _cache); _mediaListRepository = new MediaListRepository(configuration, _cache); _tvShowRepository = new TVShowRepository(configuration, _cache); }
public CommonsService(ILog log, IComponentContext context, TaxonomyTree tree, RelationRepository relRepo) { this.context = context; this.log = log; _tree = tree; _relRepo = relRepo; SetupTimer(); }
public void CreateTestData() { var relateContent = new RelationType( "Relate Content on Copy", "relateContentOnCopy", true, Constants.ObjectTypes.Document, new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972")); var relateContentType = new RelationType("Relate ContentType on Copy", "relateContentTypeOnCopy", true, Constants.ObjectTypes.DocumentType, new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB")); var provider = TestObjects.GetScopeProvider(Logger); using (var scope = provider.CreateScope()) { var accessor = (IScopeAccessor)provider; var relationTypeRepository = new RelationTypeRepository(accessor, AppCaches.Disabled, Mock.Of <ILogger>()); var entityRepository = new EntityRepository(accessor); var relationRepository = new RelationRepository(accessor, Mock.Of <ILogger>(), relationTypeRepository, entityRepository); relationTypeRepository.Save(relateContent); relationTypeRepository.Save(relateContentType); //Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed) ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage"); ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType! ServiceContext.ContentTypeService.Save(contentType); //Create and Save Content "Homepage" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 1) Content textpage = MockedContent.CreateSimpleContent(contentType); ServiceContext.ContentService.Save(textpage, 0); //Create and Save Content "Text Page 1" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 2) Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id); ServiceContext.ContentService.Save(subpage, 0); //Create and Save Content "Text Page 1" based on "umbTextpage" -> (NodeDto.NodeIdSeed + 3) Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id); ServiceContext.ContentService.Save(subpage2, 0); var relation = new Relation(textpage.Id, subpage.Id, relateContent) { Comment = string.Empty }; var relation2 = new Relation(textpage.Id, subpage2.Id, relateContent) { Comment = string.Empty }; relationRepository.Save(relation); relationRepository.Save(relation2); scope.Complete(); } }
public RelationType(RelationRepository repository) { Name = "Relation"; Field(x => x.Id); Field(x => x.Dashboard); Field(x => x.Date); Field(x => x.Time); Field(x => x.IsActive); Field(x => x.userId); Field(x => x.projectId); }
public void CreateTestData() { var relateContent = new RelationType(new Guid(Constants.ObjectTypes.Document), new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), "relateContentOnCopy") { IsBidirectional = true, Name = "Relate Content on Copy" }; var relateContentType = new RelationType(new Guid(Constants.ObjectTypes.DocumentType), new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), "relateContentTypeOnCopy") { IsBidirectional = true, Name = "Relate ContentType on Copy" }; var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var relationTypeRepository = new RelationTypeRepository(unitOfWork); var relationRepository = new RelationRepository(unitOfWork, NullCacheProvider.Current, relationTypeRepository); relationTypeRepository.AddOrUpdate(relateContent); relationTypeRepository.AddOrUpdate(relateContentType); unitOfWork.Commit(); //Create and Save ContentType "umbTextpage" -> 1045 ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage"); ServiceContext.ContentTypeService.Save(contentType); //Create and Save Content "Homepage" based on "umbTextpage" -> 1046 Content textpage = MockedContent.CreateSimpleContent(contentType); ServiceContext.ContentService.Save(textpage, 0); //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1047 Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id); ServiceContext.ContentService.Save(subpage, 0); //Create and Save Content "Text Page 1" based on "umbTextpage" -> 1048 Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id); ServiceContext.ContentService.Save(subpage2, 0); var relation = new Relation(textpage.Id, subpage.Id, relateContent) { Comment = string.Empty }; var relation2 = new Relation(textpage.Id, subpage2.Id, relateContent) { Comment = string.Empty }; relationRepository.AddOrUpdate(relation); relationRepository.AddOrUpdate(relation2); unitOfWork.Commit(); }
public void Can_Instantiate_Repository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); // Act var repositoryType = new RelationTypeRepository(unitOfWork); var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType); // Assert Assert.That(repository, Is.Not.Null); }
public void Get_Paged_Child_Entities_By_Parent_Id() { CreateTestDataForPagingTests(out List <IContent> createdContent, out List <IMember> createdMembers, out _); using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out _); // Get parent entities for child id var parents = repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 0, 6, out long totalRecords).ToList(); Assert.AreEqual(6, totalRecords); Assert.AreEqual(6, parents.Count); // Add the next page parents.AddRange(repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 1, 6, out totalRecords)); Assert.AreEqual(6, totalRecords); Assert.AreEqual(6, parents.Count); var contentEntities = parents.OfType <IDocumentEntitySlim>().ToList(); var mediaEntities = parents.OfType <IMediaEntitySlim>().ToList(); var memberEntities = parents.OfType <IMemberEntitySlim>().ToList(); Assert.AreEqual(3, contentEntities.Count); Assert.AreEqual(3, mediaEntities.Count); Assert.AreEqual(0, memberEntities.Count); // only of a certain type parents.AddRange(repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 0, 100, out totalRecords, UmbracoObjectTypes.Media.GetGuid())); Assert.AreEqual(3, totalRecords); parents.AddRange(repository.GetPagedChildEntitiesByParentId(createdMembers[0].Id, 0, 100, out totalRecords, UmbracoObjectTypes.Media.GetGuid())); Assert.AreEqual(3, totalRecords); parents.AddRange(repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 0, 100, out totalRecords, UmbracoObjectTypes.Member.GetGuid())); Assert.AreEqual(0, totalRecords); // Test getting relations of specified relation types IRelationType relatedMediaRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedMediaAlias); IRelationType relatedContentRelType = RelationService.GetRelationTypeByAlias(Constants.Conventions.RelationTypes.RelatedDocumentAlias); parents = repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 0, 6, out totalRecords, new int[] { relatedContentRelType.Id, relatedMediaRelType.Id }).ToList(); Assert.AreEqual(3, totalRecords); Assert.AreEqual(3, parents.Count); parents = repository.GetPagedChildEntitiesByParentId(createdContent[0].Id, 1, 6, out totalRecords, new int[] { relatedContentRelType.Id, relatedMediaRelType.Id }).ToList(); Assert.AreEqual(3, totalRecords); Assert.AreEqual(0, parents.Count); } }
public void Can_Perform_Count_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.ParentId == _textpage.Id); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(2)); } }
public void Can_Perform_Exists_On_RelationRepository() { // Arrange using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType); // Act bool exists = repository.Exists(2); bool doesntExist = repository.Exists(5); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); } }
public void Can_Perform_Exists_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 exists = repository.Exists(2); var doesntExist = repository.Exists(5); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); }
public void Can_Perform_Count_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 query = Query <Relation> .Builder.Where(x => x.ParentId == 1046); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(2)); }
public void Can_Perform_GetAll_With_Params_On_RelationRepository() { // Arrange using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType); // Act IEnumerable <IRelation> relations = repository.GetMany(1, 2); // 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)); } }
private DocumentRepository CreateDocumentRepository(IScopeProvider provider) { var accessor = (IScopeAccessor)provider; var tRepository = new TemplateRepository(accessor, AppCaches.Disabled, Logger, TestObjects.GetFileSystemsMock()); var tagRepo = new TagRepository(accessor, AppCaches.Disabled, Logger); var commonRepository = new ContentTypeCommonRepository(accessor, tRepository, AppCaches); var languageRepository = new LanguageRepository(accessor, AppCaches.Disabled, Logger); var ctRepository = new ContentTypeRepository(accessor, AppCaches.Disabled, Logger, commonRepository, languageRepository); var relationTypeRepository = new RelationTypeRepository(accessor, AppCaches.Disabled, Logger); var entityRepository = new EntityRepository(accessor); var relationRepository = new RelationRepository(accessor, Logger, relationTypeRepository, entityRepository); var propertyEditors = new Lazy <PropertyEditorCollection>(() => new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty <IDataEditor>()))); var dataValueReferences = new DataValueReferenceFactoryCollection(Enumerable.Empty <IDataValueReferenceFactory>()); var repository = new DocumentRepository(accessor, AppCaches.Disabled, Logger, ctRepository, tRepository, tagRepo, languageRepository, relationRepository, relationTypeRepository, propertyEditors, dataValueReferences); return(repository); }
public void Can_Perform_Add_On_RelationRepository() { // Arrange using (IScope scope = ScopeProvider.CreateScope()) { RelationRepository repository = CreateRepository(ScopeProvider, out RelationTypeRepository repositoryType); // Act IRelationType relationType = repositoryType.Get(1); var relation = new Relation(_textpage.Id, _subpage.Id, relationType); repository.Save(relation); // Assert Assert.That(relation, Is.Not.Null); Assert.That(relation.HasIdentity, Is.True); } }
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); } }
public void Can_Perform_GetAll_With_Params_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 relations = repository.GetAll(1, 2); // 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)); }
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")); } }
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)); } }
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_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")); }
public void Can_Perform_Delete_When_Assigned_To_Doc() { // Arrange IScopeProvider provider = ScopeProvider; var scopeAccessor = (IScopeAccessor)provider; IDataTypeService dataTypeService = GetRequiredService <IDataTypeService>(); IFileService fileService = GetRequiredService <IFileService>(); using (provider.CreateScope()) { ITemplateRepository templateRepository = CreateRepository(provider); var globalSettings = new GlobalSettings(); var serializer = new JsonNetSerializer(); var tagRepository = new TagRepository(scopeAccessor, AppCaches.Disabled, LoggerFactory.CreateLogger <TagRepository>()); var commonRepository = new ContentTypeCommonRepository(scopeAccessor, templateRepository, AppCaches, ShortStringHelper); var languageRepository = new LanguageRepository(scopeAccessor, AppCaches.Disabled, LoggerFactory.CreateLogger <LanguageRepository>(), Microsoft.Extensions.Options.Options.Create(globalSettings)); var contentTypeRepository = new ContentTypeRepository(scopeAccessor, AppCaches.Disabled, LoggerFactory.CreateLogger <ContentTypeRepository>(), commonRepository, languageRepository, ShortStringHelper); var relationTypeRepository = new RelationTypeRepository(scopeAccessor, AppCaches.Disabled, LoggerFactory.CreateLogger <RelationTypeRepository>()); var entityRepository = new EntityRepository(scopeAccessor, AppCaches.Disabled); var relationRepository = new RelationRepository(scopeAccessor, LoggerFactory.CreateLogger <RelationRepository>(), relationTypeRepository, entityRepository); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(() => Enumerable.Empty <IDataEditor>())); var dataValueReferences = new DataValueReferenceFactoryCollection(() => Enumerable.Empty <IDataValueReferenceFactory>()); var contentRepo = new DocumentRepository(scopeAccessor, AppCaches.Disabled, LoggerFactory.CreateLogger <DocumentRepository>(), LoggerFactory, contentTypeRepository, templateRepository, tagRepository, languageRepository, relationRepository, relationTypeRepository, propertyEditors, dataValueReferences, dataTypeService, serializer, Mock.Of <IEventAggregator>()); Template template = TemplateBuilder.CreateTextPageTemplate(); fileService.SaveTemplate(template); // else, FK violation on contentType! ContentType contentType = ContentTypeBuilder.CreateSimpleContentType("umbTextpage2", "Textpage", defaultTemplateId: template.Id); contentTypeRepository.Save(contentType); Content textpage = ContentBuilder.CreateSimpleContent(contentType); contentRepo.Save(textpage); textpage.TemplateId = template.Id; contentRepo.Save(textpage); // Act ITemplate templates = templateRepository.Get("textPage"); templateRepository.Delete(templates); // Assert Assert.IsNull(templateRepository.Get("textPage")); } }
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_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); }
private RelationRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out RelationTypeRepository relationTypeRepository) { relationTypeRepository = new RelationTypeRepository(unitOfWork, NullCacheProvider.Current); var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, relationTypeRepository); return repository; }
public void Can_Delete_Content_And_Verify_Relation_Is_Removed() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repositoryType = new RelationTypeRepository(unitOfWork); var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, repositoryType); var content = ServiceContext.ContentService.GetById(1047); ServiceContext.ContentService.Delete(content, 0); // Act var shouldntExist = repository.Exists(1); var shouldExist = repository.Exists(2); // Assert Assert.That(shouldntExist, Is.False); Assert.That(shouldExist, Is.True); }
public void Can_Perform_GetByQuery_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 query = Query<Relation>.Builder.Where(x => x.RelationTypeId == 2); var relations = repository.GetByQuery(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)); }
public void Can_Perform_Count_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 query = Query<Relation>.Builder.Where(x => x.ParentId == 1046); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(2)); }