Exemplo n.º 1
0
        public void TestBreak()
        {
            const int BREAK_DURATION = 5;

            var uiMock = new Mock<Listener>();
            var level = new Level(2, breakTime: BREAK_DURATION);
            var trainee = new TraineeAdapter(uiMock.Object, level);
            trainee.Break();

            uiMock.Verify(m => m.ShowAction(It.IsAny<string>()), Times.Once());
            uiMock.Verify(m => m.ShowTime(It.IsAny<int>()), Times.Exactly(BREAK_DURATION));
        }
Exemplo n.º 2
0
        public void TestExercise()
        {
            const string BURPEES = "burpees";
            const int DURATION = 5;

            var uiMock = new Mock<Listener>();
            var level = new Level(2, exerciseTime: DURATION);
            var trainee = new TraineeAdapter(uiMock.Object, level);

            trainee.Excercise(BURPEES);

            uiMock.Verify(m => m.ShowAction(It.Is<string>(text => text.Equals(BURPEES))), Times.Once());
            uiMock.Verify(m => m.ShowTime(It.IsAny<int>()), Times.Exactly(DURATION));
        }
Exemplo n.º 3
0
 public void TestTotalTimeWithoutWorking()
 {
     var circuit = sampleCircuit(0, 8, 0);
     var level = new Level(roundCount:1, breakTime: 10, switchTime: 0, exerciseTime: 0);
     Assert.AreEqual(Duration.fromSeconds(10), level.TotalDuration(circuit));
 }
Exemplo n.º 4
0
 public void TestTotalTime()
 {
     var circuit = sampleCircuit(0, 8, 0);
     var level = new Level(1, breakTime: 0, switchTime: 0, exerciseTime: 30);
     Assert.AreEqual(Duration.fromSeconds(240), level.TotalDuration(circuit));
 }
Exemplo n.º 5
0
 public void TestNoEffort()
 {
     var circuit = sampleCircuit(0, 8,0);
     var level = new Level(1, breakTime: 10, switchTime: 0, exerciseTime: 0);
     Assert.AreEqual(level.Effort(circuit), new Effort(0));
 }
Exemplo n.º 6
0
 public void TestMediumEffort()
 {
     var circuit = sampleCircuit(0, 8, 0);
     var level = new Level(2, breakTime: 20, switchTime: 0, exerciseTime: 10);
     Assert.AreEqual(level.Effort(circuit), Effort.FromRatio((double)160 / 200));
 }
Exemplo n.º 7
0
 public TraineeAdapter(Listener listener, Level level)
 {
     this.listener = listener;
     this.level = level;
 }
Exemplo n.º 8
0
 private double Evaluate(Level level)
 {
     return
         Math.Pow(effort.Normalized() - level.Effort(circuit).Normalized(), 2)
         + Math.Pow(duration.Normalized() - level.TotalDuration(circuit).Normalized(), 2);
 }
Exemplo n.º 9
0
 private void AdjustSchedule()
 {
     var selection = new List<Level>() { candidateLevels[0] };
     var smallestError = Evaluate(candidateLevels[0]);
     foreach (var candidate in candidateLevels)
     {
         var error = Evaluate(candidate);
         if (error < smallestError)
         {
             selection.Clear();
             selection.Add(candidate);
             smallestError = error;
         } else if (error == smallestError) {
             selection.Add(candidate);
         }
     }
     schedule = selection.Find(level => level.RoundCount() == selection.Min(p => p.RoundCount()));
 }
Exemplo n.º 10
0
 public Scheduler(Circuit circuit, Duration duration, Effort effort)
 {
     candidateLevels = new List<Level>();
     BuildCandidates();
     schedule = candidateLevels[0];
     this.circuit = circuit;
     this.duration = duration;
     this.effort = effort;
 }
Exemplo n.º 11
0
 public Session(Circuit circuit, Level level)
 {
     this.circuit = circuit;
     this.level = level;
 }