Skip to content

Commit

Permalink
Merge pull request #192 from benprime/tap_result_funcs
Browse files Browse the repository at this point in the history
TapIf overloads for handling result-returning funcs
  • Loading branch information
vkhorikov authored Mar 29, 2020
2 parents 2bc4a96 + b6419f3 commit 5690693
Show file tree
Hide file tree
Showing 9 changed files with 572 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,51 @@ public void TapIf_T_E_AsyncBoth_executes_action_T_conditionally_and_returns_self
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_T_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(condition, Task_Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_K_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(condition, Task_Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_K_E_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.AsTask().TapIf(condition, Task_Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
Expand Down Expand Up @@ -143,5 +188,50 @@ public void TapIf_T_E_AsyncBoth_executes_action_T_per_predicate_and_returns_self
actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_T_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(Predicate, Task_Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_K_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(Predicate, Task_Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncBoth_executes_func_result_K_E_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.AsTask().TapIf(Predicate, Task_Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,51 @@ public void TapIf_T_E_AsyncLeft_executes_action_T_conditionally_and_returns_self
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_T_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(condition, Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_K_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(condition, Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_K_E_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.AsTask().TapIf(condition, Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
Expand Down Expand Up @@ -143,5 +188,50 @@ public void TapIf_T_E_AsyncLeft_executes_action_T_per_predicate_and_returns_self
actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_T_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(Predicate, Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_K_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.AsTask().TapIf(Predicate, Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncLeft_executes_func_result_K_E_per_predicate_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.AsTask().TapIf(Predicate, Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,51 @@ public void Tap_T_E_AsyncRight_executes_action_T_conditionally_and_returns_self(
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_T_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.TapIf(condition, Task_Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_K_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.TapIf(condition, Task_Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_K_E_conditionally_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.TapIf(condition, Task_Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
Expand Down Expand Up @@ -143,5 +188,50 @@ public void Tap_T_E_AsyncRight_executes_action_T_per_func_condition_and_returns_
actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_T_per_func_condition_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.TapIf(Predicate, Task_Func_Result).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_K_per_func_condition_and_returns_self(bool isSuccess, bool condition)
{
Result<bool> result = Result.SuccessIf(isSuccess, condition, ErrorMessage);

var returned = result.TapIf(Predicate, Task_Func_Result_K).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}

[Theory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void TapIf_T_AsyncRight_executes_func_result_K_E_per_func_condition_and_returns_self(bool isSuccess, bool condition)
{
Result<bool, E> result = Result.SuccessIf(isSuccess, condition, E.Value);

var returned = result.TapIf(Predicate, Task_Func_Result_K_E).Result;

actionExecuted.Should().Be(isSuccess && condition);
result.Should().Be(returned);
}
}
}
Loading

0 comments on commit 5690693

Please sign in to comment.