public PingPongHandler(ILog logger, IPinger pinger, TimeSpan?autoSendPingInterval) { mLogger = logger; mAutoSendPingInterval = autoSendPingInterval; mPinger = pinger; mPinger.OnPong += OnPong; }
public void PropertyPingerTest() { //Arrange var mock = new Mock <IPinger>(); IProtocol protocol = new IcmpProtocol("ya.ru") { Message = "Data" }; IProtocol _protocol; _protocol = new HttpProtocol("http://ya.ru") { Message = "Data" }; //Act mock.Setup(x => x.Protocol); mock.Setup(x => x.Interval); mock.SetupProperty(x => x.Interval, 0); mock.Setup(x => x.Protocol).Returns(_protocol); //Assert IPinger pinger = mock.Object; Assert.AreEqual(_protocol, pinger.Protocol); Assert.AreEqual(0, pinger.Interval); Assert.AreNotSame(pinger.Protocol, protocol); Assert.IsFalse(pinger.Protocol == protocol); Assert.IsTrue(pinger.Interval > -1); }
public NetworkInformationCommand( NetworkInformationConnection networkInformationConnection ) { this._networkInformationConnection = networkInformationConnection; this._pinger = CreatePinger(networkInformationConnection); }
public TwitchBotWorker(ILogger <TwitchBotWorker> logger, IIrcClient ircClient, IPinger pinger, IAzureFunctionClient azureFunctionClient) { _logger = logger; _ircClient = ircClient; _pinger = pinger; _azureFunctionClient = azureFunctionClient; }
private async Task OnTimedOutageQueueAsync( string queueName, IPinger pinger, string endpoint) { if (!pinger.Ping(endpoint) && await messageFlow.QueueDisableSendAsync(queueName) && outageTimers.TryRemove(queueName, out Timer outageTimer)) { outageTimer.Dispose(); } }
public MessageFlowManager( IPinger pinger, ILogger logger) { this.logger = logger; this.pinger = pinger; this.messageFlow = new MessageFlow(logger); this.maxOutageInSeconds = 60; if (!Int32.TryParse(ConfigurationManager.AppSettings["MaxOutageInSeconds"], out maxOutageInSeconds)) { logger.LogCritical($"Invalid configuration setting for MaxOutageInSeconds. Default value 60 applies."); } }
private async Task OnTimedOutageSubscriptionAsync( string topicName, string subscriptionName, IPinger pinger, string endpoint) { if (!pinger.Ping(endpoint) && await messageFlow.SubscriptionDisableSendAsync(topicName, subscriptionName) && outageTimers.TryRemove($"{topicName}_{subscriptionName}", out Timer outageTimer)) { outageTimer.Dispose(); } }
public DeviceSearchService(ILogger logger, IDataAccessDispatcher dispatcher, IPinger pinger, IFadeCandyPinger fadeCandyPinger) { this.dispatcher = dispatcher; this.logger = logger; this.pinger = pinger; this.fadeCandyPinger = fadeCandyPinger; discoveredDevices = new ConcurrentQueue <DiscoveredDevice>(); currentSearchTokenSource = new CancellationTokenSource(); isSearching = false; }
private static async void Start(IPinger pinger, ManualResetEvent exit) { while (true) { var input = Console.ReadLine(); if (input.ToLowerInvariant() == "exit") { exit.Set(); } else { var pong = await pinger.Ping(input); Console.WriteLine(pong); } } }
public static void Main(string[] args) { IPonger ponger = ActorWrapper.WrapActor <IPonger>(() => new Ponger()); IPinger pinger = ActorWrapper.WrapActor <IPinger>(() => new Pinger(ponger)); //IPonger ponger = new Ponger(); //IPinger pinger = new Pinger(ponger); new Thread(delegate(object o) { Thread.Sleep(10000); Console.WriteLine(s_Count); Thread.Sleep(1000); }).Start(); pinger.Ping(); }
public void ActionsPingerWorkTest() { //Arrange var mock = new Mock <IPinger>(); var ui = new ConsoleWorkProcessUi(); var ilog = ui.InjectKernel.Get <Pinger.Logger.ILogger>(); //Act mock.Setup(x => x.StartWork(ilog)).Verifiable(); mock.Setup(x => x.StopWork()).Verifiable(); mock.Setup(x => x.StartWork(null)).Throws <NullReferenceException>(); //Assert IPinger ping = mock.Object; ping.StartWork(null); mock.VerifySet(x => x.StartWork(ilog)); mock.VerifySet(x => x.StopWork()); }
private static void DoPingPong(IPinger pingerB, IPinger pingerA) { pingerA.Subscribe(queueA, message => { Console.WriteLine("A {0}", message); pingerA.Publish(queueB, (int.Parse(message) + 1).ToString()); }); pingerB.Subscribe(queueB, message => { Console.WriteLine("B {0}", message); pingerB.Publish(queueA, (int.Parse(message) + 1).ToString()); }); pingerA.Publish(queueB, 0.ToString()); Thread.Sleep(1000); pingerA.Dispose(); pingerB.Dispose(); }
public PingerActor(TestUntil until) { _count = 0; _self = SelfAs <IPinger>(); _until = until; }
public void Pong(IPinger pinger) { Console.WriteLine($"Ponging back to pinger..."); pinger.Ping(_self); }
public void Pong(IPinger pinger) { Logger.Log("pong"); pinger.Ping(self); }
public RefreshServiceStatusHandler(IDbContext db, IPinger pinger, IMediator mediator, IValidator <RefreshServiceStatus> validator) : base(validator) { _db = db ?? throw new ArgumentNullException(nameof(db)); _pinger = pinger ?? throw new ArgumentNullException(nameof(pinger)); _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); }
public ServerServicesProvider(ITcpClient tcpClient, IDnsResolver dnsResolver, IPinger pinger) { TcpClient = tcpClient; DnsResolver = dnsResolver; Pinger = pinger; }
public MachineActor(IPinger pinger, string machineName) { _pinger = pinger; _machineName = machineName; Become(Alive); }
public PingerActor() { count = 0; self = SelfAs <IPinger>(); }
public void Pong(IPinger pinger) { pinger.Ping(self); }
public DeviceStatusService(IFadeCandyPinger fadeCandyPinger, IPinger pinger) { this.fadeCandyPinger = fadeCandyPinger; this.pinger = pinger; }
public UptimeMonitor(TimeSpan successWait, IPinger pinger, IResultLogger resultLogger, Action waitFunction = null) { _pinger = pinger; _resultLogger = resultLogger; _waitFunction = waitFunction ?? (() => Thread.Sleep(successWait)); }