示例#1
0
        public void Init()
        {
            // With substitute.for we create a mock for the IRobotActuator interface.
            _robotActuator = Substitute.For <IRobotActuator>();

            // Because we cannot use time inside unit tests, we need to mock the timer class also
            _timer = Substitute.For <ITimer>();

            // Then we can pass this mock to the robotbattery so that it is not depended on the robotactuator and the timer itself.
            _robotBattery = new RobotBattery(_robotActuator, _timer);
        }
示例#2
0
 public RobotBattery(IRobotActuator robotActuator, ITimer timer)
 {
     _robotActuator = robotActuator;
     BatteryDepletedTimeoutTimer = timer;
 }