public void CancelSubscription_SubscriptionExists_Successful() { //Arrange stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, cusService.Object); //Act string returnedId = stripeAccessor.CancelSubscription(customerId, subscriptionId); //Assert Assert.That(returnedId, Is.EqualTo(subscriptionId)); }
public void CancelSubscription_InvalidParameters_ThrowsException() { //Arrange Exception exception = new Exception(); Mock<StripeSubscriptionService> custSubService = new Mock<StripeSubscriptionService>(null); custSubService.Setup(sub => sub.Cancel(It.IsAny<string>(), It.IsAny<string>(), false, null)).Throws(exception); stripeAccessor = new StripeAccessorService(custSubService.Object, charService.Object, cusService.Object); //Act string returnMessage = stripeAccessor.CancelSubscription(customerId, subscriptionId); //Assert Assert.That(returnMessage, Is.Null); }
public void ChargeCustomer_InvalidParameters_ThrowsException() { //Arrange Exception exception = new Exception(); Mock<StripeChargeService> custChargeService = new Mock<StripeChargeService>(null); custChargeService.Setup(charg => charg.Create(It.IsAny<StripeChargeCreateOptions>(), null)) .Throws(exception); stripeAccessor = new StripeAccessorService(subService.Object, custChargeService.Object, cusService.Object); //Act //Act String returnedException = stripeAccessor.ChargeCustomer(customerId, 2, 15, 2016, 1, 25); //Assert Assert.That(returnedException, Is.Null); }
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)); }
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")); }
public void UpdateCustomer_ValidParameters_Successful() { //Arrange StripeCustomer customer = new StripeCustomer(); customer.Id = customerId; Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Update(It.IsAny<string>(), It.IsAny<StripeCustomerUpdateOptions>(), null)) .Returns(customer); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act string returnedId = stripeAccessor.UpdateCustomer(customerId, "email", "Hal", "Wilkerson"); //Assert Assert.That(returnedId, Is.EqualTo(customerId)); }
public void UpdateCustomer_InvalidParameters_ThrowsStripeException() { //Arrange StripeException exception = new StripeException(); exception.StripeError = new StripeError(); exception.StripeError.ErrorType = "invalid_request"; Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Update(It.IsAny<string>(), It.IsAny<StripeCustomerUpdateOptions>(), null)) .Throws(exception); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act string returnedException = stripeAccessor.UpdateCustomer(customerId, "email", "Hal", "Wilkerson"); //Assert Assert.That(returnedException, Is.EqualTo("invalid_request")); }
public void GetCustomer_ValidParameters_Successful() { //Arrange StripeCustomer customer = new StripeCustomer(); customer.Id = customerId; Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Get(It.IsAny<String>(), null)) .Returns(customer); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act StripeObject returnedCustomer = stripeAccessor.GetCustomer(customerId); //Assert Assert.That(returnedCustomer.Id, Is.EqualTo(customerId)); Assert.That(returnedCustomer, Is.InstanceOf<StripeCustomer>()); }
public void SubscribeCustomer_InvalidParameters_ThrowsException() { //Arrange Exception exception = new Exception(); 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.Null); }
public void GetCustomer_InvalidParameters_ThrowsStripeException() { //Arrange StripeException exception = new StripeException(); exception.StripeError = new StripeError(); CreateCustomerError error; exception.StripeError.ErrorType = "invalid_request"; Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Get(It.IsAny<string>(), null)) .Throws(exception); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act StripeObject returnedException = stripeAccessor.GetCustomer(customerId); error = (CreateCustomerError)returnedException; //Assert Assert.That(returnedException, Is.InstanceOf<CreateCustomerError>()); Assert.That(error.Error_Type, Is.EqualTo("invalid_request")); }
public void GetCustomer_InvalidParameters_ThrowsException() { //Arrange Exception exception = new Exception(); Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Get(It.IsAny<string>(), null)) .Throws(exception); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act StripeObject returnedException = stripeAccessor.GetCustomer(customerId); //Assert Assert.That(returnedException, Is.Null); }
public void CreateCustomer_InvalidParameters_ThrowsException() { //Arrange Exception exception = new Exception(); Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null); custCustService.Setup(cust => cust.Create(It.IsAny<StripeCustomerCreateOptions>(), null)) .Throws(exception); stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object); //Act StripeObject returnedException = stripeAccessor.CreateCustomer("email", "Hal", "Wilkerson"); //Assert Assert.That(returnedException, Is.Null); }
public void ChargeCustomer_ValidParameters_Successful() { //Arrange StripeCharge charge = new StripeCharge(); charge.Id = chargeId; Mock<StripeChargeService> custChargeService = new Mock<StripeChargeService>(null); custChargeService.Setup(charg => charg.Create(It.IsAny<StripeChargeCreateOptions>(), null)) .Returns(charge); stripeAccessor = new StripeAccessorService(subService.Object, custChargeService.Object, cusService.Object); //Act String returnedId = stripeAccessor.ChargeCustomer(customerId, 2, 15, 2016, 1, 25); //Assert Assert.That(returnedId, Is.EqualTo(chargeId)); }
public SqlUserDatabase(MySqlConnection conn, StripeAccessorService.StripeAccessorService stripeAccessor) : base(conn) { this.stripeAccessor = stripeAccessor; }