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

Commit

Permalink
Creating AsyncValueCommand using CreateValue
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkoshevoi committed Jan 26, 2021
1 parent 7c82bc8 commit 7b32561
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Xamarin.CommunityToolkit.UnitTests.ObjectModel.ICommandTests.CommandFa
{
public class CommandFactoryAsyncValueCommandTests : BaseAsyncValueCommandTests
{

[Fact]
public void NullExecuteParameter()
{
Expand All @@ -19,14 +18,14 @@ public void NullExecuteParameter()
// Act

// Assert
Assert.Throws<ArgumentNullException>(() => CommandFactory.Create(execute));
Assert.Throws<ArgumentNullException>(() => CommandFactory.CreateValue(execute));
}

[Fact]
public void NullCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create(NoParameterTask, null);
var command = CommandFactory.CreateValue(NoParameterTask, null);

// Act

Expand All @@ -40,7 +39,7 @@ public void NullCanExecuteParameter()
public void IntExecuteNullCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create<int>(IntParameterTask, null);
var command = CommandFactory.CreateValue<int>(IntParameterTask, null);

// Act

Expand All @@ -58,7 +57,7 @@ public void IntExecuteNullCanExecuteParameter()
public void IntExecuteTrueCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create<int>(IntParameterTask, CanExecuteTrue);
var command = CommandFactory.CreateValue<int>(IntParameterTask, CanExecuteTrue);

// Act

Expand All @@ -72,7 +71,7 @@ public void IntExecuteTrueCanExecuteParameter()
public void IntExecuteFalseCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create<int>(IntParameterTask, CanExecuteFalse);
var command = CommandFactory.CreateValue<int>(IntParameterTask, CanExecuteFalse);

// Act

Expand All @@ -86,7 +85,7 @@ public void IntExecuteFalseCanExecuteParameter()
public void IntExecuteNullTypedCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create<int, bool>(IntParameterTask, null);
var command = CommandFactory.CreateValue<int, bool>(IntParameterTask, null);

// Act

Expand All @@ -101,7 +100,7 @@ public void IntExecuteNullTypedCanExecuteParameter()
public void IntExecuteBoolCanExecuteParameter()
{
// Arrange
var command = CommandFactory.Create<int, bool>(IntParameterTask, CanExecuteTrue);
var command = CommandFactory.CreateValue<int, bool>(IntParameterTask, CanExecuteTrue);

// Act

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using Xamarin.CommunityToolkit.Exceptions;
using Xamarin.CommunityToolkit.ObjectModel;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ public static class CommandFactory
bool allowsMultipleExecutions = true) =>
new AsyncCommand<TExecute, TCanExecute>(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);

public static IAsyncValueCommand Create(
public static IAsyncValueCommand CreateValue(
Func<ValueTask> execute,
Func<bool> canExecute = null,
Action<Exception> onException = null,
bool continueOnCapturedContext = false,
bool allowsMultipleExecutions = true) =>
new AsyncValueCommand(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);

public static IAsyncValueCommand<TExecute> Create<TExecute>(
public static IAsyncValueCommand<TExecute> CreateValue<TExecute>(
Func<TExecute, ValueTask> execute,
Func<bool> canExecute = null,
Action<Exception> onException = null,
bool continueOnCapturedContext = false,
bool allowsMultipleExecutions = true) =>
new AsyncValueCommand<TExecute>(execute, canExecute, onException, continueOnCapturedContext, allowsMultipleExecutions);

public static IAsyncValueCommand<TExecute, TCanExecute> Create<TExecute, TCanExecute>(
public static IAsyncValueCommand<TExecute, TCanExecute> CreateValue<TExecute, TCanExecute>(
Func<TExecute, ValueTask> execute,
Func<TCanExecute, bool> canExecute = null,
Action<Exception> onException = null,
Expand Down

0 comments on commit 7b32561

Please sign in to comment.