Пример #1
0
        public void UpdateSubscription_ValidParameters_Successful()
        {
            //Arrange
            StripeSubscription subscription = new StripeSubscription();
            subscription.Id = subscriptionId;

            Mock<StripeSubscriptionService> custSubService = new Mock<StripeSubscriptionService>(null);
            custSubService.Setup(sub => sub.Update(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<StripeSubscriptionUpdateOptions>(), null)).Returns(subscription);
            stripeAccessor = new StripeAccessorService(custSubService.Object, charService.Object, cusService.Object);

            //Act
            string returnedId = stripeAccessor.UpdateSubscription(customerId, subscriptionId, planId);

            //Assert
            Assert.That(returnedId, Is.EqualTo(subscriptionId));
        }
Пример #2
0
        public void UpdateSubscription_InvalidParameters_ThrowsStripeException()
        {
            //Arrange
            StripeException exception = new StripeException();
            exception.StripeError = new StripeError();
            exception.StripeError.ErrorType = "invalid_request";

            Mock<StripeSubscriptionService> custSubService = new Mock<StripeSubscriptionService>(null);
            custSubService.Setup(sub => sub.Update(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<StripeSubscriptionUpdateOptions>(), null)).Throws(exception);
            stripeAccessor = new StripeAccessorService(custSubService.Object, charService.Object, cusService.Object);

            //Act
            string returnedException = stripeAccessor.UpdateSubscription(customerId, subscriptionId, planId);

            //Assert
            Assert.That(returnedException, Is.EqualTo("invalid_request"));
        }