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


C# Subscription.Create方法代码示例

本文整理汇总了C#中Subscription.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.Create方法的具体用法?C# Subscription.Create怎么用?C# Subscription.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSubscription

        public void CreateSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Create Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var coup = CreateNewCoupon(3);
            var sub = new Subscription(account, plan, "USD");
            sub.TotalBillingCycles = 5;
            sub.Coupon = coup;
            Assert.Null(sub.TaxInCents);
            Assert.Null(sub.TaxType);
            Assert.Null(sub.TaxRate);
            sub.Create();

            sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Active);
            Assert.Equal(5, sub.TotalBillingCycles);
            Assert.Equal(coup.CouponCode, sub.Coupon.CouponCode);
            Assert.Equal(9, sub.TaxInCents.Value);
            Assert.Equal("usst", sub.TaxType);
            Assert.Equal(0.0875M, sub.TaxRate.Value);

            var sub1 = Subscriptions.Get(sub.Uuid);
            Assert.Equal(5, sub1.TotalBillingCycles);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:32,代码来源:SubscriptionTest.cs

示例2: LookupCouponInvoice

        public void LookupCouponInvoice()
        {
            var discounts = new Dictionary<string, int> { { "USD", 1000 } };
            var coupon = new Coupon(GetMockCouponCode(), GetMockCouponName(), discounts);
            coupon.Create();

            var plan = new Plan(GetMockPlanCode(), GetMockPlanCode())
            {
                Description = "Test Lookup Coupon Invoice"
            };
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var redemption = account.RedeemCoupon(coupon.CouponCode, "USD");

            var sub = new Subscription(account, plan, "USD", coupon.CouponCode);
            sub.Create();

            // TODO complete this test

            var invoices = account.GetInvoices();

            invoices.Should().NotBeEmpty();

            var invoice = Invoices.Get(invoices.First().InvoiceNumber);
            var fromInvoice = invoice.GetRedemption();

            redemption.Should().Be(fromInvoice);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:32,代码来源:CouponRedemptionTest.cs

示例3: ListExpiredSubscriptions

        public void ListExpiredSubscriptions()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Subscription Test",
                PlanIntervalLength = 1,
                PlanIntervalUnit = Plan.IntervalUnit.Months
            };
            plan.UnitAmountInCents.Add("USD", 400);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            for (var x = 0; x < 2; x++)
            {
                var account = CreateNewAccountWithBillingInfo();
                var sub = new Subscription(account, plan, "USD")
                {
                    StartsAt = DateTime.Now.AddMonths(-5)
                };

                sub.Create();
            }

            var subs = Subscriptions.List(Subscription.SubscriptionState.Expired);
            subs.Should().NotBeEmpty();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:26,代码来源:SubscriptionListTest.cs

示例4: New

        /// <summary>
        /// Creates a new subscription.
        /// </summary>
        public Subscription New(Session session)
        {            
            if (session == null) throw new ArgumentNullException("session");

            Subscription subscription = new Subscription(session.DefaultSubscription);

            if (!new SubscriptionEditDlg().ShowDialog(subscription))
            {
                return null;
            }
            
            session.AddSubscription(subscription);    
            subscription.Create();

            Subscription duplicateSubscription = session.Subscriptions.FirstOrDefault(s => s.Id != 0 && s.Id.Equals(subscription.Id) && s != subscription);
            if (duplicateSubscription != null)
            {
                Utils.Trace("Duplicate subscription was created with the id: {0}", duplicateSubscription.Id);

                DialogResult result = MessageBox.Show("Duplicate subscription was created with the id: " + duplicateSubscription.Id + ". Do you want to keep it?", "Warning", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    duplicateSubscription.Delete(false);
                    session.RemoveSubscription(subscription);

                    return null;
                }
            }

            Show(subscription);
            
            return subscription;
        }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:36,代码来源:SubscriptionDlg.cs

示例5: ListActiveSubscriptions

        public void ListActiveSubscriptions()
        {
            var p = new Plan(GetMockPlanCode(), GetMockPlanName()) { Description = "Subscription Test" };
            p.UnitAmountInCents.Add("USD", 300);
            p.Create();
            PlansToDeactivateOnDispose.Add(p);

            for (var x = 0; x < 2; x++)
            {
                var account = CreateNewAccountWithBillingInfo();

                var sub = new Subscription(account, p, "USD");
                sub.Create();
            }

            var subs = Subscriptions.List(Subscription.SubscriptionState.Active);
            subs.Should().NotBeEmpty();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:18,代码来源:SubscriptionListTest.cs

示例6: LookupSubscription

        public void LookupSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) {Description = "Lookup Subscription Test"};
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Active);

            var fromService = Subscriptions.Get(sub.Uuid);

            fromService.Should().Be(sub);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:19,代码来源:SubscriptionTest.cs

示例7: CancelSubscription

        public void CancelSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Cancel Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            sub.Cancel();

            sub.CanceledAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Canceled);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:20,代码来源:SubscriptionTest.cs

示例8: LookupSubscriptionPendingChanges

        public void LookupSubscriptionPendingChanges()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Lookup Subscription With Pending Changes Test"
            };
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();
            sub.UnitAmountInCents = 3000;
            
            sub.ChangeSubscription(Subscription.ChangeTimeframe.Renewal);

            var newSubscription = Subscriptions.Get(sub.Uuid);
            newSubscription.PendingSubscription.Should().NotBeNull();
            newSubscription.PendingSubscription.UnitAmountInCents.Should().Be(3000);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:22,代码来源:SubscriptionTest.cs

示例9: CreateSubscriptionPlanWithAddons

        public void CreateSubscriptionPlanWithAddons()
        {
            Plan plan = null;
            Plan plan2 = null;
            AddOn addon1 = null;
            AddOn addon2 = null;
            Account account = null;
            Subscription sub = null;
            Subscription sub2 = null;
            Subscription sub3 = null;

            try
            {
                plan = new Plan(GetMockPlanCode(), "aarons test plan")
                {
                    Description = "Create Subscription Plan With Addons Test"
                };
                plan.UnitAmountInCents.Add("USD", 100);
                plan.Create();

                addon1 = plan.NewAddOn("addon1", "addon1");
                addon1.DisplayQuantityOnHostedPage = true;
                addon1.UnitAmountInCents.Add("USD", 100);
                addon1.DefaultQuantity = 1;
                addon1.Create();

                plan = Plans.Get(plan.PlanCode);

                var addon_test_1 = plan.GetAddOn("addon1");
                Assert.Equal(addon1.UnitAmountInCents["USD"], addon_test_1.UnitAmountInCents["USD"]);

                plan2 = new Plan(GetMockPlanCode(), "aarons test plan 2")
                {
                    Description = "Create Subscription Plan With Addons Test 2"
                };
                plan2.UnitAmountInCents.Add("USD", 1900);
                plan2.Create();

                addon2 = plan2.NewAddOn("addon1", "addon2");
                addon2.DisplayQuantityOnHostedPage = true;
                addon2.UnitAmountInCents.Add("USD", 200);
                addon2.DefaultQuantity = 1;
                addon2.Create();

                var addon_test_2 = plan2.GetAddOn("addon1");
                Assert.Equal(addon2.UnitAmountInCents["USD"], addon_test_2.UnitAmountInCents["USD"]);

                account = CreateNewAccountWithBillingInfo();

                sub = new Subscription(account, plan, "USD");
                sub.AddOns.Add(new SubscriptionAddOn("addon1", 100, 1)); // TODO allow passing just the addon code
                sub.Create();

                // confirm that Create() doesn't duplicate the AddOns
                Assert.Equal(1, sub.AddOns.Count);

                sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
                sub.State.Should().Be(Subscription.SubscriptionState.Active);

                // test changing the plan of a subscription

                sub2 = Subscriptions.Get(sub.Uuid);
                sub2.UnitAmountInCents = plan2.UnitAmountInCents["USD"];
                sub2.Plan = plan2;

                foreach (var addOn in sub2.AddOns)
                {
                    addOn.UnitAmountInCents = plan2.UnitAmountInCents["USD"];
                }

                sub2.ChangeSubscription(Subscription.ChangeTimeframe.Now);

                // check if the changes were saved
                sub3 = Subscriptions.Get(sub2.Uuid);
                sub3.UnitAmountInCents.Should().Equals(plan2.UnitAmountInCents["USD"]);
                Assert.Equal(1, sub3.AddOns.Count);
                foreach (var addOn in sub3.AddOns)
                {
                    addOn.UnitAmountInCents.Should().Equals(plan2.UnitAmountInCents["USD"]);
                }

            } finally {
                if (sub != null) sub.Cancel();
                if (plan2 != null) plan2.Deactivate();
                if (plan != null) plan.Deactivate();
                if (account != null) account.Close();
            }
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:88,代码来源:SubscriptionTest.cs

示例10: RecoverSessionContext

        /// <summary>
        /// Recovers the session context.
        /// </summary>
        /// <param name="group">The group.</param>
        public void RecoverSessionContext(ComDaGroup group)
        {
            // create a new subscription and copy existing one.
            Subscription discardSubscription = group.Subscription;
            Subscription subscription = new Subscription();
            subscription.DisplayName = discardSubscription.DisplayName;
            subscription.PublishingInterval = discardSubscription.PublishingInterval;
            subscription.KeepAliveCount = discardSubscription.KeepAliveCount;
            subscription.LifetimeCount = discardSubscription.LifetimeCount;
            subscription.MaxNotificationsPerPublish = discardSubscription.MaxNotificationsPerPublish;
            subscription.Priority = discardSubscription.Priority;
            subscription.PublishingEnabled = discardSubscription.PublishingEnabled;
            subscription.DisableMonitoredItemCache = discardSubscription.DisableMonitoredItemCache;

            try
            {
                discardSubscription.Dispose();
            }
            catch (Exception)
            {
            }

            m_session.AddSubscription(subscription);
            
            try
            {
                // create the initial subscription.
                subscription.Create();

                // set the keep alive interval to 30 seconds and the the lifetime interval to 5 minutes.
                subscription.KeepAliveCount = (uint)((30000 / (int)subscription.CurrentPublishingInterval) + 1);
                subscription.LifetimeCount = (uint)((600000 / (int)subscription.CurrentPublishingInterval) + 1);

                // update the subscription.
                subscription.Modify();
            }
            catch (Exception e)
            {
                m_session.RemoveSubscription(subscription);
                throw ComUtils.CreateComException(e, ResultIds.E_FAIL);
            }

            // update the group.
            group.ActualUpdateRate = (int)(subscription.CurrentPublishingInterval * 2);
            group.Subscription = subscription;
            group.RecreateItems();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:51,代码来源:ComDaGroupManager.cs

示例11: UpdateSubscription

        public void UpdateSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Update Subscription Plan 1"
            };
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var plan2 = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Update Subscription Plan 2"
            };
            plan2.UnitAmountInCents.Add("USD", 750);
            plan2.Create();
            PlansToDeactivateOnDispose.Add(plan2);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();
            sub.Plan = plan2;

            sub.ChangeSubscription(); // change "Now" is default

            var newSubscription = Subscriptions.Get(sub.Uuid);

            newSubscription.PendingSubscription.Should().BeNull();
            newSubscription.Plan.Should().Be(plan2);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:31,代码来源:SubscriptionTest.cs

示例12: UpdateNotesSubscription

        public void UpdateNotesSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Postpone Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            Dictionary<string, string> notes = new Dictionary<string, string>();

            notes.Add("CustomerNotes", "New Customer Notes");
            notes.Add("TermsAndConditions", "New T and C");
            notes.Add("VatReverseChargeNotes", "New VAT Notes");

            sub.UpdateNotes(notes);

            sub.CustomerNotes.Should().Be(notes["CustomerNotes"]);
            sub.TermsAndConditions.Should().Be(notes["TermsAndConditions"]);
            sub.VatReverseChargeNotes.Should().Be(notes["VatReverseChargeNotes"]);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:27,代码来源:SubscriptionTest.cs

示例13: TerminateSubscriptionPartialRefund

        public void TerminateSubscriptionPartialRefund()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Terminate Partial Refund Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 2000);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            sub.Terminate(Subscription.RefundType.Partial);
            sub.State.Should().Be(Subscription.SubscriptionState.Expired);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:18,代码来源:SubscriptionTest.cs

示例14: SubscriptionAddOverloads

        public void SubscriptionAddOverloads()
        {
            Plan plan = null;
            Account account = null;
            Subscription sub = null;
            System.Collections.Generic.List<AddOn> addons = new System.Collections.Generic.List<AddOn>();

            try
            {
                plan = new Plan(GetMockPlanCode(), "subscription addon overload plan")
                {
                    Description = "Create Subscription Plan With Addons Test"
                };
                plan.UnitAmountInCents.Add("USD", 100);
                plan.Create();

                int numberOfAddons = 7;

                for (int i = 0; i < numberOfAddons; ++i)
                {
                    var name = "Addon" + i.AsString();
                    var addon = plan.NewAddOn(name, name);
                    addon.DisplayQuantityOnHostedPage = true;
                    addon.UnitAmountInCents.Add("USD", 1000 + i);
                    addon.DefaultQuantity = i;
                    addon.Create();
                    addons.Add(addon);
                }

                account = CreateNewAccountWithBillingInfo();

                sub = new Subscription(account, plan, "USD");
                Assert.NotNull(sub.AddOns);

                sub.AddOns.Add(new SubscriptionAddOn("Addon0", 100, 1));
                sub.AddOns.Add(addons[1]);
                sub.AddOns.Add(addons[2], 2);
                sub.AddOns.Add(addons[3], 3, 100);
                sub.AddOns.Add(addons[4].AddOnCode);
                sub.AddOns.Add(addons[5].AddOnCode, 4);
                sub.AddOns.Add(addons[6].AddOnCode, 5, 100);

                sub.Create();
                sub.State.Should().Be(Subscription.SubscriptionState.Active);

                for (int i = 0; i < numberOfAddons; ++i)
                {
                    var code = "Addon" + i.AsString();
                    var addon = sub.AddOns.AsQueryable().First(x => x.AddOnCode == code);
                    Assert.NotNull(addon);
                }

                sub.AddOns.RemoveAt(0);
                Assert.Equal(6, sub.AddOns.Count);

                sub.AddOns.Clear();
                Assert.Equal(0, sub.AddOns.Count);

                var subaddon = new SubscriptionAddOn("a",1);
                var list = new System.Collections.Generic.List<SubscriptionAddOn>();
                list.Add(subaddon);
                sub.AddOns.AddRange(list);
                Assert.Equal(1, sub.AddOns.Capacity);

                Assert.DoesNotThrow(delegate {
                    sub.AddOns.AsReadOnly();
                });

                Assert.True(sub.AddOns.Contains(subaddon));

                Predicate<SubscriptionAddOn> p = x => x.AddOnCode == "a";
                Assert.True(sub.AddOns.Exists(p));
                Assert.NotNull(sub.AddOns.Find(p));
                Assert.Equal(1, sub.AddOns.FindAll(p).Count);
                Assert.NotNull(sub.AddOns.FindLast(p));

                int count = 0;
                sub.AddOns.ForEach(delegate(SubscriptionAddOn s)
                {
                    count++;
                });
                Assert.Equal(1, count);

                Assert.Equal(0, sub.AddOns.IndexOf(subaddon));

                Assert.DoesNotThrow(delegate {
                    sub.AddOns.Reverse();
                    sub.AddOns.Sort();
                });
            }
            finally
            {
                try
                {
                    if (sub != null && sub.Uuid != null) sub.Cancel();
                    if (plan != null) plan.Deactivate();
                    if (account != null) account.Close();
                }
                catch (RecurlyException e) { }
            }
//.........这里部分代码省略.........
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:101,代码来源:SubscriptionTest.cs

示例15: DoQueueSizeTest

        /// <summary>
        /// Reads an verifies all of the nodes.
        /// </summary>
        private bool DoQueueSizeTest(bool modifyQueueSize)
        {
            // follow tree from each starting node.
            bool success = true;
                                 
            // collection writeable variables that don't change during the test.
            lock (m_variables)
            {
                m_lastWriteTime = DateTime.MinValue;
                m_writeDelayed = false;
                m_writeTimerCounter++;
                m_variables.Clear();

                // collection writeable variables that don't change during the test.
                for (int ii = 0; ii < WriteableVariables.Count; ii++)
                {
                    AddVariableToTest(WriteableVariables[ii], m_variables, false);
                }

                // reduce list based on coverage.
                List<TestVariable> variables = new List<TestVariable>();

                int counter = 0;

                foreach (TestVariable variable in m_variables)
                {
                    if (!CheckCoverage(ref counter))
                    {
                        continue;
                    }

                    variables.Add(variable);
                }
                
                // check if there is anything to work with.
                if (variables.Count == 0)
                {
                    Log("WARNING: No writeable variables found.");
                    Log(WriteTest.g_WriteableVariableHelpText);
                    return true;
                }

                m_variables.Clear();
                m_variables.AddRange(variables);

                ReadEURanges(m_variables);

                InitialWrite();

                // check if there is anything to work with.
                if (m_variables.Count == 0)
                {
                    Log("WARNING: No writeable variables found.");
                    Log(WriteTest.g_WriteableVariableHelpText);
                    return true;
                }

                Log("Starting QueueSizeTest for {0} Variables ({1}% Coverage, Start={2})", m_variables.Count, Configuration.Coverage, m_variables[0].Variable);

                m_stopped = 0;
                m_writeInterval = 1000;
                m_useDeadbandValues = false;

                m_errorEvent.Reset();
            }
            
            // create subscription.
            Subscription subscription = new Subscription();

            subscription.PublishingInterval = 5000;
            subscription.PublishingEnabled = true;
            subscription.Priority = 0;
            subscription.KeepAliveCount = 100;
            subscription.LifetimeCount = 100;
            subscription.MaxNotificationsPerPublish = 100;
            
            Session.AddSubscription(subscription);    
            subscription.Create();

            m_publishingTime = subscription.CurrentPublishingInterval;

            m_writerTimer = new Timer(DoWrite, m_writeTimerCounter, 0, m_writeInterval);
        
            if (m_errorEvent.WaitOne(1000, false))
            {
                success = false;
            }
            
            // create monitored items.
            if (success)
            {
                lock (m_variables)
                {
                    m_monitoredItems = new Dictionary<uint,TestVariable>();

                    for (int ii = 0; ii < m_variables.Count; ii++)
                    {
//.........这里部分代码省略.........
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:101,代码来源:MonitoredItemTest.cs


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