本文整理汇总了C#中Subscription.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.Cancel方法的具体用法?C# Subscription.Cancel怎么用?C# Subscription.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription.Cancel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_cancel_the_subscription
public void Should_cancel_the_subscription()
{
var channel = Substitute.For<IModel>();
channel.IsOpen.Returns(true);
var subscription = new Subscription(channel)
{
ConsumerTag = "ConsumerTag"
};
// Action
subscription.Cancel();
// Assert
channel.Received(1).BasicCancel(subscription.ConsumerTag);
}
示例2: 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);
}
示例3: ListCanceledSubscriptions
public void ListCanceledSubscriptions()
{
var p = new Plan(GetMockPlanCode(), GetMockPlanName()) { Description = "Subscription Test" };
p.UnitAmountInCents.Add("USD", 400);
p.Create();
PlansToDeactivateOnDispose.Add(p);
for (var x = 0; x < 2; x++)
{
var account = CreateNewAccountWithBillingInfo();
var sub = new Subscription(account, p, "USD");
sub.Create();
sub.Cancel();
}
var subs = Subscriptions.List(Subscription.SubscriptionState.Canceled);
subs.Should().NotBeEmpty();
}
示例4: CancelSubscription
public void CancelSubscription()
{
var plan = CreateTestPlan ();
plan.Save ();
Assert.AreNotEqual (plan.Id, 0);
var subscription = new Subscription {
CardHash = GetCardHash (),
Customer = new Customer {
Email = "[email protected]"
},
Plan = plan
};
subscription.Save ();
subscription.Cancel ();
Assert.AreEqual (subscription.Status, SubscriptionStatus.Canceled);
}
示例5: 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();
}
}
示例6: 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) { }
}
//.........这里部分代码省略.........
示例7: ReactivateSubscription
public void ReactivateSubscription()
{
var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
{
Description = "Reactivate 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.State.Should().Be(Subscription.SubscriptionState.Canceled);
sub.Reactivate();
sub.State.Should().Be(Subscription.SubscriptionState.Active);
}