Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 7b32561

Browse files
committed
Creating AsyncValueCommand using CreateValue
1 parent 7c82bc8 commit 7b32561

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_AsyncValueCommand_Tests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Xamarin.CommunityToolkit.UnitTests.ObjectModel.ICommandTests.CommandFa
99
{
1010
public class CommandFactoryAsyncValueCommandTests : BaseAsyncValueCommandTests
1111
{
12-
1312
[Fact]
1413
public void NullExecuteParameter()
1514
{
@@ -19,14 +18,14 @@ public void NullExecuteParameter()
1918
// Act
2019

2120
// Assert
22-
Assert.Throws<ArgumentNullException>(() => CommandFactory.Create(execute));
21+
Assert.Throws<ArgumentNullException>(() => CommandFactory.CreateValue(execute));
2322
}
2423

2524
[Fact]
2625
public void NullCanExecuteParameter()
2726
{
2827
// Arrange
29-
var command = CommandFactory.Create(NoParameterTask, null);
28+
var command = CommandFactory.CreateValue(NoParameterTask, null);
3029

3130
// Act
3231

@@ -40,7 +39,7 @@ public void NullCanExecuteParameter()
4039
public void IntExecuteNullCanExecuteParameter()
4140
{
4241
// Arrange
43-
var command = CommandFactory.Create<int>(IntParameterTask, null);
42+
var command = CommandFactory.CreateValue<int>(IntParameterTask, null);
4443

4544
// Act
4645

@@ -58,7 +57,7 @@ public void IntExecuteNullCanExecuteParameter()
5857
public void IntExecuteTrueCanExecuteParameter()
5958
{
6059
// Arrange
61-
var command = CommandFactory.Create<int>(IntParameterTask, CanExecuteTrue);
60+
var command = CommandFactory.CreateValue<int>(IntParameterTask, CanExecuteTrue);
6261

6362
// Act
6463

@@ -72,7 +71,7 @@ public void IntExecuteTrueCanExecuteParameter()
7271
public void IntExecuteFalseCanExecuteParameter()
7372
{
7473
// Arrange
75-
var command = CommandFactory.Create<int>(IntParameterTask, CanExecuteFalse);
74+
var command = CommandFactory.CreateValue<int>(IntParameterTask, CanExecuteFalse);
7675

7776
// Act
7877

@@ -86,7 +85,7 @@ public void IntExecuteFalseCanExecuteParameter()
8685
public void IntExecuteNullTypedCanExecuteParameter()
8786
{
8887
// Arrange
89-
var command = CommandFactory.Create<int, bool>(IntParameterTask, null);
88+
var command = CommandFactory.CreateValue<int, bool>(IntParameterTask, null);
9089

9190
// Act
9291

@@ -101,7 +100,7 @@ public void IntExecuteNullTypedCanExecuteParameter()
101100
public void IntExecuteBoolCanExecuteParameter()
102101
{
103102
// Arrange
104-
var command = CommandFactory.Create<int, bool>(IntParameterTask, CanExecuteTrue);
103+
var command = CommandFactory.CreateValue<int, bool>(IntParameterTask, CanExecuteTrue);
105104

106105
// Act
107106

src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ICommandTests/CommandFactoryTests/CommandFactory_Command_Tests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Threading.Tasks;
32
using Xamarin.CommunityToolkit.Exceptions;
43
using Xamarin.CommunityToolkit.ObjectModel;
54
using Xunit;

src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/CommandFactory.shared.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ public static IAsyncCommand<TExecute, TCanExecute> Create<TExecute, TCanExecute>
4141
bool allowsMultipleExecutions = true) =>
4242
new AsyncCommand<TExecute, TCanExecute>(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);
4343

44-
public static IAsyncValueCommand Create(
44+
public static IAsyncValueCommand CreateValue(
4545
Func<ValueTask> execute,
4646
Func<bool> canExecute = null,
4747
Action<Exception> onException = null,
4848
bool continueOnCapturedContext = false,
4949
bool allowsMultipleExecutions = true) =>
5050
new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);
5151

52-
public static IAsyncValueCommand<TExecute> Create<TExecute>(
52+
public static IAsyncValueCommand<TExecute> CreateValue<TExecute>(
5353
Func<TExecute, ValueTask> execute,
5454
Func<bool> canExecute = null,
5555
Action<Exception> onException = null,
5656
bool continueOnCapturedContext = false,
5757
bool allowsMultipleExecutions = true) =>
5858
new AsyncValueCommand<TExecute>(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);
5959

60-
public static IAsyncValueCommand<TExecute, TCanExecute> Create<TExecute, TCanExecute>(
60+
public static IAsyncValueCommand<TExecute, TCanExecute> CreateValue<TExecute, TCanExecute>(
6161
Func<TExecute, ValueTask> execute,
6262
Func<TCanExecute, bool> canExecute = null,
6363
Action<Exception> onException = null,

0 commit comments

Comments
 (0)