Beispiel #1
0
        public void SetUp()
        {
            _systemContainer = Substitute.For <ISystemContainer>();

            _entityEngine = Substitute.For <IEntityEngine>();
            _systemContainer.EntityEngine.Returns(_entityEngine);
            _mutableEntities = new List <IEntity>();
            _entityEngine.MutableEntities.Returns(_mutableEntities);

            _mapSystem = Substitute.For <IMapSystem>();
            _systemContainer.MapSystem.Returns(_mapSystem);
            _mapCollection = new Atlas();
            _mapSystem.MapCollection.Returns(_mapCollection);

            _messageSystem = Substitute.For <IMessageSystem>();
            _systemContainer.MessageSystem.Returns(_messageSystem);
            _messages = new List <Message>();
            _messageSystem.AllMessages.Returns(_messages);

            _timeSystem = Substitute.For <ITimeSystem>();
            _systemContainer.TimeSystem.Returns(_timeSystem);
            _currentTime = 0;
            _timeSystem.CurrentTime.Returns(_currentTime);

            _worldGenerator = Substitute.For <IWorldGenerator>();

            _saveSystem = new SaveSystem(_systemContainer, _worldGenerator);
        }
Beispiel #2
0
        public void SwitchAtMidnightFalse()
        {
            ITimeSystem mockTime = NewMock <ITimeSystem>();

            using (Ordered)
            {
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:06")));
            }
            ITimeLogsManager timeLogsManager = NewMock <ITimeLogsManager>();
            ITimeLog         timeLog1        = NewMock <ITimeLog>();

            Expect.Once.On(timeLog1).Method("AddActivity").With(new Activities.Activity("first", DateTime.Parse("2008-08-07 23:59:55"), TimeSpan.Parse("0:00:11")));
            Expect.Once.On(timeLogsManager).Method("ActivateTimeLog").With(DateTime.Parse("2008-08-07"));
            Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(timeLog1));
            timeManager = new TimeManager(mockTime, timeLogsManager);
            var midnightCorrector = NewMock <IMidnightCorrector>();

            timeManager.MidnightCorrector = midnightCorrector;
            Expect.Never.On(midnightCorrector).Method("PerformMidnightCorrection");
            timeManager.SwitchAtMidnight = false;
            timeManager.FinishActivity("first", "second");

            VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #3
0
 public FighterSystem(IEntityEngine engine, IMessageSystem messageSystem, IEventSystem eventRuleSystem, ITimeSystem timeSystem, IStatSystem statSystem)
 {
     _engine          = engine;
     _messageSystem   = messageSystem;
     _eventRuleSystem = eventRuleSystem;
     _timeSystem      = timeSystem;
     _statSystem      = statSystem;
 }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="time">Abstract of the time system used to provide clock and datetime values</param>
        /// <param name="baseTargetBlock">A Dataflow Target (receiver of data but no output)</param>
        public RxTimedActionBlock(
            ITimeSystem time,
            ITargetBlock <T> baseTargetBlock)
        {
            _time = time;
            _base = baseTargetBlock;

            _subject = new Subject <TimedOperation>();
        }
Beispiel #5
0
 public FollowPathBehaviour(ISystemContainer systemContainer)
 {
     _positionSystem  = systemContainer.PositionSystem;
     _eventRuleSystem = systemContainer.EventSystem;
     _playerSystem    = systemContainer.PlayerSystem;
     _mapSystem       = systemContainer.MapSystem;
     _entityEngine    = systemContainer.EntityEngine;
     _messageSystem   = systemContainer.MessageSystem;
     _timeSystem      = systemContainer.TimeSystem;
 }
Beispiel #6
0
 public TimeManager(ITimeSystem timeSystem, ITimeLogsManager timeLogsManager)
 {
     currentActivity   = new RunningActivity(FIRST_ACTIVITY, timeSystem);
     midnightCorrector = new MidnightSwitcher();
     if (timeLogsManager != null)
     {
         TimeLogsManager = timeLogsManager;
         timeLogsManager.ActivateTimeLog(currentActivity.Start.Date);
     }
 }
Beispiel #7
0
        public void SetUp()
        {
            ITimeSystem mockTime = NewMock <ITimeSystem>();

            Stub.On(mockTime).GetProperty("Now").Will(Return.Value(startTime));
            timeLogsManager = NewMock <ITimeLogsManager>();
            timeLog         = NewMock <ITimeLog>();
            Stub.On(timeLogsManager).Method("ActivateTimeLog").Will(Return.Value(timeLog));
            timeManager = new TimeManager(mockTime, timeLogsManager);
        }
Beispiel #8
0
 public TimeManager(ITimeSystem timeSystem, ITimeLogsManager timeLogsManager)
 {
     currentActivity = new RunningActivity(FIRST_ACTIVITY, timeSystem);
     midnightCorrector = new MidnightSwitcher();
     if (timeLogsManager != null)
     {
         TimeLogsManager = timeLogsManager;
         timeLogsManager.ActivateTimeLog(currentActivity.Start.Date);
     }
 }
Beispiel #9
0
        public void FinishActivityUseNowOnce()
        {
            ITimeSystem mockSystem = NewMock <ITimeSystem>();

            Expect.Exactly(2).On(mockSystem).GetProperty("Now").Will(Return.Value(startTime));
            timeManager = new TimeManager(mockSystem);

            timeManager.FinishActivity("activityName", "second");

            VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #10
0
        public void CurrentActivityIsLastingTooLongIsFalseBeforeAnHourOfInactivity()
        {
            ITimeSystem timeSystem = NewMock <ITimeSystem>();

            using (Ordered)
            {
                Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("5:00:00")));
                Expect.AtLeastOnce.On(timeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("5:59:59")));
            }
            timeManager = new TimeManager(timeSystem);
            Assert.IsFalse(timeManager.CurrentActivityIsLastingTooLong);
        }
Beispiel #11
0
        public void SwitchAtMidnightWithoutTimeLogsManager()
        {
            ITimeSystem mockTime = NewMock <ITimeSystem>();

            using (Ordered)
            {
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:06")));
            }
            timeManager = new TimeManager(mockTime);

            timeManager.SwitchTo("second");
        }
Beispiel #12
0
        public void AddRecordToTimeLog()
        {
            ITimeSystem mockSystem = NewMock <ITimeSystem>();

            Expect.Exactly(2).On(mockSystem).GetProperty("Now").Will(Return.Value(startTime));
            ITimeLog mockTimeLog = NewMock <ITimeLog>();

            Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(mockTimeLog));
            timeManager = new TimeManager(mockSystem, timeLogsManager);
            Expect.Once.On(mockTimeLog).Method("AddActivity").With(timeManager.CurrentActivity);

            timeManager.FinishActivity("first", "second");

            VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #13
0
 /// <summary>
 /// Initialize all subsystems
 /// </summary>
 /// <param name="timeSystem"></param>
 /// <param name="settings"></param>
 public Driver(ITimeSystem timeSystem, ISettings settings)
 {
     //when reordering, be carefull, in order to pass only initialized objects
     this.fileManager      = new FileManager(settings);
     this.languageSwitcher = new LanguageSwitcher(settings);
     //probably all of them should be properties, not fields, in order to automatically update referencies
     TaskCollection       = LifeIdea.LazyCure.Core.Tasks.TaskCollection.Default;
     this.timeLogsManager = new TimeLogsManager(this.fileManager);
     HistoryDataProvider  = new HistoryDataProvider(timeLogsManager, TaskCollection);
     this.timeManager     = new TimeManager(timeSystem, TimeLogsManager);
     HistoryDataProvider.CreateSummaries(TimeManager.TimeLog);
     this.workingTime          = new WorkingTimeForDay(TimeManager.TimeLog, TaskCollection);
     this.efficiencyCalculator = new EfficiencyCalculator(workingTime);
     ApplySettings(settings);
 }
Beispiel #14
0
        public void CurrentActivityDuration()
        {
            TimeSpan    duration   = TimeSpan.FromMinutes(15);
            DateTime    endTime    = startTime + duration;
            ITimeSystem timeSystem = NewMock <ITimeSystem>();

            using (Ordered)
            {
                Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(startTime));
                Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(endTime));
            }

            timeManager = new TimeManager(timeSystem);

            Assert.AreEqual(duration, timeManager.CurrentActivity.Duration);
        }
Beispiel #15
0
        public void SplitByCommaAtMidnight()
        {
            ITimeSystem mockTime = NewMock <ITimeSystem>();

            using (Ordered)
            {
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:15")));
            }
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(timeLog));
            using (Ordered)
            {
                Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("first", DateTime.Parse("2008-08-07 23:59:55"), TimeSpan.Parse("0:00:05")));
                Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("first", DateTime.Parse("2008-08-08 0:00:00"), TimeSpan.Parse("0:00:05")));
                Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("second", DateTime.Parse("2008-08-08 0:00:05"), TimeSpan.Parse("0:00:10")));
            }
            timeManager = new TimeManager(mockTime, timeLogsManager);
            timeManager.SwitchAtMidnight = true;
            timeManager.SplitByComma     = true;
            timeManager.FinishActivity("first,second", "next");
            VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #16
0
 public Interpreter(ITimeSystem timeSystem)
 {
     Load();
     this.timeSystem = timeSystem;
     currentActivity = new RunningActivity("", timeSystem);
 }
 public RunningActivity(string name, ITimeSystem timeSystem)
 {
     Name = name;
     this.timeSystem = timeSystem;
     this.start = timeSystem.Now;
 }
 private RunningActivity(string name, RunningActivity previous)
 {
     Name = name;
     this.timeSystem = previous.timeSystem;
     this.start = previous.start + previous.duration;
 }
Beispiel #19
0
 public Interpreter(ITimeSystem timeSystem)
 {
     Load();
     this.timeSystem = timeSystem;
     currentActivity = new RunningActivity("", timeSystem);
 }
 public RunningActivity(string name, ITimeSystem timeSystem)
 {
     Name            = name;
     this.timeSystem = timeSystem;
     this.start      = timeSystem.Now;
 }
Beispiel #21
0
 /// <summary>
 /// Create a new TimedFunc object that adds timing data to the function.
 /// </summary>
 /// <param name="time">The source for the timing mechanism.</param>
 /// <param name="func">A function that will be timed.</param>
 public TimedFunc(ITimeSystem time, Func <TInput, T> func)
 {
     _time = time;
     Func  = func;
 }
Beispiel #22
0
 public void SetUp()
 {
     mockTimeSystem = mocks.NewMock <ITimeSystem>();
 }
Beispiel #23
0
 /// <summary>
 /// Create a new TimedFunc object that adds timing data to the function.
 /// </summary>
 /// <param name="time">The source for the timing mechanism.</param>
 public TimedAction(ITimeSystem time, Action action)
 {
     _time  = time;
     Action = action;
 }
 public void SetUp()
 {
     System.IO.File.Delete(FileManager.FILENAME);
     timeSystem = NewMock<ITimeSystem>();
 }
 private RunningActivity(string name, RunningActivity previous)
 {
     Name            = name;
     this.timeSystem = previous.timeSystem;
     this.start      = previous.start + previous.duration;
 }
Beispiel #26
0
 public TimeManager(ITimeSystem timeSystem)
     : this(timeSystem, null)
 {
 }
Beispiel #27
0
 public TimeManager(ITimeSystem timeSystem) : this(timeSystem, null)
 {
 }
Beispiel #28
0
 public void SetUp()
 {
     System.IO.File.Delete(FileManager.FILENAME);
     timeSystem = NewMock <ITimeSystem>();
 }
 public void SetUp()
 {
     mockTimeSystem = mocks.NewMock<ITimeSystem>();
 }