-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests that ensure supersets behave in an intended manner
- Loading branch information
1 parent
3999099
commit 4e4bdab
Showing
7 changed files
with
222 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
global using System.Collections.Immutable; | ||
global using FluentAssertions; | ||
global using NSubstitute; | ||
global using NUnit.Framework; | ||
global using Oatmilk; | ||
global using Oatmilk.Nunit; | ||
global using static Oatmilk.TestBuilder; | ||
global using Oatmilk.Xunit; | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
tests/LiftLog.Tests.App/SessionBehaviors/SessionSuperset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
using LiftLog.Lib.Models; | ||
using LiftLog.Ui.Store.CurrentSession; | ||
|
||
namespace LiftLog.Tests.App.SessionBehaviors; | ||
|
||
public class SessionSupersetTests | ||
{ | ||
[Describe("Session supersets")] | ||
public void Spec() | ||
{ | ||
Describe( | ||
"When given a session with supersets", | ||
() => | ||
{ | ||
Session session = null!; | ||
CurrentSessionState GetState() => CurrentSessionState.FromWorkoutSession(session); | ||
Session CycleExerciseReps(int exerciseIndex, int setIndex) => | ||
CurrentSessionReducers | ||
.CycleExerciseReps( | ||
GetState(), | ||
new CycleExerciseRepsAction( | ||
SessionTarget.WorkoutSession, | ||
ExerciseIndex: exerciseIndex, | ||
SetIndex: setIndex | ||
) | ||
) | ||
.WorkoutSession!; | ||
ExerciseBlueprint Exercise(int index, bool supersetWithNext) => | ||
Blueprints.CreateExerciseBlueprint(x => | ||
x with | ||
{ | ||
Name = $"Ex{index}", | ||
SupersetWithNext = supersetWithNext | ||
} | ||
); | ||
BeforeEach( | ||
() => | ||
session = Sessions.CreateSession( | ||
sessionBlueprint: Blueprints.CreateSessionBlueprint() with | ||
{ | ||
Exercises = | ||
[ | ||
Exercise(0, supersetWithNext: false), | ||
Exercise(1, supersetWithNext: true), | ||
Exercise(2, supersetWithNext: false), | ||
Exercise(3, supersetWithNext: true), | ||
Exercise(4, supersetWithNext: true), | ||
Exercise(5, supersetWithNext: false) | ||
] | ||
}, | ||
fillFirstSet: false | ||
) | ||
); | ||
It("should have the first exercise and set as the next exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise.Blueprint.Name.Should().Be(session.RecordedExercises[0].Blueprint.Name); | ||
Check warning on line 62 in tests/LiftLog.Tests.App/SessionBehaviors/SessionSuperset.cs GitHub Actions / test
|
||
}); | ||
Describe("and the last completed set was the first exercise (not a superset)") | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(0, 0); | ||
}); | ||
It( | ||
"Should have the next set be the first exercise", | ||
() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
Check warning on line 79 in tests/LiftLog.Tests.App/SessionBehaviors/SessionSuperset.cs GitHub Actions / test
|
||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[0].Blueprint.Name); | ||
} | ||
); | ||
}); | ||
Describe( | ||
"and the last completed set was the second exercise (a superset with the third exercise)" | ||
) | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(1, 0); | ||
}); | ||
It("Should have the next set be the third exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
Check warning on line 101 in tests/LiftLog.Tests.App/SessionBehaviors/SessionSuperset.cs GitHub Actions / test
|
||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[2].Blueprint.Name); | ||
}); | ||
}); | ||
Describe( | ||
"and the last completed set was the third exercise (a superset with the previous exercise)" | ||
) | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(2, 0); | ||
}); | ||
It("Should have the next set be the second exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[1].Blueprint.Name); | ||
}); | ||
}); | ||
Describe( | ||
"and the last completed set was the fourth exercise (a superset with the fifth and sixth exercise)" | ||
) | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(3, 0); | ||
}); | ||
It("Should have the next set be the fifth exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[4].Blueprint.Name); | ||
}); | ||
}); | ||
Describe( | ||
"and the last completed set was the fifth exercise (a superset with the fourth and sixth exercise)" | ||
) | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(4, 0); | ||
}); | ||
It("Should have the next set be the sixth exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[5].Blueprint.Name); | ||
}); | ||
}); | ||
Describe( | ||
"and the last completed set was the sixth exercise (a superset with the fourth and fifth exercise)" | ||
) | ||
.As(() => | ||
{ | ||
BeforeEach(() => | ||
{ | ||
session = CycleExerciseReps(4, 0); | ||
}); | ||
It("Should have the next set be the fourth exercise") | ||
.When(() => | ||
{ | ||
var nextExercise = session.NextExercise; | ||
nextExercise.Should().NotBeNull(); | ||
nextExercise | ||
.Blueprint.Name.Should() | ||
.Be(session.RecordedExercises[4].Blueprint.Name); | ||
}); | ||
}); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters