1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-08-16 23:31:47 +02:00
Files
.github
CommunityToolkit.Common
CommunityToolkit.Diagnostics
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm
CommunityToolkit.Mvvm.SourceGenerators
build
tests
CommunityToolkit.Common.UnitTests
CommunityToolkit.Diagnostics.UnitTests
CommunityToolkit.HighPerformance.UnitTests
Buffers
Enumerables
Extensions
Test_ArrayExtensions.1D.cs
Test_ArrayExtensions.2D.cs
Test_ArrayExtensions.3D.cs
Test_ArrayPoolExtensions.cs
Test_BoolExtensions.cs
Test_HashCodeExtensions.cs
Test_IBufferWriterExtensions.cs
Test_IMemoryOwnerExtensions.cs
Test_MemoryExtensions.cs
Test_NullableExtensions.cs
Test_ReadOnlyMemoryExtensions.cs
Test_ReadOnlySpanExtensions.Count.cs
Test_ReadOnlySpanExtensions.cs
Test_SpanExtensions.cs
Test_SpinLockExtensions.cs
Test_StreamExtensions.cs
Test_StringExtensions.cs
Helpers
Memory
Streams
CommunityToolkit.HighPerformance.UnitTests.csproj
Test_Box{T}.cs
Test_NullableReadOnlyRef{T}.cs
Test_NullableRef{T}.cs
Test_ReadOnlyRef{T}.cs
Test_Ref{T}.cs
CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests
CommunityToolkit.Mvvm.ExternalAssembly
CommunityToolkit.Mvvm.Internals.UnitTests
CommunityToolkit.Mvvm.SourceGenerators.UnitTests
CommunityToolkit.Mvvm.UnitTests
.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
2021-11-04 21:48:54 +01:00

45 lines
1.5 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;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CommunityToolkit.HighPerformance.UnitTests.Extensions;
[TestClass]
public class Test_BoolExtensions
{
[TestMethod]
public void Test_BoolExtensions_True()
{
// There tests all just run a couple of boolean expressions and validate that the extension
// correctly produces either 1 or 0 depending on whether the expression was true or false.
Assert.AreEqual(1, true.ToByte(), nameof(Test_BoolExtensions_True));
Assert.AreEqual(1, (DateTime.Now.Year > 0).ToByte(), nameof(Test_BoolExtensions_True));
}
[TestMethod]
public void Test_BoolExtensions_False()
{
Assert.AreEqual(0, false.ToByte(), nameof(Test_BoolExtensions_False));
Assert.AreEqual(0, (DateTime.Now.Year > 3000).ToByte(), nameof(Test_BoolExtensions_False));
}
[TestMethod]
[DataRow(true, -1)]
[DataRow(false, 0)]
public void Test_BoolExtensions_ToBitwiseMask32(bool value, int result)
{
Assert.AreEqual(value.ToBitwiseMask32(), result);
}
[TestMethod]
[DataRow(true, -1)]
[DataRow(false, 0)]
public void Test_BoolExtensions_ToBitwiseMask64(bool value, long result)
{
Assert.AreEqual(value.ToBitwiseMask64(), result);
}
}