예제 #1
0
        void Basic()
        {
            var time = TrivialNtpClient.RetrieveTime("0.medo64.pool.ntp.org");
            var diff = DateTime.UtcNow - time;

            Assert.True(Math.Abs(diff.TotalSeconds) < 1);
        }
예제 #2
0
        public void Basic()
        {
            var time = TrivialNtpClient.RetrieveTime("0.medo64.pool.ntp.org");
            var diff = DateTime.UtcNow - time;

            Assert.InRange <double>(diff.TotalSeconds, -2, 2);
        }
예제 #3
0
 public void NonExistingHost()
 {
     using var client = new TrivialNtpClient("nonexisting.medo64.com");
     Assert.Throws <InvalidOperationException>(() => {
         var time = client.RetrieveTime();
     });
 }
예제 #4
0
 public void Timeout()
 {
     using var client = new TrivialNtpClient("0.medo64.pool.ntp.org")
           {
               Timeout = 1
           };
     Assert.Throws <InvalidOperationException>(() => {
         var time = client.RetrieveTime();
     });
 }