Beispiel #1
0
        public void SubscribeCustomer_ValidParameters_Successful()
        {
            //Arrange
            StripeSubscription subscription = new StripeSubscription();
            subscription.Id = subscriptionId;

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

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

            //Assert
            Assert.That(returnedId, Is.EqualTo(subscriptionId));
        }
Beispiel #2
0
        public void SubscribeCustomer_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.Create(It.IsAny<string>(), It.IsAny<string>(), null, null)).Throws(exception);
            stripeAccessor = new StripeAccessorService(custSubService.Object, charService.Object, cusService.Object);

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

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