SHARE
TWEET

Untitled

a guest Dec 13th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface IConsulFactory {
  2.   IConsulClient BuildClient(ConsulClientConfiguration config)
  3. }
  4.  
  5. class ConsulConfigProvider {
  6.     private IConsulFactory _factory;
  7.     ConsulConfigProvider(IConsulFactory factory) {
  8.         _factory = factory
  9.     }
  10. }
  11.  
  12. class DefaultConsulFactory : IConsulFactory {
  13.     override   IConsulClient BuildClient(ConsulClientConfiguration config) {
  14.         return new ConsulClient(config)
  15.     }
  16. }
  17.  
  18. // В тестах
  19.  
  20. class TestConsulClient: IConsulClient {
  21.     override ... // хуячишь какие то тестовые конфиги, которые проверять будешь или например бросишь эксепшон.
  22. }
  23.  
  24. class TestConsulFactory : IConsulFactory {
  25.     override   IConsulClient BuildClient(ConsulClientConfiguration config) {
  26.         return new TestConsulClient();
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top