diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 77e9565..1e2bba9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,9 +1,6 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net +name: Samples.CI -name: .NET - -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: @@ -15,7 +12,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 10.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.gitignore b/.gitignore index 8588efb..0fbfbf4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,431 @@ tools !tools/packages.config .vs .dotnet +# Created by https://www.toptal.com/developers/gitignore/api/visualstudio +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/visualstudio +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode diff --git a/DataDrivenTests/DataDrivenTests.csproj b/DataDrivenTests/DataDrivenTests.csproj index 29831dc..6e74f49 100644 --- a/DataDrivenTests/DataDrivenTests.csproj +++ b/DataDrivenTests/DataDrivenTests.csproj @@ -1,13 +1,19 @@ - + - net6.0 + net10.0 Copyright ©NUnit 2018 - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..58da347 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,12 @@ + + + true + + + + + + + + + \ No newline at end of file diff --git a/ExpectedExceptionExample/ExpectedExceptionExample.csproj b/ExpectedExceptionExample/ExpectedExceptionExample.csproj index ab83e14..6e74f49 100644 --- a/ExpectedExceptionExample/ExpectedExceptionExample.csproj +++ b/ExpectedExceptionExample/ExpectedExceptionExample.csproj @@ -1,13 +1,19 @@ - + - net6.0 + net10.0 Copyright ©NUnit 2018 - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + \ No newline at end of file diff --git a/Samples.sln b/Samples.sln deleted file mode 100644 index 872d045..0000000 --- a/Samples.sln +++ /dev/null @@ -1,53 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33627.172 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Money", "money\Money.csproj", "{11EDF872-A04D-4F75-A1BF-71168DC86AF3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpectedExceptionExample", "ExpectedExceptionExample\ExpectedExceptionExample.csproj", "{A6E1D464-9AAF-4CA9-A818-819739132281}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssertSyntax", "syntax\AssertSyntax.csproj", "{06F46FA2-687B-4B46-A912-C1B0B4CC1B20}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{51996B31-851B-463C-8B57-A7E51CA034EC}" - ProjectSection(SolutionItems) = preProject - .gitattributes = .gitattributes - .gitignore = .gitignore - BUILDING.md = BUILDING.md - LICENSE.txt = LICENSE.txt - nuget.config = nuget.config - README.md = README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataDrivenTests", "DataDrivenTests\DataDrivenTests.csproj", "{FBBC6F15-E718-4080-832C-9D1F4B7A352A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Release|Any CPU.Build.0 = Release|Any CPU - {A6E1D464-9AAF-4CA9-A818-819739132281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6E1D464-9AAF-4CA9-A818-819739132281}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6E1D464-9AAF-4CA9-A818-819739132281}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6E1D464-9AAF-4CA9-A818-819739132281}.Release|Any CPU.Build.0 = Release|Any CPU - {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Release|Any CPU.Build.0 = Release|Any CPU - {FBBC6F15-E718-4080-832C-9D1F4B7A352A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FBBC6F15-E718-4080-832C-9D1F4B7A352A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FBBC6F15-E718-4080-832C-9D1F4B7A352A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FBBC6F15-E718-4080-832C-9D1F4B7A352A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {381F12E7-0FE3-4A81-8427-2BA14C454821} - EndGlobalSection -EndGlobal diff --git a/Samples.slnx b/Samples.slnx new file mode 100644 index 0000000..c16b8f0 --- /dev/null +++ b/Samples.slnx @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/TimeoutRetryAttributeExample/TimeoutRetryAttributeExample.csproj b/TimeoutRetryAttributeExample/TimeoutRetryAttributeExample.csproj index 759718f..ecfdae7 100644 --- a/TimeoutRetryAttributeExample/TimeoutRetryAttributeExample.csproj +++ b/TimeoutRetryAttributeExample/TimeoutRetryAttributeExample.csproj @@ -1,4 +1,4 @@ - + diff --git a/money/Money.csproj b/money/Money.csproj index ab83e14..6e74f49 100644 --- a/money/Money.csproj +++ b/money/Money.csproj @@ -1,13 +1,19 @@ - + - net6.0 + net10.0 Copyright ©NUnit 2018 - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + \ No newline at end of file diff --git a/money/MoneyTest.cs b/money/MoneyTest.cs index 4aee9c8..5a2d594 100755 --- a/money/MoneyTest.cs +++ b/money/MoneyTest.cs @@ -46,7 +46,7 @@ public void BagMultiply() var expected = new MoneyBag(bag); Assert.That(fMB1.Multiply(2), Is.EqualTo(expected)); Assert.That(fMB1.Multiply(1), Is.EqualTo(fMB1)); - ClassicAssert.IsTrue(fMB1.Multiply(0).IsZero); + Assert.IsTrue(fMB1.Multiply(0).IsZero); } /// diff --git a/nuget.config b/nuget.config index 2189696..5fdba97 100644 --- a/nuget.config +++ b/nuget.config @@ -1,8 +1,8 @@ - + - + - + \ No newline at end of file diff --git a/syntax/AssertSyntax.csproj b/syntax/AssertSyntax.csproj index ab83e14..6e74f49 100644 --- a/syntax/AssertSyntax.csproj +++ b/syntax/AssertSyntax.csproj @@ -1,13 +1,19 @@ - + - net6.0 + net10.0 Copyright ©NUnit 2018 - - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + \ No newline at end of file diff --git a/syntax/AssertSyntaxTests.cs b/syntax/AssertSyntaxTests.cs index 11160ca..7ea0277 100755 --- a/syntax/AssertSyntaxTests.cs +++ b/syntax/AssertSyntaxTests.cs @@ -1,9 +1,21 @@ using System.Collections; using NUnit.Framework; -using NUnit.Framework.Legacy; namespace AssertSyntax; +// This file is part of the NUnit framework and is used to test the syntax of assertions in NUnit. +// It contains a series of tests that demonstrate the various ways to use assertions, including both classic and constraint-based syntax. +// The tests cover a wide range of scenarios, including simple constraints, type constraints, string constraints, equality tests, comparison tests, collection tests, property tests, and operator tests. +// Additionally, it includes tests for assumptions and warnings. +// Warnings are suppressed +#pragma warning disable NUnit2007 // The actual value should not be a constant +#pragma warning disable NUnit2049 // Consider using Assert.That(...) instead of CollectionAssert(...) +#pragma warning disable NUnit2009 // The same value has been provided as both the actual and the expected argument +#pragma warning disable CA1825 // Avoid zero-length array allocations +#pragma warning disable NUnit2010 // Use EqualConstraint for better assertion messages in case of failure +#pragma warning disable NUnit2048 // Consider using Assert.That(...) instead of StringAssert.Contains(...) + + /// /// This test fixture attempts to exercise all the syntactic /// variations of Assert without getting into failures, errors @@ -24,15 +36,17 @@ public class AssertSyntaxTests [Test] public void IsNull() { - object nada = null; + object nada = GetObjectAsNull(); // Constraint Syntax Assert.That(nada, Is.Null); // Classic syntax - ClassicAssert.IsNull(nada); + Assert.IsNull(nada); } + private static object GetObjectAsNull() => null; + [Test] public void IsNotNull() { @@ -42,28 +56,34 @@ public void IsNotNull() Assert.That(theAnswer, Is.Not.Null); // Classic syntax - ClassicAssert.IsNotNull(42); + Assert.IsNotNull(42); } [Test] public void IsTrue() { // Constraint Syntax - Assert.That(2 + 2 == 4, Is.True); - Assert.That(2 + 2 == 4); + int result = GetResultAs4(); + Assert.That(result == 4, Is.True); + Assert.That(result == 4); // Classic syntax - ClassicAssert.IsTrue(2 + 2 == 4); + Assert.IsTrue(GetResultAs4() == 4); } + /// + /// Returns 4 + /// + private static int GetResultAs4() => 4; + [Test] public void IsFalse() { // Constraint Syntax - Assert.That(2 + 2 == 5, Is.False); + Assert.That(GetResultAs4() == 5, Is.False); // Classic syntax - ClassicAssert.IsFalse(2 + 2 == 5); + Assert.IsFalse(GetResultAs4() == 5); } [Test] @@ -77,8 +97,8 @@ public void IsNaN() Assert.That(f, Is.NaN); // Classic syntax - ClassicAssert.IsNaN(d); - ClassicAssert.IsNaN(f); + Assert.IsNaN(d); + Assert.IsNaN(f); } [Test] @@ -89,8 +109,8 @@ public void EmptyStringTests() Assert.That("Hello!", Is.Not.Empty); // Classic syntax - ClassicAssert.IsEmpty(""); - ClassicAssert.IsNotEmpty("Hello!"); + Assert.IsEmpty(""); + Assert.IsNotEmpty("Hello!"); } [Test] @@ -101,8 +121,8 @@ public void EmptyCollectionTests() Assert.That(new[] { 1, 2, 3 }, Is.Not.Empty); // Classic syntax - ClassicAssert.IsEmpty(new bool[0]); - ClassicAssert.IsNotEmpty(new[] { 1, 2, 3 }); + Assert.IsEmpty(new bool[0]); + Assert.IsNotEmpty(new[] { 1, 2, 3 }); } #endregion @@ -116,10 +136,10 @@ public void ExactTypeTests() Assert.That("Hello", Is.Not.TypeOf(typeof(int))); // Classic syntax workarounds - ClassicAssert.AreEqual(typeof(string), "Hello".GetType()); - ClassicAssert.AreEqual("System.String", "Hello".GetType().FullName); - ClassicAssert.AreNotEqual(typeof(int), "Hello".GetType()); - ClassicAssert.AreNotEqual("System.Int32", "Hello".GetType().FullName); + Assert.AreEqual(typeof(string), "Hello".GetType()); + Assert.AreEqual("System.String", "Hello".GetType().FullName); + Assert.AreNotEqual(typeof(int), "Hello".GetType()); + Assert.AreNotEqual("System.Int32", "Hello".GetType().FullName); } [Test] @@ -130,8 +150,8 @@ public void InstanceOfTests() Assert.That(5, Is.Not.InstanceOf(typeof(string))); // Classic syntax - ClassicAssert.IsInstanceOf(typeof(string), "Hello"); - ClassicAssert.IsNotInstanceOf(typeof(string), 5); + Assert.IsInstanceOf(typeof(string), "Hello"); + Assert.IsNotInstanceOf(typeof(string), 5); } [Test] @@ -142,8 +162,8 @@ public void AssignableFromTypeTests() Assert.That(5, Is.Not.AssignableFrom(typeof(string))); // Classic syntax - ClassicAssert.IsAssignableFrom(typeof(string), "Hello"); - ClassicAssert.IsNotAssignableFrom(typeof(string), 5); + Assert.IsAssignableFrom(typeof(string), "Hello"); + Assert.IsNotAssignableFrom(typeof(string), 5); } #endregion @@ -156,7 +176,6 @@ public void SubstringTests() // Constraint Syntax Assert.That(phrase, Does.Contain("World")); - // Only available using new syntax Assert.That(phrase, Does.Not.Contain("goodbye")); Assert.That(phrase, Does.Contain("WORLD").IgnoreCase); Assert.That(phrase, Does.Not.Contain("BYE").IgnoreCase); @@ -174,7 +193,6 @@ public void StartsWithTests() // Constraint Syntax Assert.That(phrase, Does.StartWith("Hello")); - // Only available using new syntax Assert.That(phrase, Does.Not.StartWith("Hi!")); Assert.That(phrase, Does.StartWith("HeLLo").IgnoreCase); Assert.That(phrase, Does.Not.StartWith("HI").IgnoreCase); @@ -255,10 +273,10 @@ public void EqualityTests() Assert.That(i3, Is.Not.EqualTo(iunequal)); // Classic Syntax - ClassicAssert.AreEqual(4, 2 + 2); - ClassicAssert.AreEqual(i3, d3); - ClassicAssert.AreNotEqual(5, 2 + 2); - ClassicAssert.AreNotEqual(i3, iunequal); + Assert.AreEqual(4, 2 + 2); + Assert.AreEqual(i3, d3); + Assert.AreNotEqual(5, 2 + 2); + Assert.AreNotEqual(i3, iunequal); } [Test] @@ -274,9 +292,9 @@ public void EqualityTestsWithTolerance() Assert.That(4999999999L, Is.EqualTo(5000000000L).Within(5L)); Assert.That(5999999999ul, Is.EqualTo(6000000000ul).Within(5ul)); - // CLassic syntax - ClassicAssert.AreEqual(5.0d, 4.99d, 0.05d); - ClassicAssert.AreEqual(5.0f, 4.99f, 0.05f); + // Classic syntax + Assert.AreEqual(5.0d, 4.99d, 0.05d); + Assert.AreEqual(5.0f, 4.99f, 0.05f); } [Test] @@ -330,9 +348,9 @@ public void ComparisonTests() Assert.That(7, Is.AtLeast(7)); // Classic Syntax - ClassicAssert.Greater(7, 3); - ClassicAssert.GreaterOrEqual(7, 3); - ClassicAssert.GreaterOrEqual(7, 7); + Assert.Greater(7, 3); + Assert.GreaterOrEqual(7, 3); + Assert.GreaterOrEqual(7, 7); // Constraint Syntax Assert.That(3, Is.LessThan(7)); @@ -343,9 +361,9 @@ public void ComparisonTests() // Classic syntax - ClassicAssert.Less(3, 7); - ClassicAssert.LessOrEqual(3, 7); - ClassicAssert.LessOrEqual(3, 3); + Assert.Less(3, 7); + Assert.LessOrEqual(3, 7); + Assert.LessOrEqual(3, 3); } #endregion @@ -437,21 +455,19 @@ public void CollectionContainsTests() Assert.That(iarray, Has.Member(3)); Assert.That(sarray, Has.Some.EqualTo("b")); Assert.That(sarray, Has.None.EqualTo("x")); - Assert.That(iarray, Has.None.SameAs(1.0d)); Assert.That(iarray, Has.All.LessThan(10)); Assert.That(sarray, Has.All.Length.EqualTo(1)); Assert.That(sarray, Has.None.Property("Length").GreaterThan(3)); // Classic syntax - ClassicAssert.Contains(3, iarray); - ClassicAssert.Contains("b", sarray); + Assert.Contains(3, iarray); + Assert.Contains("b", sarray); CollectionAssert.Contains(iarray, 3); CollectionAssert.Contains(sarray, "b"); CollectionAssert.DoesNotContain(sarray, "x"); // Showing that Contains uses NUnit equality CollectionAssert.Contains(iarray, 1.0d); - } [Test] @@ -490,7 +506,6 @@ public void SubsetTests() CollectionAssert.IsSubsetOf(new[] { 1, 2, 3, 4, 5 }, ints1to5); CollectionAssert.IsNotSubsetOf(new[] { 2, 4, 6 }, ints1to5); CollectionAssert.IsNotSubsetOf(new[] { 1, 2, 2, 2, 5 }, ints1to5); - } #endregion @@ -498,8 +513,8 @@ public void SubsetTests() [Test] public void PropertyTests() { - string[] array = { "abc", "bca", "xyz", "qrs" }; - string[] array2 = { "a", "ab", "abc" }; + string[] array = ["abc", "bca", "xyz", "qrs"]; + string[] array2 = ["a", "ab", "abc"]; var list = new ArrayList(array); // Not available using the classic syntax @@ -557,21 +572,18 @@ public void NotTests() [Test] public void NotOperator() { - // The ! operator is only available in the new syntax Assert.That(42, !Is.Null); } [Test] public void AndOperator() { - // The & operator is only available in the new syntax Assert.That(7, Is.GreaterThan(5) & Is.LessThan(10)); } [Test] public void OrOperator() { - // The | operator is only available in the new syntax Assert.That(3, Is.LessThan(5) | Is.GreaterThan(10)); }