Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
 }
Exemple #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));
 }
Exemple #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));
 }
Exemple #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));
 }
Exemple #7
0
 public TraineeAdapter(Listener listener, Level level)
 {
     this.listener = listener;
     this.level = level;
 }
Exemple #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);
 }
Exemple #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()));
 }
Exemple #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;
 }
Exemple #11
0
 public Session(Circuit circuit, Level level)
 {
     this.circuit = circuit;
     this.level = level;
 }