Chapter 8. Protocols

 

This chapter covers

  • How protocols work in mountebank
  • An in-depth look at the TCP protocol
  • How to stub a bespoke text-based TCP protocol
  • How to stub a binary .NET Remoting service

Let’s get real: faking it only gets you so far. At some point, even the best virtual services have to lay down some real bits on the wire.

The functionality we have explored so far—responses, predicates, and behaviors—is largely the realm of stubbing and mocking tools. Those stubbing and mocking tools were created for creating test doubles in process, allowing you to perform focused tests by methodically manipulating dependencies. Responses correspond to what stub functions return, and predicates exist to provide different results based on the way the function is called (for example, returning a different result based on a request parameter). I’m not aware of any in-process mocking tools that have the concept of behaviors per se, but there’s nothing preventing them. Behaviors are transformations on the result.

8.1. How protocols work in mountebank

8.2. A TCP primer

8.3. Stubbing text-based TCP-based RPC

8.4. Binary support

8.5. Virtualizing a .NET Remoting service

Summary