Beispiel #1
0
        public void NtpClient_DefaultServer_GetsValidResponsesOverMultipleRequests()
        {
            var ntpEpoch = new DateTime(1900, 01, 01, 0, 0, 0, DateTimeKind.Utc);

            _GotResultSignal = new System.Threading.AutoResetEvent(false);
            var client = new Yort.Ntp.NtpClient();

            try
            {
                client.TimeReceived  += Client_TimeReceived;
                client.ErrorOccurred += Client_ErrorOccurred;
                for (int cnt = 0; cnt < 60; cnt++)
                {
                    client.BeginRequestTime();
                    _GotResultSignal.WaitOne(2000);
                    Assert.IsNotNull(_Result);
                    Assert.AreNotEqual(ntpEpoch, _Result);
                }
            }
            finally
            {
                client.TimeReceived  -= this.Client_TimeReceived;
                client.ErrorOccurred -= this.Client_ErrorOccurred;
            }
        }
Beispiel #2
0
		public void NtpClient_DefaultServer_GetsNonNullResponse()
		{
			_GotResultSignal = new System.Threading.AutoResetEvent(false);
			var client = new Yort.Ntp.NtpClient();
			try
			{
				client.TimeReceived += Client_TimeReceived;
				client.ErrorOccurred += Client_ErrorOccurred;
				client.BeginRequestTime();
				_GotResultSignal.WaitOne(1000);
				Assert.AreNotEqual(null, _Result);
			}
			finally
			{
				client.TimeReceived -= this.Client_TimeReceived;
				client.ErrorOccurred -= this.Client_ErrorOccurred;
			}
		}
Beispiel #3
0
        public void NtpClient_DefaultServer_GetsNonNullResponse()
        {
            _GotResultSignal = new System.Threading.AutoResetEvent(false);
            var client = new Yort.Ntp.NtpClient();

            try
            {
                client.TimeReceived  += Client_TimeReceived;
                client.ErrorOccurred += Client_ErrorOccurred;
                client.BeginRequestTime();
                _GotResultSignal.WaitOne(1000);
                Assert.IsNotNull(_Result);
            }
            finally
            {
                client.TimeReceived  -= this.Client_TimeReceived;
                client.ErrorOccurred -= this.Client_ErrorOccurred;
            }
        }
Beispiel #4
0
		public async Task WinRT_NtpClient_DefaultServer_GetsNonNullResponse()
		{
			var ntpClient = new Yort.Ntp.NtpClient();
			try
			{
				_GotTimeTaskCompletionSource = new TaskCompletionSource<DateTime?>();

				ntpClient.TimeReceived += ntpClient_TimeReceived;
				ntpClient.ErrorOccurred += NtpClient_ErrorOccurred;
				ntpClient.BeginRequestTime();

				var result = await _GotTimeTaskCompletionSource.Task;
				Assert.AreNotEqual(null, result);
			}
			finally
			{
				ntpClient.TimeReceived -= ntpClient_TimeReceived;
			}
		}
Beispiel #5
0
        public async Task WinRT_NtpClient_DefaultServer_GetsNonNullResponse()
        {
            var ntpClient = new Yort.Ntp.NtpClient();

            try
            {
                _GotTimeTaskCompletionSource = new TaskCompletionSource <DateTime?>();

                ntpClient.TimeReceived  += ntpClient_TimeReceived;
                ntpClient.ErrorOccurred += NtpClient_ErrorOccurred;
                ntpClient.BeginRequestTime();

                var result = await _GotTimeTaskCompletionSource.Task;
                Assert.AreNotEqual(null, result);
            }
            finally
            {
                ntpClient.TimeReceived -= ntpClient_TimeReceived;
            }
        }