public void GetSubscriptionAction3() { Subscription sub; Plan newPlan; PayPalInterval interval; Guid userId; SubscriptionActions actions; sub = new Subscription(); sub.Plan = paidPlan; newPlan = paidPlan2; interval = new PayPalInterval(1, IntervalUnits.Years); userId = Guid.NewGuid(); actions = PayPalManagement.GetSubscriptionAction(sub, newPlan, interval, userId); Assert.AreEqual(ActionTypes.Modify, actions.Action); Assert.AreEqual(199.99, actions.NewSubscription.Cost); Assert.AreEqual(null, actions.NewSubscription.EndTime); Assert.IsTrue(actions.NewSubscription.Id != Guid.Empty); Assert.AreEqual("1 Y", actions.NewSubscription.PayPalInterval); Assert.AreEqual(newPlan, actions.NewSubscription.Plan); Assert.AreEqual(userId, actions.NewSubscription.UserId); }
public void Units() { ppi = new PayPalInterval("4 W"); ppi.Units = IntervalUnits.Months; Assert.AreEqual(4, ppi.Quantity); Assert.AreEqual(IntervalUnits.Months, ppi.Units); }
public void Quantity() { ppi = new PayPalInterval("4 W"); ppi.Quantity = 6; Assert.AreEqual(6, ppi.Quantity); Assert.AreEqual(IntervalUnits.Weeks, ppi.Units); }
public void AddTo4() { DateTime now = DateTime.Now; ppi = new PayPalInterval(6, IntervalUnits.Years); Assert.AreEqual(now.AddYears(6), ppi.AddTo(now)); }
public void AddTo3() { DateTime now = DateTime.Now; ppi = new PayPalInterval(5, IntervalUnits.Months); Assert.AreEqual(now.AddMonths(5), ppi.AddTo(now)); }
public void AddTo2() { DateTime now = DateTime.Now; ppi = new PayPalInterval(7, IntervalUnits.Days); Assert.AreEqual(now.AddDays(7), ppi.AddTo(now)); }
/// <summary> /// Modifies the subscription and adds the appropriate interval of /// time t the subscription. /// </summary> private void renewAccount() { PayPalInterval ppi; _saveSubscription = _existingSubscription; _log.DebugFormat("Renewing account for subscription '{0}'", _saveSubscription.Id); if (_saveSubscription.StartTime == null) { _saveSubscription.StartTime = _dbNow; } //Parse the interval, and add it to the subscription ppi = new PayPalInterval(_saveSubscription.PayPalInterval); _saveSubscription.EndTime = ppi.AddTo(_dbNow); }
public void ctor() { ppi = new PayPalInterval(7, IntervalUnits.Weeks); Assert.AreEqual(7, ppi.Quantity); Assert.AreEqual(IntervalUnits.Weeks, ppi.Units); }
public void Parse4() { ppi = new PayPalInterval("3 Y"); Assert.AreEqual(3, ppi.Quantity); Assert.AreEqual(IntervalUnits.Years, ppi.Units); }
public void Parse3() { ppi = new PayPalInterval("3 W"); Assert.AreEqual(3, ppi.Quantity); Assert.AreEqual(IntervalUnits.Weeks, ppi.Units); }
public void Parse2() { ppi = new PayPalInterval("5 D"); Assert.AreEqual(5, ppi.Quantity); Assert.AreEqual(IntervalUnits.Days, ppi.Units); }
public void TestToString4() { ppi = new PayPalInterval("5 Y"); Assert.AreEqual("5 Y", ppi.ToString()); }
public void Parse() { ppi = new PayPalInterval("3 M"); Assert.AreEqual(3, ppi.Quantity); Assert.AreEqual(IntervalUnits.Months, ppi.Units); }
public static SubscriptionActions GetSubscriptionAction(Subscription currentSubscription, Plan newPlan, PayPalInterval interval, Guid userId) { SubscriptionActions actions; actions = new SubscriptionActions(); //They need a subscription if they're switching to a paid plan if (newPlan.Id == 1) { actions.Action = ActionTypes.Cancel; } else { actions.Action = ActionTypes.Modify; actions.NewSubscription = getNewSubscription(newPlan, interval.Units == IntervalUnits.Months, userId); } if (currentSubscription == null || currentSubscription.Plan == null || currentSubscription.Plan.Id == 1) { if (newPlan.Id == 1) { actions.Action = ActionTypes.NoChange; } else { //The modify method will create a new subscription when upgrading from the free account actions.Action = ActionTypes.StartPlan; } } return(actions); }