當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。