Ejemplo n.º 1
0
        private void LoadSubscribers(string query = null)
        {
            var subscribers = string.IsNullOrEmpty(query) ? SubscriberHelper.GetSubscribers() : SubscriberHelper.SearchSubscribers(query);

            lbSubscribers.Items.Clear();
            lbSubscribers.Items.AddRange(subscribers.Select(x => x.ToString()).ToArray());
        }
        public void UpgradeSubscription_ChargesProRatadAmount()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);

            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber,
                                                                       TestConstants.MediumSubscriptionPlanId,
                                                                       creditCard);
            var upgradeInvoice = subscriberHelper.ChangeSubscriberFeatureLevelWithOnFilePayment(subscriber, TestConstants.HighSubscriptionPlanId);

            Assert.AreEqual(15, upgradeInvoice.Amount.Value);
        }
 public void Init()
 {
     _subscriberClient = Substitute.For<ISpreedlySubscribers>();
     _subscriptionPlansClient = Substitute.For<ISpreedlySubscriptionPlans>();
     _paymentsClient = Substitute.For<ISpreedlyInvoices>();
     _subscriberHelper = new SubscriberHelper(_subscriberClient, _paymentsClient, _subscriptionPlansClient);
 }
Ejemplo n.º 4
0
        private void btnSubscriberShowInfo_Click(object sender, EventArgs e)
        {
            var sub = SubscriberHelper.GetSubscribers().Where(x => x.ToString().Equals(lbSubscribers.SelectedItem)).FirstOrDefault();

            var form = new SubscriberInfo(sub);

            form.ShowDialog();
        }
Ejemplo n.º 5
0
 public ActionResult Create([Bind(Include = "Id,FirstName,LastName,State,ZipCode")] Subscriber subscriber)
 {
     if (ModelState.IsValid)
     {
         SubscriberHelper.AddSubscriber(subscriber);
         return(RedirectToAction("Index"));
     }
     return(View(subscriber));
 }
Ejemplo n.º 6
0
        private void btnSubscriberUpdate_Click(object sender, EventArgs e)
        {
            var sub = SubscriberHelper.GetSubscribers().Where(x => x.ToString().Equals(lbSubscribers.SelectedItem)).FirstOrDefault();

            var form = new SubscriberUpdate(sub);

            form.FormClosed += delegate { LoadSubscribers(); };
            form.ShowDialog();
        }
Ejemplo n.º 7
0
 private void btnAddSubscriber_Click(object sender, EventArgs e)
 {
     try
     {
         SubscriberHelper.AddSubscriber(tbSubscriberName.Text, tbSubscriberSurname.Text, tbSubscriberPhoneNumber.Text);
         LoadSubscribers();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 8
0
 private void btnSubscriberDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete this subscriber?",
                         "Deleting",
                         MessageBoxButtons.YesNoCancel,
                         MessageBoxIcon.Question) == DialogResult.Yes)
     {
         var sub = SubscriberHelper.GetSubscribers().Where(x => x.ToString().Equals(lbSubscribers.SelectedItem)).FirstOrDefault();
         SubscriberHelper.DeleteSubscriber(sub.Id);
         LoadSubscribers();
     }
 }
        public void Init()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };

            if (!subscriberHelper.Exists(subscriber.CustomerId))
                subscriberHelper.CreateSubscriber(subscriber.CustomerId, subscriber.Email, subscriber.ScreenName);
        }
Ejemplo n.º 10
0
        // GET: Subscribers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var subscriber = SubscriberHelper.FindSubscriber((int)id);

            if (subscriber == null)
            {
                return(HttpNotFound());
            }
            return(View(subscriber));
        }
        public void CreateSubscription_WithHelper_ReturnsInvoice()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.MediumSubscriptionPlanId, creditCard);

            Assert.NotNull(invoice);
        }
Ejemplo n.º 12
0
 public ActionResult DeleteConfirmed(int id)
 {
     SubscriberHelper.DeleteSubscriber(id);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 13
0
 private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
 {
     FrontendModule.Current.DependencyResolver.Rebind <ISubscribeFormModel>().To <SubscribeFormModelCustom>();
     SubscriberHelper.CreateCustomSubscriberField();
 }
        public void DowngradeSubscription_GivesStoreCreditToSubscriber()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.HighSubscriptionPlanId, creditCard);
            subscriberHelper.ChangeSubscriberFeatureLevelWithOnFilePayment(subscriber, TestConstants.LowSubscriptionPlanId);
            var downgradedSubscriber = subscriberHelper.FetchSubscriber(subscriber.CustomerId);

            Assert.GreaterOrEqual(downgradedSubscriber.StoreCredit.Value, 0);
        }
        public void CreateSubscription_WithHelper_ForFreeSubscriptionPlan_ThrowsForbiddenActionException()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.FreePlanSubscriptionPlanId, creditCard);
        }
        public void CreateSubscription_WithHelper_WhenGatewayTimesout_ThrowsPaymentGatewayTimeoutException()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.GatewayUnavailableCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.MediumSubscriptionPlanId, creditCard);
        }
Ejemplo n.º 17
0
        // GET: Subscribers
        public ActionResult Index(string searchString)
        {
            var subscribers = SubscriberHelper.GetSubscribers(searchString);

            return(View(subscribers));
        }
Ejemplo n.º 18
0
        // GET: Subscribers/Report
        public ActionResult Report()
        {
            var subscribers = SubscriberHelper.GetSubscribers(null);

            return(View(subscribers));
        }
Ejemplo n.º 19
0
        public void MyTestInitialize()
        {
            // Helper code to get the HttpContext
            var mySIMPLTestContext = new SIMPLTestContext();
            HttpContext.Current = mySIMPLTestContext.GetHttpSession();

            // Helper Code to get the user logged into Windows
            var userName = mySIMPLTestContext.GetNameFromWindowsIdentity();

            // Calling actual production code to set the instance for this username
            CurrentUser.SetInstance(userName);

            // Calling actual production code to get the Rosettian User Object
            RosettianUser = CurrentUser.AsUserDto();

            BusinessFacadeforTests = DependencyResolver.Current.GetService<IBusinessFacade>();
            SubscriberHelperforTests = DependencyResolver.Current.GetService<SubscriberHelper>();

            // Set up the LocationController
            LocationController4Tests = DependencyResolver.Current.GetService<LocationController>();

            LocationController4Tests.ControllerContext = new ControllerContext(new HttpContextWrapper(HttpContext.Current), new RouteData(), LocationController4Tests);
        }
Ejemplo n.º 20
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     SubscriberHelper.UpdateSubscriber(_subscriber.Id, tbName.Text, tbSurname.Text, tbPhoneNumber.Text, tbBalance.Text);
     Close();
 }