mirror of
https://github.com/chylex/.NET-Community-Toolkit.git
synced 2025-08-16 23:31:47 +02:00
.github
CommunityToolkit.Common
CommunityToolkit.Diagnostics
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm
CommunityToolkit.Mvvm.SourceGenerators
build
tests
CommunityToolkit.Common.UnitTests
CommunityToolkit.Diagnostics.UnitTests
CommunityToolkit.HighPerformance.UnitTests
CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests
CommunityToolkit.Mvvm.ExternalAssembly
CommunityToolkit.Mvvm.Internals.UnitTests
CommunityToolkit.Mvvm.SourceGenerators.UnitTests
CommunityToolkit.Mvvm.UnitTests
Collections
Helpers
CommunityToolkit.Mvvm.UnitTests.csproj
Test_ArgumentNullException.ComponentModel.cs
Test_ArgumentNullException.DependencyInjection.cs
Test_ArgumentNullException.Input.cs
Test_ArgumentNullException.Messaging.cs
Test_AsyncRelayCommand.cs
Test_AsyncRelayCommand{T}.cs
Test_INotifyPropertyChangedAttribute.cs
Test_IRecipientGenerator.cs
Test_Messenger.Request.cs
Test_Messenger.cs
Test_ObservableObject.cs
Test_ObservableObjectAttribute.cs
Test_ObservablePropertyAttribute.RootNamespace.cs
Test_ObservablePropertyAttribute.cs
Test_ObservableRecipient.cs
Test_ObservableRecipientAttribute.cs
Test_ObservableValidator.cs
Test_RelayCommand.cs
Test_RelayCommandAttribute.cs
Test_RelayCommand{T}.cs
Test_SourceGenerators.cs
.editorconfig
.git-blame-ignore-revs
.gitattributes
.gitignore
.runsettings
CODE_OF_CONDUCT.md
Contributing.md
Directory.Build.props
Directory.Build.targets
License.md
README.md
ThirdPartyNotices.txt
azure-pipelines.yml
dotnet Community Toolkit.sln
toolkit.snk
version.json
63 lines
4.1 KiB
C#
63 lines
4.1 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Threading.Tasks;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace CommunityToolkit.Mvvm.UnitTests;
|
|
|
|
public partial class Test_ArgumentNullException
|
|
{
|
|
[TestMethod]
|
|
public void Test_ArgumentNullException_RelayCommand()
|
|
{
|
|
Assert(() => new RelayCommand(execute: null!), "execute");
|
|
Assert(() => new RelayCommand(execute: null!, () => true), "execute");
|
|
Assert(() => new RelayCommand(() => { }, canExecute: null!), "canExecute");
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Test_ArgumentNullException_RelayCommandOfT()
|
|
{
|
|
Assert(() => new RelayCommand<string>(execute: null!), "execute");
|
|
Assert(() => new RelayCommand<string>(execute: null!, s => true), "execute");
|
|
Assert(() => new RelayCommand<string>(s => { }, canExecute: null!), "canExecute");
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Test_ArgumentNullException_AsyncRelayCommand()
|
|
{
|
|
Assert(() => new AsyncRelayCommand(execute: null!), "execute");
|
|
Assert(() => new AsyncRelayCommand(execute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "execute");
|
|
Assert(() => new AsyncRelayCommand(cancelableExecute: null!), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand(cancelableExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand(execute: null!, () => true), "execute");
|
|
Assert(() => new AsyncRelayCommand(() => Task.CompletedTask, canExecute: null!), "canExecute");
|
|
Assert(() => new AsyncRelayCommand(execute: null!, () => true, AsyncRelayCommandOptions.AllowConcurrentExecutions), "execute");
|
|
Assert(() => new AsyncRelayCommand(() => Task.CompletedTask, canExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "canExecute");
|
|
Assert(() => new AsyncRelayCommand(cancelableExecute: null!, () => true), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand(t => Task.CompletedTask, canExecute: null!), "canExecute");
|
|
Assert(() => new AsyncRelayCommand(cancelableExecute: null!, () => true, AsyncRelayCommandOptions.AllowConcurrentExecutions), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand(t => Task.CompletedTask, canExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "canExecute");
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Test_ArgumentNullException_AsyncRelayCommandOfT()
|
|
{
|
|
Assert(() => new AsyncRelayCommand<string>(execute: null!), "execute");
|
|
Assert(() => new AsyncRelayCommand<string>(execute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "execute");
|
|
Assert(() => new AsyncRelayCommand<string>(cancelableExecute: null!), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(cancelableExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(execute: null!, s => true), "execute");
|
|
Assert(() => new AsyncRelayCommand<string>(s => Task.CompletedTask, canExecute: null!), "canExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(execute: null!, s => true, AsyncRelayCommandOptions.AllowConcurrentExecutions), "execute");
|
|
Assert(() => new AsyncRelayCommand<string>(s => Task.CompletedTask, canExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "canExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(cancelableExecute: null!, s => true), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(t => Task.CompletedTask, canExecute: null!), "canExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(cancelableExecute: null!, s => true, AsyncRelayCommandOptions.AllowConcurrentExecutions), "cancelableExecute");
|
|
Assert(() => new AsyncRelayCommand<string>(t => Task.CompletedTask, canExecute: null!, AsyncRelayCommandOptions.AllowConcurrentExecutions), "canExecute");
|
|
}
|
|
}
|