Beispiel #1
0
        /// <summary>
        /// (internal for tests only)
        /// Overrides the default static implementation with a temporary alternate implementation.
        /// </summary>
        /// <param name="dns">The alternate <see cref="IDns"/> implementation.</param>
        /// <returns>An object that must be disposed in order to restore the original static implementation.</returns>
        internal static IDisposable Override(IDns dns)
        {
            var od = new OverrideDisposable();

            _implementation = dns;
            return(od);
        }
Beispiel #2
0
        public DiscoveryTestBuilder WithDns(IDns dnsClient             = default,
                                            bool mock                  = false,
                                            IPeerSettings peerSettings = default)
        {
            _dnsClient = dnsClient == default(IDns) && mock == false
                ? Substitute.For <IDns>()
                : DiscoveryHelper.MockDnsClient(_peerSettings = _peerSettings == null && peerSettings == default(IPeerSettings)
                    ? PeerSettingsHelper.TestPeerSettings()
                    : peerSettings);

            return(this);
        }
Beispiel #3
0
 public HastingsDiscovery(ILogger logger,
                          IPeerRepository peerRepository,
                          IDns dns,
                          IPeerSettings peerSettings,
                          IPeerClient peerClient,
                          IPeerMessageCorrelationManager peerMessageCorrelationManager,
                          ICancellationTokenProvider cancellationTokenProvider,
                          IEnumerable <IPeerClientObservable> peerClientObservables,
                          bool autoStart                                   = true,
                          int peerDiscoveryBurnIn                          = 10,
                          IHastingsOriginator stepProposal                 = default,
                          IHastingsCareTaker hastingsCareTaker             = default,
                          int millisecondsTimeout                          = 10_000,
Beispiel #4
0
 private HastingDiscoveryTest(ILogger logger = default,
                              IPeerRepository peerRepository = default,
                              IPeerSettings peerSettings     = default,
                              IDns dns = default,
                              IPeerClient peerClient = default,
                              IPeerMessageCorrelationManager peerMessageCorrelationManager = default,
                              ICancellationTokenProvider cancellationTokenProvider         = default,
                              IEnumerable <IPeerClientObservable> peerClientObservables    = default,
                              bool autoStart                                   = true,
                              int peerDiscoveryBurnIn                          = 10,
                              IHastingsOriginator state                        = default,
                              IHastingsCareTaker hastingsCareTaker             = default,
                              int millisecondsTimeout                          = 10_000,
Beispiel #5
0
        public TextServer(ISocket socket, IDns dns)
        {
            if (socket == null)
            {
                throw new ArgumentNullException();
            }

            if (dns == null)
            {
                throw new ArgumentNullException();
            }

            _listener = socket;
            _dns      = dns;
        }
Beispiel #6
0
 public TcpPingDriver(
     IDns dns = null,
     ISocketService socketService       = null,
     IStopWatchService stopWatchService = null,
     IWaiter waiter          = null,
     TextWriter outputWriter = null,
     TimeSpan retryInterval  = default(TimeSpan),
     TimeSpan timeOutLimit   = default(TimeSpan),
     int retryTimes          = 4)
 {
     Dns              = dns ?? new SystemDns();
     SocketService    = socketService ?? new SystemSocketService();
     StopWatchService = stopWatchService ?? new SystemStopWatchService();
     Waiter           = waiter ?? new Waiter();
     OutputWriter     = outputWriter ?? Console.Out;
     RetryInterval    = retryInterval != default(TimeSpan) ? retryInterval : TimeSpan.FromSeconds(1);
     TimeOutLimit     = timeOutLimit != default(TimeSpan) ? timeOutLimit : TimeSpan.FromSeconds(2);
     RetryTimes       = retryTimes;
 }
Beispiel #7
0
 public OverrideDisposable()
 {
     _captured = _implementation;
 }
Beispiel #8
0
 public DynamicPath(string path, IDns dotNetDns)
 {
     OriginalPath = CurrentPath = path;
     mDotNetDns   = dotNetDns;
     mRootedPath  = Path.IsPathRooted(path);
 }
Beispiel #9
0
 public DynamicPath(string path, IDns dotNetDns)
 {
     OriginalPath = CurrentPath = path;
       mDotNetDns = dotNetDns;
       mRootedPath = Path.IsPathRooted(path);
 }
 /// <summary>
 /// Dependency injection
 /// </summary>
 /// <param name="socket"></param>
 public HttpSocket(ISocket socket, ITimerService timerService, IDns dns)
 {
     this._socket = socket;
     this._timerService = timerService;
     this._dns = dns;
 }
Beispiel #11
0
 /// <summary>
 /// Dependency injection
 /// </summary>
 /// <param name="socket"></param>
 public HttpSocket(ISocket socket, ITimerService timerService, IDns dns)
 {
     this._socket       = socket;
     this._timerService = timerService;
     this._dns          = dns;
 }