Пример #1
0
        public void time_zone_is_used_to_calculate_local_time()
        {
            TimeZoneInfo.GetSystemTimeZones().Each(zone =>
            {
                var time = new SystemTime(new Clock(), new SimpleTimeZoneContext(zone));
                var first = time.LocalTime().Time;
                var second = DateTime.UtcNow.ToLocalTime(zone);

                second.Subtract(first).TotalMilliseconds.ShouldBeLessThan(100);
            });
        }
Пример #2
0
        public void stub()
        {
            var now = DateTime.Today.AddDays(1).AddHours(8);

            var clock = new Clock();
            var systemTime = new SystemTime(clock, new MachineTimeZoneContext());
            clock.LocalNow(now);

            systemTime.LocalTime().Time.ShouldEqual(now);
            systemTime.LocalTime().TimeOfDay.ShouldEqual(800.ToTime());
            systemTime.LocalTime().Date.Day.ShouldEqual(DateTime.Today.AddDays(1));
        }
Пример #3
0
        public void Start(EngineMode mode, Project project, MarshalByRefObject remoteListener)
        {
            Project.CurrentProject = project;

            EventAggregator.Start((IRemoteListener) remoteListener);

            _project = project;

            Type systemType = null;

            try
            {
                systemType = _project.DetermineSystemType();
                _system = Activator.CreateInstance(systemType).As<ISystem>();
                _services.Add(_system);

                var timeZone = new MachineTimeZoneContext();
                var clock = new Clock();
                var systemTime = new SystemTime(clock, timeZone);
                _specExpiration = new SpecExpiration(systemTime);

                if (mode == EngineMode.Interactive)
                {
                    _engine = buildUserInterfaceEngine();
                }
                else
                {
                    _engine = buildBatchedEngine(project.TracingStyle);
                }

                _engine.Start(project.StopConditions);

            }
            catch (Exception e)
            {
                var message = new SystemRecycled
                {
                    error = e.ToString(),
                    success = false,
                };

                if (systemType != null)
                {
                    message.system_name = systemType.AssemblyQualifiedName;
                }

                EventAggregator.SendMessage(message);
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.DomainUnload += CurrentDomainOnDomainUnload;
        }
Пример #4
0
        public void stub_then_back_to_live()
        {
            var now = DateTime.Today.AddDays(1).AddHours(8);

            var clock = new Clock();
            var systemTime = new SystemTime(clock, new MachineTimeZoneContext());
            clock.LocalNow(now);

            systemTime.LocalTime().Time.ShouldEqual(now);

            clock.Live();

            var firstNow = SystemTime.Default().LocalTime().Time;
            var secondNow = DateTime.Now;

            secondNow.Subtract(firstNow).TotalSeconds.ShouldBeLessThan(1);
        }
 public void SetUp()
 {
     systemTime = SystemTime.AtLocalTime("0800".ToTime());
     theCondition = new ConditionTimeFrame(systemTime);
 }