Ejemplo n.º 1
0
        public void CreateCustomer_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.Create(It.IsAny<StripeCustomerCreateOptions>(), null))
                .Throws(exception);
            stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object);

            //Act
            StripeObject returnedException = stripeAccessor.CreateCustomer("email", "Hal", "Wilkerson");
            error = (CreateCustomerError)returnedException;

            //Assert
            Assert.That(returnedException, Is.InstanceOf<CreateCustomerError>());
            Assert.That(error.Error_Type, Is.EqualTo("invalid_request"));
        }
Ejemplo n.º 2
0
        public void CreateCustomer_ValidParameters_Successful()
        {
            //Arrange
            StripeCustomer customer = new StripeCustomer();
            customer.Id = customerId;

            Mock<StripeCustomerService> custCustService = new Mock<StripeCustomerService>(null);
            custCustService.Setup(cust => cust.Create(It.IsAny<StripeCustomerCreateOptions>(), null))
                .Returns(customer);
            stripeAccessor = new StripeAccessorService(subService.Object, charService.Object, custCustService.Object);

            //Act
            StripeObject returnedCustomer = stripeAccessor.CreateCustomer("email", "Hal", "Wilkerson");

            //Assert
            Assert.That(returnedCustomer.Id, Is.EqualTo(customerId));
            Assert.That(returnedCustomer, Is.InstanceOf<StripeCustomer>());
        }
Ejemplo n.º 3
0
        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);
        }