private RelationRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out RelationTypeRepository relationTypeRepository) { relationTypeRepository = new RelationTypeRepository(unitOfWork, NullCacheProvider.Current); var repository = new RelationRepository(unitOfWork, NullCacheProvider.Current, relationTypeRepository); return(repository); }
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 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(); } }
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 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 void Can_Instantiate_Repository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); // Act var repository = new RelationTypeRepository(unitOfWork); // Assert Assert.That(repository, Is.Not.Null); }
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 repository = new RelationTypeRepository(unitOfWork); // Assert Assert.That(repository, Is.Not.Null); }
public void Can_Perform_Exists_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var exists = repository.Exists(3); var doesntExist = repository.Exists(5); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); }
public void Can_Perform_Count_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var query = Query <RelationType> .Builder.Where(x => x.Alias.StartsWith("relate")); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(3)); }
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_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")); }
public void Can_Perform_GetAll_With_Params_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var relationTypes = repository.GetAll(2, 3); // Assert Assert.That(relationTypes, Is.Not.Null); Assert.That(relationTypes.Any(), Is.True); Assert.That(relationTypes.Any(x => x == null), Is.False); Assert.That(relationTypes.Count(), Is.EqualTo(2)); }
public void Can_Perform_Count_On_RelationTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { RelationTypeRepository repository = CreateRepository(provider); // Act IQuery <IRelationType> query = scope.SqlContext.Query <IRelationType>().Where(x => x.Alias.StartsWith("relate")); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(6)); } }
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 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 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_Exists_On_RelationTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { RelationTypeRepository repository = CreateRepository(provider); // Act bool exists = repository.Exists(3); bool doesntExist = repository.Exists(9); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); } }
public void CreateTestData() { var relateContent = new RelationType("Relate Content on Copy", "relateContentOnCopy", true, Constants.ObjectTypes.Document, Constants.ObjectTypes.Document); var relateContentType = new RelationType("Relate ContentType on Copy", "relateContentTypeOnCopy", true, Constants.ObjectTypes.DocumentType, Constants.ObjectTypes.DocumentType); var relateContentMedia = new RelationType("Relate Content to Media", "relateContentToMedia", true, Constants.ObjectTypes.Document, Constants.ObjectTypes.Media); IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { var repository = new RelationTypeRepository((IScopeAccessor)provider, AppCaches.Disabled, LoggerFactory.CreateLogger <RelationTypeRepository>()); repository.Save(relateContent); // Id 2 repository.Save(relateContentType); // Id 3 repository.Save(relateContentMedia); // Id 4 scope.Complete(); } }
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")); } }
private MemberRepository CreateRepository(IScopeProvider provider, out MemberTypeRepository memberTypeRepository, out MemberGroupRepository memberGroupRepository) { var accessor = (IScopeAccessor)provider; var templateRepository = Mock.Of <ITemplateRepository>(); var commonRepository = new ContentTypeCommonRepository(accessor, templateRepository, AppCaches); var languageRepository = new LanguageRepository(accessor, AppCaches.Disabled, Logger); memberTypeRepository = new MemberTypeRepository(accessor, AppCaches.Disabled, Logger, commonRepository, languageRepository); memberGroupRepository = new MemberGroupRepository(accessor, AppCaches.Disabled, Logger); var tagRepo = new TagRepository(accessor, AppCaches.Disabled, Logger); 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 MemberRepository(accessor, AppCaches.Disabled, Logger, memberTypeRepository, memberGroupRepository, tagRepo, Mock.Of <ILanguageRepository>(), relationRepository, relationTypeRepository, propertyEditors, dataValueReferences); return(repository); }
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_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_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); } }
public void Can_Perform_Add_On_RelationTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { RelationTypeRepository repository = CreateRepository(provider); // Act var relateMemberToContent = new RelationType("Relate Member to Content", "relateMemberToContent", true, Constants.ObjectTypes.Member, Constants.ObjectTypes.Document); repository.Save(relateMemberToContent); // Assert Assert.That(relateMemberToContent.HasIdentity, Is.True); Assert.That(repository.Exists(relateMemberToContent.Id), Is.True); } }
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(Logger); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of <ILogger>(), SqlSyntax); repository.AddOrUpdate(relateContent); //Id 2 repository.AddOrUpdate(relateContentType); //Id 3 unitOfWork.Commit(); }
public void CreateTestData() { var relateContent = new RelationType(new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), "relateContentOnCopy") { IsBidirectional = true, Name = "Relate Content on Copy" }; var relateContentType = new RelationType(new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), "relateContentTypeOnCopy") { IsBidirectional = true, Name = "Relate ContentType on Copy" }; var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); repository.AddOrUpdate(relateContent); //Id 2 repository.AddOrUpdate(relateContentType); //Id 3 unitOfWork.Commit(); }
public void Can_Perform_GetAll_With_Params_On_RelationTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (provider.CreateScope()) { RelationTypeRepository repository = CreateRepository(provider); // Act IEnumerable <IRelationType> relationTypes = repository.GetMany(2, 3); // Assert Assert.That(relationTypes, Is.Not.Null); Assert.That(relationTypes.Any(), Is.True); Assert.That(relationTypes.Any(x => x == null), Is.False); Assert.That(relationTypes.Count(), Is.EqualTo(2)); } }
public void Can_Perform_GetByQuery_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var childObjType = new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"); var query = Query <RelationType> .Builder.Where(x => x.ChildObjectType == childObjType); var result = repository.GetByQuery(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)); }
private MediaRepository CreateRepository(IScopeProvider provider, out MediaTypeRepository mediaTypeRepository, AppCaches appCaches = null) { appCaches = appCaches ?? AppCaches; var scopeAccessor = (IScopeAccessor)provider; var templateRepository = new TemplateRepository(scopeAccessor, appCaches, Logger, TestObjects.GetFileSystemsMock()); var commonRepository = new ContentTypeCommonRepository(scopeAccessor, templateRepository, appCaches); var languageRepository = new LanguageRepository(scopeAccessor, appCaches, Logger); mediaTypeRepository = new MediaTypeRepository(scopeAccessor, appCaches, Logger, commonRepository, languageRepository); var tagRepository = new TagRepository(scopeAccessor, appCaches, Logger); var relationTypeRepository = new RelationTypeRepository(scopeAccessor, AppCaches.Disabled, Logger); var entityRepository = new EntityRepository(scopeAccessor); var relationRepository = new RelationRepository(scopeAccessor, 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 MediaRepository(scopeAccessor, appCaches, Logger, mediaTypeRepository, tagRepository, Mock.Of <ILanguageRepository>(), relationRepository, relationTypeRepository, propertyEditors, dataValueReferences); return(repository); }
private MediaRepository CreateRepository(IScopeProvider provider, out MediaTypeRepository mediaTypeRepository, AppCaches appCaches = null) { appCaches ??= AppCaches.NoCache; var scopeAccessor = (IScopeAccessor)provider; var globalSettings = new GlobalSettings(); var commonRepository = new ContentTypeCommonRepository(scopeAccessor, TemplateRepository, appCaches, ShortStringHelper); var languageRepository = new LanguageRepository(scopeAccessor, appCaches, LoggerFactory.CreateLogger <LanguageRepository>()); mediaTypeRepository = new MediaTypeRepository(scopeAccessor, appCaches, LoggerFactory.CreateLogger <MediaTypeRepository>(), commonRepository, languageRepository, ShortStringHelper); var tagRepository = new TagRepository(scopeAccessor, appCaches, LoggerFactory.CreateLogger <TagRepository>()); 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 mediaUrlGenerators = new MediaUrlGeneratorCollection(() => Enumerable.Empty <IMediaUrlGenerator>()); var dataValueReferences = new DataValueReferenceFactoryCollection(() => Enumerable.Empty <IDataValueReferenceFactory>()); var repository = new MediaRepository(scopeAccessor, appCaches, LoggerFactory.CreateLogger <MediaRepository>(), LoggerFactory, mediaTypeRepository, tagRepository, Mock.Of <ILanguageRepository>(), relationRepository, relationTypeRepository, propertyEditors, mediaUrlGenerators, dataValueReferences, DataTypeService, JsonSerializer, Mock.Of <IEventAggregator>()); return(repository); }
public void Can_Perform_Add_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var relateMemberToContent = new RelationType(new Guid("39eb0f98-b348-42a1-8662-e7eb18487560"), new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), "relateMemberToContent") {IsBidirectional = true, Name = "Relate Member to Content"}; repository.AddOrUpdate(relateMemberToContent); unitOfWork.Commit(); // Assert Assert.That(relateMemberToContent.HasIdentity, Is.True); Assert.That(repository.Exists(relateMemberToContent.Id), Is.True); }
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); }
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_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 CreateTestData() { var relateContent = new RelationType(new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), "relateContentOnCopy"){IsBidirectional = true, Name = "Relate Content on Copy"}; var relateContentType = new RelationType(new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), "relateContentTypeOnCopy") { IsBidirectional = true, Name = "Relate ContentType on Copy" }; var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); repository.AddOrUpdate(relateContent);//Id 2 repository.AddOrUpdate(relateContentType);//Id 3 unitOfWork.Commit(); }
public void Can_Perform_GetAll_With_Params_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var relationTypes = repository.GetAll(2, 3); // Assert Assert.That(relationTypes, Is.Not.Null); Assert.That(relationTypes.Any(), Is.True); Assert.That(relationTypes.Any(x => x == null), Is.False); Assert.That(relationTypes.Count(), Is.EqualTo(2)); }
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_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_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_GetByQuery_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var childObjType = new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"); var query = Query<RelationType>.Builder.Where(x => x.ChildObjectType == childObjType); var result = repository.GetByQuery(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 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")); }
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")); }
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() { 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_Perform_Exists_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var exists = repository.Exists(3); var doesntExist = repository.Exists(5); // Assert Assert.That(exists, Is.True); Assert.That(doesntExist, Is.False); }
public void Can_Perform_Count_On_RelationTypeRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new RelationTypeRepository(unitOfWork); // Act var query = Query<RelationType>.Builder.Where(x => x.Alias.StartsWith("relate")); int count = repository.Count(query); // Assert Assert.That(count, Is.EqualTo(3)); }