-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added test project & github action to run tests #1
base: release/0.5.0
Are you sure you want to change the base?
Conversation
Timmoth
commented
Apr 10, 2022
•
edited
Loading
edited
- Tiny refactor in Recuder.cs to Reducer.Combine - made the loop a little more readable
- Created Test project
- Added Simple & Conditional reducer tests
- Created github action to automate the tests
- Improved readability by using target-typed new
|
||
|
||
[Fact] | ||
public void ReducerUpdatesStateWhenInvoked() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking into account the filename is the Given, I like my test methods to be named WhenXxxxx_ThenYyyyyy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Func<TSubState, TDelta, Result<TSubState>> reducer) | ||
=> | ||
new ObjectResultMapper<TState, TSubState, TDelta>(subStateSelector, reducer); | ||
Func<TState, TSubState> subStateSelector, Func<TSubState, TDelta, Result<TSubState>> reducer) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer all of the original code in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
Func<TElement, TDelta, Result<TElement>> reducer) | ||
=> | ||
new ImmutableArrayResultMapper<TState, TElement, TDelta>(subStateSelector, reducer); | ||
Func<TState, ImmutableArray<TElement>> subStateSelector, Func<TElement, TDelta, Result<TElement>> reducer) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the original code here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
@@ -5,6 +5,6 @@ public static partial class Reducer | |||
public record struct Result<TState>(bool Changed, TState State) | |||
{ | |||
public static implicit operator (bool changed, TState state)(Result<TState> result) => (result.Changed, result.State); | |||
public static implicit operator Result<TState>((bool changed, TState value) value) => new Result<TState>(value.changed, value.value); | |||
public static implicit operator Result<TState>((bool changed, TState value) value) => new(value.changed, value.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay, but could you also change the parameter names to TState state
and the param itself to tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Source/Morris.Reducible/Reducer.cs
Outdated
@@ -23,10 +23,9 @@ public static partial class Reducer | |||
return (state, delta) => | |||
{ | |||
bool anyChanged = false; | |||
for (int o = 0; o < allReducers.Length; o++) | |||
foreach (var reducer in allReducers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a for loop is faster than a foreach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
I've tried to rebase this off release/0.5.0 but there are conflicts. Would you like to resolve them so I can merge in your changes? |