Invalid Braintree API: Should I Change the Source Code or Wrap Each Class Individually?

I am working with the Braintree API for .NET to take care of payment processing. Their business does a great job of processing payments, and the wrapper API works for easy use. However, the provided API wrapper starts to work quickly with more thorough research or more intensive use; for example, it contains tame enums. My problem is with the testing module of my code that uses this shell.

To do this, I essentially need a layout of my own “fake” Braintree gateway, which will have some known values ​​in it, generate errors upon request, etc. My attack plan was to override the functionality of the Braintree API and redirect requests to the local endpoint in memory. Then I could use dependency injection to bind the proper gateway / shell at runtime.

At first it seemed smooth: despite the sins against software development that were fixed in the API shell, every method I needed to override was miraculously noted virtual. However, this came to a squeal: almost the constructor in the API wrapper is marked internal. Thus, I can neither inherit these classes, nor create them at my discretion for storage for testing.

On the sidelines: I create constructors internaland reasons that I will legitimately want to use. However, I reviewed the source code for this, and each constructor internalonly performs trivial property assignments. Thus, I am pleased to say that you should adhere to a different coding practice.

So, I have three options:

  • API . , , , , . , , .

  • API . internal , , . , API.

  • , API. ; , : (, API Braintree ).

, . , 2 , . - / , ? , ? , ?

+5
2

API, Facade. , , , . : API , .

+1

All Articles