public MFTestResults TimeServiceUpdateTest1()
        {
            MFTestResults result = MFTestResults.Pass;
            SystemTimeChangedEventHandler handler = new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);

            try
            {
                timerEvent.Reset();

                TimeService.SystemTimeChanged += handler;
                UpdateTimeNow();
                if (!timerEvent.WaitOne(60 * 1000, false)) /// Wait some time for the event to be fired.
                {
                    result = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }
            finally
            {
                TimeService.SystemTimeChanged -= handler;
            }

            return(result);
        }
        public MFTestResults TimeServiceStartTest0()
        {
            MFTestResults result = MFTestResults.Pass;
            SystemTimeChangedEventHandler handler = new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);

            try
            {
                timerEvent.Reset();

                TimeService.SystemTimeChanged += handler;

                byte[] primaryServer         = new byte[] { 192, 43, 244, 18 };
                byte[] alternateServer       = new byte[] { 129, 6, 15, 28 };
                TimeServiceSettings settings = new TimeServiceSettings();
                settings.PrimaryServer   = primaryServer;
                settings.AlternateServer = alternateServer;
                settings.Tolerance       = 100;
                settings.RefreshTime     = 60;

                /// Save the settings.
                TimeService.Settings = settings;
                TimeService.Start(); /// This should fire a sync event right away.

                if (!timerEvent.WaitOne(60 * 1000, false))
                {
                    result = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }
            finally
            {
                TimeService.SystemTimeChanged -= handler;
                TimeService.Stop();
            }

            return(result);
        }
        public MFTestResults TimeServiceStartTest0()
        {
            MFTestResults result = MFTestResults.Pass;
            SystemTimeChangedEventHandler handler = new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            try
            {
                timerEvent.Reset();

                TimeService.SystemTimeChanged += handler;

                byte[] primaryServer = new byte[] { 157, 54, 86, 20 };
                byte[] alternateServer = new byte[] { 10, 192, 53, 107 };
                TimeServiceSettings settings = new TimeServiceSettings();
                settings.PrimaryServer = primaryServer;
                settings.AlternateServer = alternateServer;
                settings.Tolerance = 100;
                settings.RefreshTime = 60;

                /// Save the settings.
                TimeService.Settings = settings;
                TimeService.Start(); /// This should fire a sync event right away.

                if (!timerEvent.WaitOne(60 * 1000, false))
                {
                    result = MFTestResults.Fail;
                }                
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }

            return result;
        }
        public MFTestResults TimeServiceUpdateTest1()
        {
            MFTestResults result = MFTestResults.Pass;
            SystemTimeChangedEventHandler handler = new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            try
            {
                timerEvent.Reset();

                TimeService.SystemTimeChanged += handler;
                TimeService.UpdateNow(new byte[] { 157, 54, 86, 20 }, 10);
                if (!timerEvent.WaitOne(60 * 1000, false)) /// Wait some time for the event to be fired.
                {
                    result = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }
            finally
            {
                TimeService.SystemTimeChanged -= handler;
            }

            return result;
        }
Пример #5
0
        public MFTestResults TimeServiceStartTest0()
        {
            MFTestResults result = MFTestResults.Pass;
            SystemTimeChangedEventHandler handler = new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            try
            {
                timerEvent.Reset();

                TimeService.SystemTimeChanged += handler;

                TimeServiceSettings settings = new TimeServiceSettings();
                settings.PrimaryServer = GetTimeServiceAddress().GetAddressBytes();
                settings.Tolerance = 100;
                settings.RefreshTime = 60;

                /// Save the settings.
                TimeService.Settings = settings;
                TimeService.Start(); /// This should fire a sync event right away.

                if (!timerEvent.WaitOne(60 * 1000, false))
                {
                    result = MFTestResults.Fail;
                }
            }
            catch (Exception ex)
            {
                Log.Exception("Unexpected exception", ex);
                result = MFTestResults.Fail;
            }
            finally
            {
                TimeService.SystemTimeChanged -= handler;
                TimeService.Stop();
            }

            return result;
        }