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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public TraineeAdapter(Listener listener, Level level) { this.listener = listener; this.level = level; }
private double Evaluate(Level level) { return Math.Pow(effort.Normalized() - level.Effort(circuit).Normalized(), 2) + Math.Pow(duration.Normalized() - level.TotalDuration(circuit).Normalized(), 2); }
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())); }
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; }
public Session(Circuit circuit, Level level) { this.circuit = circuit; this.level = level; }