当前位置: 首页>>代码示例>>C#>>正文


C# UnitOfWork.PetaPocoUnitOfWorkProvider类代码示例

本文整理汇总了C#中Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWorkProvider的典型用法代码示例。如果您正苦于以下问题:C# PetaPocoUnitOfWorkProvider类的具体用法?C# PetaPocoUnitOfWorkProvider怎么用?C# PetaPocoUnitOfWorkProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PetaPocoUnitOfWorkProvider类属于Umbraco.Core.Persistence.UnitOfWork命名空间,在下文中一共展示了PetaPocoUnitOfWorkProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_Perform_Multiple_Adds_On_Repository

        public void Can_Perform_Multiple_Adds_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = CreateRepository(unitOfWork))
            {
                var tag = new Tag()
                    {
                        Group = "Test",
                        Text = "Test"
                    };

                // Act
                repository.AddOrUpdate(tag);
                unitOfWork.Commit();

                var tag2 = new Tag()
                    {
                        Group = "Test",
                        Text = "Test2"
                    };
                repository.AddOrUpdate(tag2);
                unitOfWork.Commit();

                // Assert
                Assert.That(tag.HasIdentity, Is.True);
                Assert.That(tag2.HasIdentity, Is.True);
                Assert.AreNotEqual(tag.Id, tag2.Id);
            }

        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:32,代码来源:TagRepositoryTest.cs

示例2: Can_Perform_Multiple_Adds_On_MediaRepository

        public void Can_Perform_Multiple_Adds_On_MediaRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var mediaTypeRepository = RepositoryResolver.Current.ResolveByType<IMediaTypeRepository>(unitOfWork);
            var repository = RepositoryResolver.Current.ResolveByType<IMediaRepository>(unitOfWork);

            var mediaType = mediaTypeRepository.Get(1032);
            var file = MockedMedia.CreateMediaFile(mediaType, -1);

            // Act
            repository.AddOrUpdate(file);
            unitOfWork.Commit();

            var image = MockedMedia.CreateMediaImage(mediaType, -1);
            repository.AddOrUpdate(image);
            unitOfWork.Commit();

            // Assert
            Assert.That(file.HasIdentity, Is.True);
            Assert.That(image.HasIdentity, Is.True);
            Assert.That(file.Name, Is.EqualTo("Test File"));
            Assert.That(image.Name, Is.EqualTo("Test Image"));
            Assert.That(file.ContentTypeId, Is.EqualTo(mediaType.Id));
            Assert.That(image.ContentTypeId, Is.EqualTo(mediaType.Id));
        }
开发者ID:ChrisNikkel,项目名称:Umbraco-CMS,代码行数:27,代码来源:MediaRepositoryTest.cs

示例3: Ensures_Permissions_Are_Set_If_Parent_Entity_Permissions_Exist

        public void Ensures_Permissions_Are_Set_If_Parent_Entity_Permissions_Exist()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var contentTypeRepository = RepositoryResolver.Current.ResolveByType<IContentTypeRepository>(unitOfWork);
            var repository = (ContentRepository)RepositoryResolver.Current.ResolveByType<IContentRepository>(unitOfWork);

            var contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
            contentType.AllowedContentTypes = new List<ContentTypeSort>
                {
                    new ContentTypeSort
                        {
                            Alias = contentType.Alias,
                            Id = new Lazy<int>(() => contentType.Id),
                            SortOrder = 0
                        }
                };
            var parentPage = MockedContent.CreateSimpleContent(contentType);                        
            contentTypeRepository.AddOrUpdate(contentType);
            repository.AddOrUpdate(parentPage);
            unitOfWork.Commit();

            // Act
            repository.AssignEntityPermissions(parentPage, "A", new object[] {0});
            var childPage = MockedContent.CreateSimpleContent(contentType, "child", parentPage);
            repository.AddOrUpdate(childPage);
            unitOfWork.Commit();

            // Assert
            var permissions = repository.GetPermissionsForEntity(childPage.Id);
            Assert.AreEqual(1, permissions.Count());
            Assert.AreEqual("A", permissions.Single().Permission);
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:34,代码来源:ContentRepositoryTest.cs

示例4: Can_Perform_Update_On_MediaTypeRepository

        public void Can_Perform_Update_On_MediaTypeRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = RepositoryResolver.Current.ResolveByType<IMediaTypeRepository>(unitOfWork);
            var videoMediaType = MockedContentTypes.CreateVideoMediaType();
            repository.AddOrUpdate(videoMediaType);
            unitOfWork.Commit();

            // Act
            var mediaType = repository.Get(1045);

            mediaType.Thumbnail = "Doc2.png";
            mediaType.PropertyGroups["Media"].PropertyTypes.Add(new PropertyType(new Guid(), DataTypeDatabaseType.Ntext)
            {
                Alias = "subtitle",
                Name = "Subtitle",
                Description = "Optional Subtitle",
                HelpText = "",
                Mandatory = false,
                SortOrder = 1,
                DataTypeDefinitionId = -88
            });
            repository.AddOrUpdate(mediaType);
            unitOfWork.Commit();

            var dirty = ((MediaType)mediaType).IsDirty();

            // Assert
            Assert.That(mediaType.HasIdentity, Is.True);
            Assert.That(dirty, Is.False);
            Assert.That(mediaType.Thumbnail, Is.EqualTo("Doc2.png"));
            Assert.That(mediaType.PropertyTypes.Any(x => x.Alias == "subtitle"), Is.True);
        }
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:35,代码来源:MediaTypeRepositoryTest.cs

示例5: Can_Perform_Get_On_Repository

        public void Can_Perform_Get_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current))
            {
                // Act
                var macro = repository.Get(1);

                // Assert
                Assert.That(macro, Is.Not.Null);
                Assert.That(macro.HasIdentity, Is.True);
                Assert.That(macro.Alias, Is.EqualTo("test1"));
                Assert.That(macro.CacheByPage, Is.EqualTo(false));
                Assert.That(macro.CacheByMember, Is.EqualTo(false));
                Assert.That(macro.ControlAssembly, Is.EqualTo("MyAssembly1"));
                Assert.That(macro.ControlType, Is.EqualTo("~/usercontrol/test1.ascx"));
                Assert.That(macro.DontRender, Is.EqualTo(true));
                Assert.That(macro.Name, Is.EqualTo("Test1"));
                Assert.That(macro.CacheDuration, Is.EqualTo(0));
                Assert.That(macro.ScriptPath, Is.EqualTo("~/views/macropartials/test1.cshtml"));
                Assert.That(macro.UseInEditor, Is.EqualTo(false));
                Assert.That(macro.XsltPath, Is.EqualTo("test1.xslt"));
            }


        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:MacroRepositoryTest.cs

示例6: FixtureSetup

        public void FixtureSetup()
        {
            SqlSyntaxProviderTestHelper.EstablishSqlSyntax();

            var cacheProvider = new Mock<IRuntimeCacheProvider>();

            GatewayProviderService = new GatewayProviderService();

            var providers =
                GatewayProviderService.GetAllGatewayProviders()
                    .Where(x => x.GatewayProviderType == GatewayProviderType.Payment);

            GatewayProvider = providers.FirstOrDefault(x => x.Key == new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"));

            if (GatewayProvider != null)
            {
                GatewayProviderService.Delete(GatewayProvider);
            }

            var petaPoco = new PetaPocoUnitOfWorkProvider();

            var xLogin = ConfigurationManager.AppSettings["xlogin"];
            var xtrankey = ConfigurationManager.AppSettings["xtrankey"];

            var sql = new Sql();

            var dto = new GatewayProviderDto()
            {
                Key = new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"),
                Name = "AuthorizeNet",
                Description = "AuthorizeNet",
                TypeFullName =
                    "Merchello.Plugin.Payments.AuthorizeNet.AuthorizeNetPaymentGatewayProvider, Merchello.Plugin.Payments.AuthorizeNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
                ExtendedData = "<extendedData />",
                EncryptExtendedData = false,
                ProviderTfKey = Constants.TypeFieldKeys.GatewayProvider.PaymentProviderKey,
                CreateDate = DateTime.Now,
                UpdateDate = DateTime.Now
            };

            petaPoco.GetUnitOfWork().Database.Insert(dto);

            GatewayProvider =
                GatewayProviderService.GetGatewayProviderByKey(new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"));

            var providerSettings = new AuthorizeNetProcessorSettings()
            {
                LoginId = xLogin,
                TransactionKey = xtrankey
            };

            GatewayProvider.ExtendedData.SaveProcessorSettings(providerSettings);

            Provider = new AuthorizeNetPaymentGatewayProvider(GatewayProviderService, GatewayProvider,
                cacheProvider.Object);
        }
开发者ID:koswesley,项目名称:Merchello-1,代码行数:56,代码来源:ProviderTestsBase.cs

示例7: FixtureSetup

        public void FixtureSetup()
        {
            SqlSyntaxProviderTestHelper.EstablishSqlSyntax();

            var cacheProvider = new Mock<IRuntimeCacheProvider>();

            GatewayProviderService = new GatewayProviderService();

            var providers =
                GatewayProviderService.GetAllGatewayProviders()
                    .Where(x => x.GatewayProviderType == GatewayProviderType.Payment);

            GatewayProviderSettings = providers.FirstOrDefault(x => x.Key == new Guid("15C87B6F-7987-49D9-8444-A2B4406941A8"));

            if (GatewayProviderSettings != null)
            {
                GatewayProviderService.Delete(GatewayProviderSettings);
            }

            var petaPoco = new PetaPocoUnitOfWorkProvider();

            var xLogin = ConfigurationManager.AppSettings["xlogin"];
            var xtrankey = ConfigurationManager.AppSettings["xtrankey"];

            var sql = new Sql();

            var dto = new GatewayProviderSettingsDto()
            {
                Key = new Guid("15C87B6F-7987-49D9-8444-A2B4406941A8"),
                Name = "Stripe",
                Description = "Stripe",
                ExtendedData = "<extendedData />",
                EncryptExtendedData = false,
                ProviderTfKey = Constants.TypeFieldKeys.GatewayProvider.PaymentProviderKey,
                CreateDate = DateTime.Now,
                UpdateDate = DateTime.Now
            };


            petaPoco.GetUnitOfWork().Database.Insert(dto);

            GatewayProviderSettings =
                GatewayProviderService.GetGatewayProviderByKey(new Guid("15C87B6F-7987-49D9-8444-A2B4406941A8"));

            var providerSettings = new StripeProcessorSettings()
            {
                // TODO
                //LoginId = xLogin,
                //TransactionKey = xtrankey
            };

            GatewayProviderSettings.ExtendedData.SaveProcessorSettings(providerSettings);

            Provider = new StripePaymentGatewayProvider(GatewayProviderService, GatewayProviderSettings,
                cacheProvider.Object);
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:56,代码来源:ProviderTestsBase.cs

示例8: Can_Instantiate_Repository

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

            // Act
            var repository = new TemplateRepository(unitOfWork, NullCacheProvider.Current, _masterPageFileSystem, _viewsFileSystem);

            // Assert
            Assert.That(repository, Is.Not.Null);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:12,代码来源:TemplateRepositoryTest.cs

示例9: Can_Instantiate_Repository

        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);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:12,代码来源:RelationTypeRepositoryTest.cs

示例10: Can_Instantiate_Repository

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

            // Act
            var repository = RepositoryResolver.Current.ResolveByType<IMediaTypeRepository>(unitOfWork);

            // Assert
            Assert.That(repository, Is.Not.Null);
        }
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:12,代码来源:MediaTypeRepositoryTest.cs

示例11: Can_Instantiate_Repository

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

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Assert
                Assert.That(repository, Is.Not.Null);    
            }
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:13,代码来源:ServerRegistrationRepositoryTest.cs

示例12: Can_Instantiate_Repository

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

            // Act
            using (var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current))
            {
                // Assert
                Assert.That(repository, Is.Not.Null);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:13,代码来源:MacroRepositoryTest.cs

示例13: MemberRepository_Can_Get_Member_By_Id

        public void MemberRepository_Can_Get_Member_By_Id()
        {
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            MemberTypeRepository memberTypeRepository;
            using (var repository = CreateRepository(unitOfWork, out memberTypeRepository))
            {

                var member = repository.Get(1341);

                Assert.That(member, Is.Not.Null);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:13,代码来源:MemberRepositoryTest.cs

示例14: CreateTestData

        public override void CreateTestData()
        {            
            base.CreateTestData();

            var provider = new PetaPocoUnitOfWorkProvider();
            using (var unitOfWork = provider.GetUnitOfWork())
            using (var repository = new MacroRepository(unitOfWork))
            {
                repository.AddOrUpdate(new Macro("test1", "Test1", "~/usercontrol/test1.ascx", "MyAssembly1", "test1.xslt", "~/views/macropartials/test1.cshtml"));
                repository.AddOrUpdate(new Macro("test2", "Test2", "~/usercontrol/test2.ascx", "MyAssembly2", "test2.xslt", "~/views/macropartials/test2.cshtml"));
                repository.AddOrUpdate(new Macro("test3", "Tet3", "~/usercontrol/test3.ascx", "MyAssembly3", "test3.xslt", "~/views/macropartials/test3.cshtml"));
                unitOfWork.Commit();
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:14,代码来源:MacroServiceTests.cs

示例15: Can_Perform_Get_On_DataTypeDefinitionRepository

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

            // Act
            var dataTypeDefinition = repository.Get(-42);

            // Assert
            Assert.That(dataTypeDefinition, Is.Not.Null);
            Assert.That(dataTypeDefinition.HasIdentity, Is.True);
            Assert.That(dataTypeDefinition.Name, Is.EqualTo("Dropdown"));
        }
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:15,代码来源:DataTypeDefinitionRepositoryTest.cs


注:本文中的Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWorkProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。