Skip to content
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

Open
wants to merge 13 commits into
base: release/0.5.0
Choose a base branch
from

Conversation

Timmoth
Copy link

@Timmoth Timmoth commented Apr 10, 2022

  • 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

@Timmoth Timmoth changed the title Added test project & github workflow to run tests Added test project & github action to run tests Apr 10, 2022


[Fact]
public void ReducerUpdatesStateWhenInvoked()
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Source/Morris.Reducible/Reducer.ConditionBuilder.cs Outdated Show resolved Hide resolved
Func<TSubState, TDelta, Result<TSubState>> reducer)
=>
new ObjectResultMapper<TState, TSubState, TDelta>(subStateSelector, reducer);
Func<TState, TSubState> subStateSelector, Func<TSubState, TDelta, Result<TSubState>> reducer) =>
Copy link
Owner

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.

Copy link
Author

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) =>
Copy link
Owner

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.

Copy link
Author

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);
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@@ -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)
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted

Source/Morris.Reducible/Reducer.cs Outdated Show resolved Hide resolved
.github/workflows/test.yml Show resolved Hide resolved
@mrpmorris mrpmorris changed the base branch from master to release/0.5.0 October 20, 2022 12:58
@mrpmorris
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants