diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-21 16:15:28 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-21 16:15:28 -0700 |
commit | d2350db627b5ef7c9ebe6fd150b3007b0af1e660 (patch) | |
tree | 6817d8679ad3efadb78e7c275429fd9372ee4058 | |
parent | b5c8335f528acbca046ca2844f8e4c12cfa9cba3 (diff) | |
parent | 4f2ccab7a53819c7d0c4008626995e95ece4dd34 (diff) | |
download | DotNetOpenAuth-d2350db627b5ef7c9ebe6fd150b3007b0af1e660.zip DotNetOpenAuth-d2350db627b5ef7c9ebe6fd150b3007b0af1e660.tar.gz DotNetOpenAuth-d2350db627b5ef7c9ebe6fd150b3007b0af1e660.tar.bz2 |
Merge branch 'v3.4' into oauth2
Conflicts:
projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj
projecttemplates/RelyingPartyLogic/CreateDatabase.sql
samples/OAuthConsumerWpf/OAuthConsumerWpf.csproj
src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
src/DotNetOpenAuth/Messaging/MessagingStrings.resx
src/DotNetOpenAuth/Messaging/MessagingUtilities.cs
src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs
src/version.txt
267 files changed, 26459 insertions, 848 deletions
diff --git a/EnlistmentInfo.props b/EnlistmentInfo.props new file mode 100644 index 0000000..69cacb4 --- /dev/null +++ b/EnlistmentInfo.props @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> + <PropertyGroup> + <!-- Release builds should break when StyleCop warnings exist. --> + <StyleCopTreatErrorsAsWarnings Condition=" '$(StyleCopTreatErrorsAsWarnings)' == '' and '$(Configuration)' == 'Release' ">false</StyleCopTreatErrorsAsWarnings> + <StyleCopTreatErrorsAsWarnings Condition=" '$(StyleCopTreatErrorsAsWarnings)' == '' ">true</StyleCopTreatErrorsAsWarnings> + + <ProjectRoot>$(MSBuildThisFileDirectory)\</ProjectRoot> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/EnlistmentInfo.targets b/EnlistmentInfo.targets new file mode 100644 index 0000000..19bfd55 --- /dev/null +++ b/EnlistmentInfo.targets @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> + <Import Project="Tools\StyleCop\Microsoft.StyleCop.Targets"/> +</Project>
\ No newline at end of file @@ -1,4 +1,5 @@ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="EnlistmentInfo.props" /> <Import Project="$(MSBuildProjectDirectory)\tools\DotNetOpenAuth.automated.props"/> <Import Project="$(ProjectRoot)tools\Translation.targets"/> @@ -11,7 +12,7 @@ samples\samples.proj; doc\doc.proj; " /> - + <ProjectsToClean Include=" $(SolutionPath); projecttemplates\projecttemplates.proj; @@ -47,7 +48,7 @@ </Target> <Target Name="Test" DependsOnTargets="BuildTests" - Inputs="$(OutputPath)$(ProductName).Test.dll" + Inputs="$(OutputPath)$(ProductName).dll;$(OutputPath)$(ProductName).Test.dll" Outputs='$(OutputPath)Test-result.xml'> <PropertyGroup> <!-- Performance tests are only expected to pass in optimized builds. --> @@ -56,7 +57,7 @@ <NUnit Assemblies="$(OutputPath)$(ProductName).Test.dll" ToolPath="$(NUnitToolPath)" OutputXmlFile="$(OutputPath)Test-result.xml" - ExcludeCategory="$(NUnitExcludeCategories)"/> + ExcludeCategory="$(NUnitExcludeCategories)" /> </Target> <Target Name="Nightly"> @@ -68,4 +69,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="EnlistmentInfo.targets" /> </Project> diff --git a/doc/doc.proj b/doc/doc.proj index 75f3cdc..e75565c 100644 --- a/doc/doc.proj +++ b/doc/doc.proj @@ -9,8 +9,8 @@ For creating or publishing to web sites: $(DocWebRoot): the full physical path to where documentation should be copied to, excluding $(BranchName) --> - - <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> + <Import Project="..\tools\DotNetOpenAuth.automated.props"/> <Target Name="Build" DependsOnTargets="BuildProduct;Chm" Condition=" '$(NoDocumentation)' != 'true' " /> @@ -62,4 +62,5 @@ <Import Project="$(ProjectRoot)tools\Documentation.targets"/> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/lib/DotNetOpenAuth.BuildTasks.targets b/lib/DotNetOpenAuth.BuildTasks.targets index 2a4c14d..e57ec97 100644 --- a/lib/DotNetOpenAuth.BuildTasks.targets +++ b/lib/DotNetOpenAuth.BuildTasks.targets @@ -1,35 +1,31 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> - <PropertyGroup> - <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..</ProjectRoot> - </PropertyGroup> <ItemGroup> <VsTemplateParameterReplaceExtensions Include=".cs;.csproj;.sql;.config;.Master;.aspx;.ascx;.vb;.asax;.ashx" /> <VsTemplateProjectItemTypes Include="Compile;EmbeddedResource;EntityDeploy;Content;None" /> </ItemGroup> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="GetBuildVersion" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="SetEnvironmentVariable" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="ChangeProjectReferenceToAssemblyReference" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="CompareFiles" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="ReSignDelaySignedAssemblies" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="SignatureVerification" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="CheckAdminRights" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="CreateWebApplication" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="DeleteWebApplication" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="Trim" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="FilterItems" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="JsPack" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="CopyWithTokenSubstitution" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="MergeProjectWithVSTemplate" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="DiscoverProjectTemplates" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="FixupReferenceHintPaths" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="AddProjectItems" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="Purge" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="FixupShippingToolSamples" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="Publicize" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="DowngradeProjects" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="HardLinkCopy" /> - <UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="PrepareOhlohRelease" /> - + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="GetBuildVersion" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="SetEnvironmentVariable" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="ChangeProjectReferenceToAssemblyReference" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="CompareFiles" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="ReSignDelaySignedAssemblies" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="SignatureVerification" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="CheckAdminRights" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="CreateWebApplication" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="DeleteWebApplication" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="Trim" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="FilterItems" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="JsPack" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="CopyWithTokenSubstitution" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="MergeProjectWithVSTemplate" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="DiscoverProjectTemplates" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="FixupReferenceHintPaths" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="AddProjectItems" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="Purge" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="FixupShippingToolSamples" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="Publicize" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="DowngradeProjects" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="HardLinkCopy" /> + <UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="PrepareOhlohRelease" /> </Project> diff --git a/projecttemplates/MvcRelyingParty/MvcRelyingParty.csproj b/projecttemplates/MvcRelyingParty/MvcRelyingParty.csproj index 6378402..e08465f 100644 --- a/projecttemplates/MvcRelyingParty/MvcRelyingParty.csproj +++ b/projecttemplates/MvcRelyingParty/MvcRelyingParty.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -213,4 +214,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj index 9ffe9cf..3df061c 100644 --- a/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj +++ b/projecttemplates/RelyingPartyDatabase/RelyingPartyDatabase.dbproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Name>"DatabaseProject"</Name> @@ -319,4 +320,5 @@ <QuotedIdentifier>On</QuotedIdentifier> </Build> </ItemGroup> -</Project>
\ No newline at end of file + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> +</Project> diff --git a/projecttemplates/RelyingPartyLogic/.gitignore b/projecttemplates/RelyingPartyLogic/.gitignore new file mode 100644 index 0000000..673a3d9 --- /dev/null +++ b/projecttemplates/RelyingPartyLogic/.gitignore @@ -0,0 +1 @@ +CreateDatabase.sql diff --git a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql b/projecttemplates/RelyingPartyLogic/CreateDatabase.sql deleted file mode 100644 index 5c82398..0000000 --- a/projecttemplates/RelyingPartyLogic/CreateDatabase.sql +++ /dev/null @@ -1,685 +0,0 @@ -/* -Deployment script for RelyingPartyDatabase -*/ - -GO -SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, NUMERIC_ROUNDABORT, QUOTED_IDENTIFIER OFF; - - -GO -/* -:setvar Path1 "WEBROOT" -:setvar DatabaseName "RelyingPartyDatabase" -:setvar DefaultDataPath "c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\" -:setvar DefaultLogPath "c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\" -*/ - -GO -USE [master] - -GO -IF (DB_ID(N'$(DatabaseName)') IS NOT NULL - AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE') -BEGIN - RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT - RETURN -END - -GO -IF (DB_ID(N'$(DatabaseName)') IS NOT NULL) -BEGIN - ALTER DATABASE [$(DatabaseName)] - SET SINGLE_USER WITH ROLLBACK IMMEDIATE; - DROP DATABASE [$(DatabaseName)]; -END - -GO -PRINT N'Creating $(DatabaseName)...' -GO -CREATE DATABASE [$(DatabaseName)] - ON - PRIMARY(NAME = [$(Path1)$(DatabaseName).mdf], FILENAME = '$(Path1)$(DatabaseName).mdf', FILEGROWTH = 1024 KB) - LOG ON (NAME = [$(DatabaseName)_log], FILENAME = '$(Path1)$(DatabaseName)_log.LDF', MAXSIZE = 2097152 MB, FILEGROWTH = 10 %) COLLATE SQL_Latin1_General_CP1_CI_AS -GO -EXECUTE sp_dbcmptlevel [$(DatabaseName)], 90; - - -GO -IF EXISTS (SELECT 1 - FROM [master].[dbo].[sysdatabases] - WHERE [name] = N'$(DatabaseName)') - BEGIN - ALTER DATABASE [$(DatabaseName)] - SET ANSI_NULLS OFF, - ANSI_PADDING OFF, - ANSI_WARNINGS OFF, - ARITHABORT OFF, - CONCAT_NULL_YIELDS_NULL OFF, - NUMERIC_ROUNDABORT OFF, - QUOTED_IDENTIFIER OFF, - ANSI_NULL_DEFAULT OFF, - CURSOR_DEFAULT GLOBAL, - RECOVERY SIMPLE, - CURSOR_CLOSE_ON_COMMIT OFF, - AUTO_CREATE_STATISTICS ON, - AUTO_SHRINK OFF, - AUTO_UPDATE_STATISTICS ON, - RECURSIVE_TRIGGERS OFF - WITH ROLLBACK IMMEDIATE; - ALTER DATABASE [$(DatabaseName)] - SET AUTO_CLOSE ON - WITH ROLLBACK IMMEDIATE; - END - - -GO -IF EXISTS (SELECT 1 - FROM [master].[dbo].[sysdatabases] - WHERE [name] = N'$(DatabaseName)') - BEGIN - ALTER DATABASE [$(DatabaseName)] - SET ALLOW_SNAPSHOT_ISOLATION OFF; - END - - -GO -IF EXISTS (SELECT 1 - FROM [master].[dbo].[sysdatabases] - WHERE [name] = N'$(DatabaseName)') - BEGIN - ALTER DATABASE [$(DatabaseName)] - SET READ_COMMITTED_SNAPSHOT OFF; - END - - -GO -IF EXISTS (SELECT 1 - FROM [master].[dbo].[sysdatabases] - WHERE [name] = N'$(DatabaseName)') - BEGIN - ALTER DATABASE [$(DatabaseName)] - SET AUTO_UPDATE_STATISTICS_ASYNC OFF, - PAGE_VERIFY CHECKSUM, - DATE_CORRELATION_OPTIMIZATION OFF, - DISABLE_BROKER, - PARAMETERIZATION SIMPLE, - SUPPLEMENTAL_LOGGING OFF - WITH ROLLBACK IMMEDIATE; - END - - -GO -IF IS_SRVROLEMEMBER(N'sysadmin') = 1 - BEGIN - IF EXISTS (SELECT 1 - FROM [master].[dbo].[sysdatabases] - WHERE [name] = N'$(DatabaseName)') - BEGIN - EXECUTE sp_executesql N'ALTER DATABASE [$(DatabaseName)] - SET TRUSTWORTHY OFF, - DB_CHAINING OFF - WITH ROLLBACK IMMEDIATE'; - END - END -ELSE - BEGIN - PRINT N'The database settings cannot be modified. You must be a SysAdmin to apply these settings.'; - END - - -GO -USE [$(DatabaseName)] - -GO -IF fulltextserviceproperty(N'IsFulltextInstalled') = 1 - EXECUTE sp_fulltext_database 'enable'; - - -GO -/* - Pre-Deployment Script Template --------------------------------------------------------------------------------------- - This file contains SQL statements that will be executed before the build script. - Use SQLCMD syntax to include a file in the pre-deployment script. - Example: :r .\myfile.sql - Use SQLCMD syntax to reference a variable in the pre-deployment script. - Example: :setvar TableName MyTable - SELECT * FROM [$(TableName)] --------------------------------------------------------------------------------------- -*/ - -GO -PRINT N'Creating [dbo].[AuthenticationToken]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[AuthenticationToken] ( - [AuthenticationTokenId] INT IDENTITY (1, 1) NOT NULL, - [UserId] INT NOT NULL, - [OpenIdClaimedIdentifier] NVARCHAR (250) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [OpenIdFriendlyIdentifier] NVARCHAR (250) NULL, - [CreatedOn] DATETIME NOT NULL, - [LastUsed] DATETIME NOT NULL, - [UsageCount] INT NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_AuthenticationToken...'; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] - ADD CONSTRAINT [PK_AuthenticationToken] PRIMARY KEY CLUSTERED ([AuthenticationTokenId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[Client]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[Client] ( - [ClientId] INT IDENTITY (1, 1) NOT NULL, - [ClientIdentifier] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [ClientSecret] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL, - [Callback] VARCHAR (2048) NULL, - [Name] NVARCHAR (50) NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_Consumer...'; - - -GO -ALTER TABLE [dbo].[Client] - ADD CONSTRAINT [PK_Consumer] PRIMARY KEY CLUSTERED ([ClientId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[Client].[IX_Consumer]...'; - - -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_Consumer] - ON [dbo].[Client]([ClientIdentifier] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0) - ON [PRIMARY]; - - -GO -PRINT N'Creating [dbo].[ClientAuthorization]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[ClientAuthorization] ( - [AuthorizationId] INT IDENTITY (1, 1) NOT NULL, - [ClientId] INT NOT NULL, - [UserId] INT NOT NULL, - [CreatedOn] DATETIME NOT NULL, - [ExpirationDate] DATETIME NULL, - [Scope] VARCHAR (2048) NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_IssuedToken...'; - - -GO -ALTER TABLE [dbo].[ClientAuthorization] - ADD CONSTRAINT [PK_IssuedToken] PRIMARY KEY CLUSTERED ([AuthorizationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[Log]...'; - - -GO -CREATE TABLE [dbo].[Log] ( - [Id] INT IDENTITY (1, 1) NOT NULL, - [Date] DATETIME NOT NULL, - [Thread] VARCHAR (255) NOT NULL, - [Level] VARCHAR (50) NOT NULL, - [Logger] VARCHAR (255) NOT NULL, - [Message] VARCHAR (4000) NOT NULL, - [Exception] VARCHAR (2000) NULL -); - - -GO -PRINT N'Creating [dbo].[Nonce]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[Nonce] ( - [NonceId] INT IDENTITY (1, 1) NOT NULL, - [Context] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Code] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Issued] DATETIME NOT NULL, - [Expires] DATETIME NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_Nonce...'; - - -GO -ALTER TABLE [dbo].[Nonce] - ADD CONSTRAINT [PK_Nonce] PRIMARY KEY CLUSTERED ([NonceId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[Nonce].[IX_Nonce_Code]...'; - - -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_Nonce_Code] - ON [dbo].[Nonce]([Context] ASC, [Code] ASC, [Issued] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); - - -GO -PRINT N'Creating [dbo].[Nonce].[IX_Nonce_Expires]...'; - - -GO -CREATE NONCLUSTERED INDEX [IX_Nonce_Expires] - ON [dbo].[Nonce]([Expires] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); - - -GO -PRINT N'Creating [dbo].[OpenIDAssociation]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[OpenIDAssociation] ( - [AssociationId] INT IDENTITY (1, 1) NOT NULL, - [DistinguishingFactor] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [AssociationHandle] VARCHAR (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, - [Expiration] DATETIME NOT NULL, - [PrivateData] BINARY (64) NOT NULL, - [PrivateDataLength] INT NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_OpenIDAssociations...'; - - -GO -ALTER TABLE [dbo].[OpenIDAssociation] - ADD CONSTRAINT [PK_OpenIDAssociations] PRIMARY KEY CLUSTERED ([AssociationId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[OpenIDAssociation].[IX_OpenIDAssociations]...'; - - -GO -CREATE UNIQUE NONCLUSTERED INDEX [IX_OpenIDAssociations] - ON [dbo].[OpenIDAssociation]([DistinguishingFactor] ASC, [AssociationHandle] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF, ONLINE = OFF, MAXDOP = 0); - - -GO -PRINT N'Creating [dbo].[Role]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[Role] ( - [RoleId] INT IDENTITY (1, 1) NOT NULL, - [Name] NVARCHAR (50) NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_Role...'; - - -GO -ALTER TABLE [dbo].[Role] - ADD CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED ([RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[User]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[User] ( - [UserId] INT IDENTITY (1, 1) NOT NULL, - [FirstName] NVARCHAR (50) NULL, - [LastName] NVARCHAR (50) NULL, - [EmailAddress] NVARCHAR (100) NULL, - [EmailAddressVerified] BIT NOT NULL, - [CreatedOn] DATETIME NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_User...'; - - -GO -ALTER TABLE [dbo].[User] - ADD CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([UserId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating [dbo].[UserRole]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE TABLE [dbo].[UserRole] ( - [UserId] INT NOT NULL, - [RoleId] INT NOT NULL -); - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating PK_UserRole...'; - - -GO -ALTER TABLE [dbo].[UserRole] - ADD CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED ([UserId] ASC, [RoleId] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF); - - -GO -PRINT N'Creating DF_AuthenticationToken_CreatedOn...'; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] - ADD CONSTRAINT [DF_AuthenticationToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; - - -GO -PRINT N'Creating DF_AuthenticationToken_LastUsed...'; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] - ADD CONSTRAINT [DF_AuthenticationToken_LastUsed] DEFAULT (getutcdate()) FOR [LastUsed]; - - -GO -PRINT N'Creating DF_AuthenticationToken_UsageCount...'; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] - ADD CONSTRAINT [DF_AuthenticationToken_UsageCount] DEFAULT ((0)) FOR [UsageCount]; - - -GO -PRINT N'Creating DF_IssuedToken_CreatedOn...'; - - -GO -ALTER TABLE [dbo].[ClientAuthorization] - ADD CONSTRAINT [DF_IssuedToken_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; - - -GO -PRINT N'Creating DF_Nonce_Issued...'; - - -GO -ALTER TABLE [dbo].[Nonce] - ADD CONSTRAINT [DF_Nonce_Issued] DEFAULT (getutcdate()) FOR [Issued]; - - -GO -PRINT N'Creating DF_User_CreatedOn...'; - - -GO -ALTER TABLE [dbo].[User] - ADD CONSTRAINT [DF_User_CreatedOn] DEFAULT (getutcdate()) FOR [CreatedOn]; - - -GO -PRINT N'Creating DF_User_EmailAddressVerified...'; - - -GO -ALTER TABLE [dbo].[User] - ADD CONSTRAINT [DF_User_EmailAddressVerified] DEFAULT ((0)) FOR [EmailAddressVerified]; - - -GO -PRINT N'Creating FK_AuthenticationToken_User...'; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] WITH NOCHECK - ADD CONSTRAINT [FK_AuthenticationToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; - - -GO -PRINT N'Creating FK_IssuedToken_Consumer...'; - - -GO -ALTER TABLE [dbo].[ClientAuthorization] WITH NOCHECK - ADD CONSTRAINT [FK_IssuedToken_Consumer] FOREIGN KEY ([ClientId]) REFERENCES [dbo].[Client] ([ClientId]) ON DELETE CASCADE ON UPDATE CASCADE; - - -GO -PRINT N'Creating FK_IssuedToken_User...'; - - -GO -ALTER TABLE [dbo].[ClientAuthorization] WITH NOCHECK - ADD CONSTRAINT [FK_IssuedToken_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; - - -GO -PRINT N'Creating FK_UserRole_Role...'; - - -GO -ALTER TABLE [dbo].[UserRole] WITH NOCHECK - ADD CONSTRAINT [FK_UserRole_Role] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[Role] ([RoleId]) ON DELETE CASCADE ON UPDATE CASCADE; - - -GO -PRINT N'Creating FK_UserRole_User...'; - - -GO -ALTER TABLE [dbo].[UserRole] WITH NOCHECK - ADD CONSTRAINT [FK_UserRole_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]) ON DELETE CASCADE ON UPDATE CASCADE; - - -GO -PRINT N'Creating [dbo].[AddUser]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE PROCEDURE [dbo].[AddUser] - ( - @firstName nvarchar(50), - @lastName nvarchar(50), - @openid nvarchar(255), - @role nvarchar(255) - ) -AS - DECLARE - @roleid int, - @userid int - - BEGIN TRANSACTION - - INSERT INTO [dbo].[User] (FirstName, LastName) VALUES (@firstName, @lastName) - SET @userid = (SELECT @@IDENTITY) - - IF (SELECT COUNT(*) FROM dbo.Role WHERE [Name] = @role) = 0 - BEGIN - INSERT INTO dbo.Role (Name) VALUES (@role) - SET @roleid = (SELECT @@IDENTITY) - END - ELSE - BEGIN - SET @roleid = (SELECT RoleId FROM dbo.Role WHERE [Name] = @role) - END - - INSERT INTO dbo.UserRole (UserId, RoleId) VALUES (@userId, @roleid) - - INSERT INTO dbo.AuthenticationToken - (UserId, OpenIdClaimedIdentifier, OpenIdFriendlyIdentifier) - VALUES - (@userid, @openid, @openid) - - COMMIT TRANSACTION - - RETURN @userid -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating [dbo].[ClearExpiredAssociations]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE PROCEDURE dbo.ClearExpiredAssociations -AS - -DELETE FROM dbo.OpenIDAssociation -WHERE [Expiration] < getutcdate() -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO -PRINT N'Creating [dbo].[ClearExpiredNonces]...'; - - -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER ON; - - -GO -CREATE PROCEDURE dbo.ClearExpiredNonces -AS - -DELETE FROM dbo.[Nonce] -WHERE [Expires] < getutcdate() -GO -SET ANSI_NULLS, QUOTED_IDENTIFIER OFF; - - -GO --- Refactoring step to update target server with deployed transaction logs -CREATE TABLE [dbo].[__RefactorLog] (OperationKey UNIQUEIDENTIFIER NOT NULL PRIMARY KEY) -GO -sp_addextendedproperty N'microsoft_database_tools_support', N'refactoring log', N'schema', N'dbo', N'table', N'__RefactorLog' -GO - -GO -/* -Post-Deployment Script Template --------------------------------------------------------------------------------------- - This file contains SQL statements that will be appended to the build script. - Use SQLCMD syntax to include a file in the post-deployment script. - Example: :r .\myfile.sql - Use SQLCMD syntax to reference a variable in the post-deployment script. - Example: :setvar TableName MyTable - SELECT * FROM [$(TableName)] --------------------------------------------------------------------------------------- -*/ - -GO -PRINT N'Checking existing data against newly created constraints'; - - -GO -USE [$(DatabaseName)]; - - -GO -ALTER TABLE [dbo].[AuthenticationToken] WITH CHECK CHECK CONSTRAINT [FK_AuthenticationToken_User]; - -ALTER TABLE [dbo].[ClientAuthorization] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_Consumer]; - -ALTER TABLE [dbo].[ClientAuthorization] WITH CHECK CHECK CONSTRAINT [FK_IssuedToken_User]; - -ALTER TABLE [dbo].[UserRole] WITH CHECK CHECK CONSTRAINT [FK_UserRole_Role]; - -ALTER TABLE [dbo].[UserRole] WITH CHECK CHECK CONSTRAINT [FK_UserRole_User]; - - -GO diff --git a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj index 06dee41..942fa3b 100644 --- a/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj +++ b/projecttemplates/RelyingPartyLogic/RelyingPartyLogic.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -176,4 +177,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj index eb81910..04c85b7 100644 --- a/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj +++ b/projecttemplates/WebFormsRelyingParty/WebFormsRelyingParty.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -280,4 +281,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/projecttemplates/projecttemplates.proj b/projecttemplates/projecttemplates.proj index 470d1f3..0fa6068 100644 --- a/projecttemplates/projecttemplates.proj +++ b/projecttemplates/projecttemplates.proj @@ -1,4 +1,5 @@ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <Import Project="ProjectTemplates.props"/> @@ -253,4 +254,5 @@ <Target Name="Build" DependsOnTargets="Zip;Zip2008" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj b/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj index d05c9c2..be80671 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj +++ b/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -126,11 +127,5 @@ </BootstrapperPackage> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs index 2add642..558d4bc 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs @@ -207,12 +207,12 @@ namespace DotNetOpenAuth.ApplicationBlock { /// <summary> /// Gets the Gmail address book's contents. /// </summary> - /// <param name="consumer">The Google consumer previously constructed using <see cref="CreateWebConsumer"/> or <see cref="CreateDesktopConsumer"/>.</param> + /// <param name="consumer">The Google consumer.</param> /// <param name="accessToken">The access token previously retrieved.</param> /// <param name="maxResults">The maximum number of entries to return. If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number here.</param> /// <param name="startIndex">The 1-based index of the first result to be retrieved (for paging).</param> /// <returns>An XML document returned by Google.</returns> - public static XDocument GetContacts(ConsumerBase consumer, string accessToken, int maxResults = 25, int startIndex = 1) { + public static XDocument GetContacts(ConsumerBase consumer, string accessToken, int maxResults/* = 25*/, int startIndex/* = 1*/) { if (consumer == null) { throw new ArgumentNullException("consumer"); } diff --git a/samples/DotNetOpenAuth.ApplicationBlock/Util.cs b/samples/DotNetOpenAuth.ApplicationBlock/Util.cs index ea7da97..0bec372 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/Util.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/Util.cs @@ -1,10 +1,44 @@ namespace DotNetOpenAuth.ApplicationBlock { using System; using System.Collections.Generic; + using System.Diagnostics; using System.IO; + using System.Net; using DotNetOpenAuth.Messaging; - internal static class Util { + public static class Util { + /// <summary> + /// Pseudo-random data generator. + /// </summary> + internal static readonly Random NonCryptoRandomDataGenerator = new Random(); + + /// <summary> + /// Sets the channel's outgoing HTTP requests to use default network credentials. + /// </summary> + /// <param name="channel">The channel to modify.</param> + public static void UseDefaultNetworkCredentialsOnOutgoingHttpRequests(this Channel channel) + { + Debug.Assert(!(channel.WebRequestHandler is WrappingWebRequestHandler), "Wrapping an already wrapped web request handler. This is legal, but highly suspect of a bug as you don't want to wrap the same channel repeatedly to apply the same effect."); + AddOutgoingHttpRequestTransform(channel, http => http.Credentials = CredentialCache.DefaultNetworkCredentials); + } + + /// <summary> + /// Adds some action to any outgoing HTTP request on this channel. + /// </summary> + /// <param name="channel">The channel's whose outgoing HTTP requests should be modified.</param> + /// <param name="action">The action to perform on outgoing HTTP requests.</param> + internal static void AddOutgoingHttpRequestTransform(this Channel channel, Action<HttpWebRequest> action) { + if (channel == null) { + throw new ArgumentNullException("channel"); + } + + if (action == null) { + throw new ArgumentNullException("action"); + } + + channel.WebRequestHandler = new WrappingWebRequestHandler(channel.WebRequestHandler, action); + } + /// <summary> /// Enumerates through the individual set bits in a flag enum. /// </summary> @@ -72,5 +106,154 @@ return totalCopiedBytes; } + + /// <summary> + /// Wraps some instance of a web request handler in order to perform some extra operation on all + /// outgoing HTTP requests. + /// </summary> + private class WrappingWebRequestHandler : IDirectWebRequestHandler + { + /// <summary> + /// The handler being wrapped. + /// </summary> + private readonly IDirectWebRequestHandler wrappedHandler; + + /// <summary> + /// The action to perform on outgoing HTTP requests. + /// </summary> + private readonly Action<HttpWebRequest> action; + + /// <summary> + /// Initializes a new instance of the <see cref="WrappingWebRequestHandler"/> class. + /// </summary> + /// <param name="wrappedHandler">The HTTP handler to wrap.</param> + /// <param name="action">The action to perform on outgoing HTTP requests.</param> + internal WrappingWebRequestHandler(IDirectWebRequestHandler wrappedHandler, Action<HttpWebRequest> action) + { + if (wrappedHandler == null) { + throw new ArgumentNullException("wrappedHandler"); + } + + if (action == null) { + throw new ArgumentNullException("action"); + } + + this.wrappedHandler = wrappedHandler; + this.action = action; + } + + #region Implementation of IDirectWebRequestHandler + + /// <summary> + /// Determines whether this instance can support the specified options. + /// </summary> + /// <param name="options">The set of options that might be given in a subsequent web request.</param> + /// <returns> + /// <c>true</c> if this instance can support the specified options; otherwise, <c>false</c>. + /// </returns> + public bool CanSupport(DirectWebRequestOptions options) + { + return this.wrappedHandler.CanSupport(options); + } + + /// <summary> + /// Prepares an <see cref="HttpWebRequest"/> that contains an POST entity for sending the entity. + /// </summary> + /// <param name="request">The <see cref="HttpWebRequest"/> that should contain the entity.</param> + /// <returns> + /// The stream the caller should write out the entity data to. + /// </returns> + /// <exception cref="ProtocolException">Thrown for any network error.</exception> + /// <remarks> + /// <para>The caller should have set the <see cref="HttpWebRequest.ContentLength"/> + /// and any other appropriate properties <i>before</i> calling this method. + /// Callers <i>must</i> close and dispose of the request stream when they are done + /// writing to it to avoid taking up the connection too long and causing long waits on + /// subsequent requests.</para> + /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a + /// <see cref="ProtocolException"/> to abstract away the transport and provide + /// a single exception type for hosts to catch.</para> + /// </remarks> + public Stream GetRequestStream(HttpWebRequest request) + { + this.action(request); + return this.wrappedHandler.GetRequestStream(request); + } + + /// <summary> + /// Prepares an <see cref="HttpWebRequest"/> that contains an POST entity for sending the entity. + /// </summary> + /// <param name="request">The <see cref="HttpWebRequest"/> that should contain the entity.</param> + /// <param name="options">The options to apply to this web request.</param> + /// <returns> + /// The stream the caller should write out the entity data to. + /// </returns> + /// <exception cref="ProtocolException">Thrown for any network error.</exception> + /// <remarks> + /// <para>The caller should have set the <see cref="HttpWebRequest.ContentLength"/> + /// and any other appropriate properties <i>before</i> calling this method. + /// Callers <i>must</i> close and dispose of the request stream when they are done + /// writing to it to avoid taking up the connection too long and causing long waits on + /// subsequent requests.</para> + /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a + /// <see cref="ProtocolException"/> to abstract away the transport and provide + /// a single exception type for hosts to catch.</para> + /// </remarks> + public Stream GetRequestStream(HttpWebRequest request, DirectWebRequestOptions options) + { + this.action(request); + return this.wrappedHandler.GetRequestStream(request, options); + } + + /// <summary> + /// Processes an <see cref="HttpWebRequest"/> and converts the + /// <see cref="HttpWebResponse"/> to a <see cref="IncomingWebResponse"/> instance. + /// </summary> + /// <param name="request">The <see cref="HttpWebRequest"/> to handle.</param> + /// <returns>An instance of <see cref="IncomingWebResponse"/> describing the response.</returns> + /// <exception cref="ProtocolException">Thrown for any network error.</exception> + /// <remarks> + /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a + /// <see cref="ProtocolException"/> to abstract away the transport and provide + /// a single exception type for hosts to catch. The <see cref="WebException.Response"/> + /// value, if set, should be Closed before throwing.</para> + /// </remarks> + public IncomingWebResponse GetResponse(HttpWebRequest request) + { + // If the request has an entity, the action would have already been processed in GetRequestStream. + if (request.Method == "GET") + { + this.action(request); + } + + return this.wrappedHandler.GetResponse(request); + } + + /// <summary> + /// Processes an <see cref="HttpWebRequest"/> and converts the + /// <see cref="HttpWebResponse"/> to a <see cref="IncomingWebResponse"/> instance. + /// </summary> + /// <param name="request">The <see cref="HttpWebRequest"/> to handle.</param> + /// <param name="options">The options to apply to this web request.</param> + /// <returns>An instance of <see cref="IncomingWebResponse"/> describing the response.</returns> + /// <exception cref="ProtocolException">Thrown for any network error.</exception> + /// <remarks> + /// <para>Implementations should catch <see cref="WebException"/> and wrap it in a + /// <see cref="ProtocolException"/> to abstract away the transport and provide + /// a single exception type for hosts to catch. The <see cref="WebException.Response"/> + /// value, if set, should be Closed before throwing.</para> + /// </remarks> + public IncomingWebResponse GetResponse(HttpWebRequest request, DirectWebRequestOptions options) + { + // If the request has an entity, the action would have already been processed in GetRequestStream. + if (request.Method == "GET") { + this.action(request); + } + + return this.wrappedHandler.GetResponse(request, options); + } + + #endregion + } } } diff --git a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs index 1ca3abe..ddca7e4 100644 --- a/samples/OAuthConsumer/GoogleAddressBook.aspx.cs +++ b/samples/OAuthConsumer/GoogleAddressBook.aspx.cs @@ -57,7 +57,7 @@ protected void getAddressBookButton_Click(object sender, EventArgs e) { var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - XDocument contactsDocument = GoogleConsumer.GetContacts(google, this.AccessToken, 5); + XDocument contactsDocument = GoogleConsumer.GetContacts(google, this.AccessToken, 5, 1); var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")) select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value, Email = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value }; StringBuilder tableBuilder = new StringBuilder(); diff --git a/samples/OAuthConsumer/OAuthConsumer.csproj b/samples/OAuthConsumer/OAuthConsumer.csproj index ae69bdc..698de7a 100644 --- a/samples/OAuthConsumer/OAuthConsumer.csproj +++ b/samples/OAuthConsumer/OAuthConsumer.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -203,11 +204,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OAuthConsumerWpf/Authorize.xaml.cs b/samples/OAuthConsumerWpf/Authorize.xaml.cs index 2ee4d70..4ed1932 100644 --- a/samples/OAuthConsumerWpf/Authorize.xaml.cs +++ b/samples/OAuthConsumerWpf/Authorize.xaml.cs @@ -24,7 +24,7 @@ private string requestToken; internal Authorize(DesktopConsumer consumer, FetchUri fetchUriCallback) { - InitializeComponent(); + this.InitializeComponent(); this.consumer = consumer; Cursor original = this.Cursor; @@ -44,7 +44,7 @@ internal string AccessToken { get; set; } private void finishButton_Click(object sender, RoutedEventArgs e) { - var grantedAccess = this.consumer.ProcessUserAuthorization(this.requestToken, verifierBox.Text); + var grantedAccess = this.consumer.ProcessUserAuthorization(this.requestToken, this.verifierBox.Text); this.AccessToken = grantedAccess.AccessToken; DialogResult = true; Close(); diff --git a/samples/OAuthConsumerWpf/MainWindow.xaml.cs b/samples/OAuthConsumerWpf/MainWindow.xaml.cs index ae51103..e62683d 100644 --- a/samples/OAuthConsumerWpf/MainWindow.xaml.cs +++ b/samples/OAuthConsumerWpf/MainWindow.xaml.cs @@ -91,28 +91,28 @@ bool? result = auth.ShowDialog(); if (result.HasValue && result.Value) { this.googleAccessToken = auth.AccessToken; - postButton.IsEnabled = true; + this.postButton.IsEnabled = true; - XDocument contactsDocument = GoogleConsumer.GetContacts(this.google, this.googleAccessToken); + XDocument contactsDocument = GoogleConsumer.GetContacts(this.google, this.googleAccessToken, 25, 1); var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")) select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value, Email = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value }; - contactsGrid.Children.Clear(); + this.contactsGrid.Children.Clear(); foreach (var contact in contacts) { - contactsGrid.RowDefinitions.Add(new RowDefinition()); + this.contactsGrid.RowDefinitions.Add(new RowDefinition()); TextBlock name = new TextBlock { Text = contact.Name }; TextBlock email = new TextBlock { Text = contact.Email }; - Grid.SetRow(name, contactsGrid.RowDefinitions.Count - 1); - Grid.SetRow(email, contactsGrid.RowDefinitions.Count - 1); + Grid.SetRow(name, this.contactsGrid.RowDefinitions.Count - 1); + Grid.SetRow(email, this.contactsGrid.RowDefinitions.Count - 1); Grid.SetColumn(email, 1); - contactsGrid.Children.Add(name); - contactsGrid.Children.Add(email); + this.contactsGrid.Children.Add(name); + this.contactsGrid.Children.Add(email); } } } private void postButton_Click(object sender, RoutedEventArgs e) { - XElement postBodyXml = XElement.Parse(postBodyBox.Text); - GoogleConsumer.PostBlogEntry(this.google, this.googleAccessToken, blogUrlBox.Text, postTitleBox.Text, postBodyXml); + XElement postBodyXml = XElement.Parse(this.postBodyBox.Text); + GoogleConsumer.PostBlogEntry(this.google, this.googleAccessToken, this.blogUrlBox.Text, this.postTitleBox.Text, postBodyXml); } private void beginWcfAuthorizationButton_Click(object sender, RoutedEventArgs e) { @@ -125,9 +125,9 @@ bool? result = auth.ShowDialog(); if (result.HasValue && result.Value) { this.wcfAccessToken = auth.AccessToken; - wcfName.Content = CallService(client => client.GetName()); - wcfAge.Content = CallService(client => client.GetAge()); - wcfFavoriteSites.Content = CallService(client => string.Join(", ", client.GetFavoriteSites())); + this.wcfName.Content = CallService(client => client.GetName()); + this.wcfAge.Content = CallService(client => client.GetAge()); + this.wcfFavoriteSites.Content = CallService(client => string.Join(", ", client.GetFavoriteSites())); } } @@ -150,15 +150,15 @@ private void beginButton_Click(object sender, RoutedEventArgs e) { try { var service = new ServiceProviderDescription { - RequestTokenEndpoint = new MessageReceivingEndpoint(requestTokenUrlBox.Text, requestTokenHttpMethod.SelectedIndex == 0 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest), - UserAuthorizationEndpoint = new MessageReceivingEndpoint(authorizeUrlBox.Text, HttpDeliveryMethods.GetRequest), - AccessTokenEndpoint = new MessageReceivingEndpoint(accessTokenUrlBox.Text, accessTokenHttpMethod.SelectedIndex == 0 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest), + RequestTokenEndpoint = new MessageReceivingEndpoint(this.requestTokenUrlBox.Text, this.requestTokenHttpMethod.SelectedIndex == 0 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest), + UserAuthorizationEndpoint = new MessageReceivingEndpoint(this.authorizeUrlBox.Text, HttpDeliveryMethods.GetRequest), + AccessTokenEndpoint = new MessageReceivingEndpoint(this.accessTokenUrlBox.Text, this.accessTokenHttpMethod.SelectedIndex == 0 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest), TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() }, - ProtocolVersion = oauthVersion.SelectedIndex == 0 ? ProtocolVersion.V10 : ProtocolVersion.V10a, + ProtocolVersion = this.oauthVersion.SelectedIndex == 0 ? ProtocolVersion.V10 : ProtocolVersion.V10a, }; var tokenManager = new InMemoryTokenManager(); - tokenManager.ConsumerKey = consumerKeyBox.Text; - tokenManager.ConsumerSecret = consumerSecretBox.Text; + tokenManager.ConsumerKey = this.consumerKeyBox.Text; + tokenManager.ConsumerSecret = this.consumerSecretBox.Text; var consumer = new DesktopConsumer(service, tokenManager); string accessToken; @@ -181,13 +181,13 @@ return; } } - HttpDeliveryMethods resourceHttpMethod = resourceHttpMethodList.SelectedIndex < 2 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest; - if (resourceHttpMethodList.SelectedIndex == 1) { + HttpDeliveryMethods resourceHttpMethod = this.resourceHttpMethodList.SelectedIndex < 2 ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest; + if (this.resourceHttpMethodList.SelectedIndex == 1) { resourceHttpMethod |= HttpDeliveryMethods.AuthorizationHeaderRequest; } - var resourceEndpoint = new MessageReceivingEndpoint(resourceUrlBox.Text, resourceHttpMethod); + var resourceEndpoint = new MessageReceivingEndpoint(this.resourceUrlBox.Text, resourceHttpMethod); using (IncomingWebResponse resourceResponse = consumer.PrepareAuthorizedRequestAndSend(resourceEndpoint, accessToken)) { - resultsBox.Text = resourceResponse.GetResponseReader().ReadToEnd(); + this.resultsBox.Text = resourceResponse.GetResponseReader().ReadToEnd(); } } catch (DotNetOpenAuth.Messaging.ProtocolException ex) { MessageBox.Show(this, ex.Message); diff --git a/samples/OAuthConsumerWpf/OAuthConsumerWpf.csproj b/samples/OAuthConsumerWpf/OAuthConsumerWpf.csproj index 9a26bd6..e6971c0 100644 --- a/samples/OAuthConsumerWpf/OAuthConsumerWpf.csproj +++ b/samples/OAuthConsumerWpf/OAuthConsumerWpf.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -241,4 +242,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project> diff --git a/samples/OAuthServiceProvider/OAuthServiceProvider.csproj b/samples/OAuthServiceProvider/OAuthServiceProvider.csproj index c31e8bf..94e7bb3 100644 --- a/samples/OAuthServiceProvider/OAuthServiceProvider.csproj +++ b/samples/OAuthServiceProvider/OAuthServiceProvider.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -189,4 +190,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs index 5b4dd24..c80264d 100644 --- a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs +++ b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs @@ -33,7 +33,7 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { private CheckIdWindow(HostedProvider provider, IAuthenticationRequest request) { Contract.Requires(request != null); - InitializeComponent(); + this.InitializeComponent(); // Initialize the window with appropriate values. this.realmLabel.Content = request.Realm; diff --git a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs index 0fcac9c..0983637 100644 --- a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs +++ b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs @@ -53,7 +53,7 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { this.hostedProvider.ProcessRequest = this.ProcessRequest; TextWriterAppender boxLogger = log4net.LogManager.GetRepository().GetAppenders().OfType<TextWriterAppender>().FirstOrDefault(a => a.Name == "TextBoxAppender"); if (boxLogger != null) { - boxLogger.Writer = new TextBoxTextWriter(logBox); + boxLogger.Writer = new TextBoxTextWriter(this.logBox); } this.startProvider(); @@ -115,15 +115,15 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { if (!request.IsResponseReady) { var authRequest = request as IAuthenticationRequest; if (authRequest != null) { - switch (checkidRequestList.SelectedIndex) { + switch (this.checkidRequestList.SelectedIndex) { case 0: if (authRequest.IsDirectedIdentity) { string userIdentityPageBase = this.hostedProvider.UserIdentityPageBase.AbsoluteUri; - if (capitalizedHostName.IsChecked.Value) { + if (this.capitalizedHostName.IsChecked.Value) { userIdentityPageBase = (this.hostedProvider.UserIdentityPageBase.Scheme + Uri.SchemeDelimiter + this.hostedProvider.UserIdentityPageBase.Authority).ToUpperInvariant() + this.hostedProvider.UserIdentityPageBase.PathAndQuery; } string leafPath = "directedidentity"; - if (directedIdentityTrailingPeriodsCheckbox.IsChecked.Value) { + if (this.directedIdentityTrailingPeriodsCheckbox.IsChecked.Value) { leafPath += "."; } authRequest.ClaimedIdentifier = Identifier.Parse(userIdentityPageBase + leafPath, true); @@ -173,7 +173,7 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param> private void opIdentifierLabel_MouseDown(object sender, MouseButtonEventArgs e) { try { - Clipboard.SetText(opIdentifierLabel.Content.ToString()); + Clipboard.SetText(this.opIdentifierLabel.Content.ToString()); } catch (COMException ex) { MessageBox.Show(this, ex.Message, "Error while copying OP Identifier to the clipboard", MessageBoxButton.OK, MessageBoxImage.Error); } @@ -185,7 +185,7 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider { /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void ClearLogButton_Click(object sender, RoutedEventArgs e) { - logBox.Clear(); + this.logBox.Clear(); } } } diff --git a/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj b/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj index 98b451c..5ed8345 100644 --- a/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj +++ b/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> - <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode> @@ -211,4 +211,5 @@ </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdProviderMvc/OpenIdProviderMvc.csproj b/samples/OpenIdProviderMvc/OpenIdProviderMvc.csproj index 27fd42b..794a91e 100644 --- a/samples/OpenIdProviderMvc/OpenIdProviderMvc.csproj +++ b/samples/OpenIdProviderMvc/OpenIdProviderMvc.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -150,4 +151,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdProviderWebForms/OpenIdProviderWebForms.csproj b/samples/OpenIdProviderWebForms/OpenIdProviderWebForms.csproj index a78cf26..66e0f6a 100644 --- a/samples/OpenIdProviderWebForms/OpenIdProviderWebForms.csproj +++ b/samples/OpenIdProviderWebForms/OpenIdProviderWebForms.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -219,4 +220,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyMvc/OpenIdRelyingPartyMvc.csproj b/samples/OpenIdRelyingPartyMvc/OpenIdRelyingPartyMvc.csproj index a3c7b78..f8df49d 100644 --- a/samples/OpenIdRelyingPartyMvc/OpenIdRelyingPartyMvc.csproj +++ b/samples/OpenIdRelyingPartyMvc/OpenIdRelyingPartyMvc.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -160,4 +161,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebForms/MembersOnly/DisplayGoogleContacts.aspx.cs b/samples/OpenIdRelyingPartyWebForms/MembersOnly/DisplayGoogleContacts.aspx.cs index b14aba1..c95fc7c 100644 --- a/samples/OpenIdRelyingPartyWebForms/MembersOnly/DisplayGoogleContacts.aspx.cs +++ b/samples/OpenIdRelyingPartyWebForms/MembersOnly/DisplayGoogleContacts.aspx.cs @@ -18,7 +18,7 @@ this.emailLabel.Text = "unavailable"; } this.claimedIdLabel.Text = this.User.Identity.Name; - var contactsDocument = GoogleConsumer.GetContacts(Global.GoogleWebConsumer, State.GoogleAccessToken); + var contactsDocument = GoogleConsumer.GetContacts(Global.GoogleWebConsumer, State.GoogleAccessToken, 25, 1); this.RenderContacts(contactsDocument); } } diff --git a/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj index 4089d70..69c3e91 100644 --- a/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj +++ b/samples/OpenIdRelyingPartyWebForms/OpenIdRelyingPartyWebForms.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -247,4 +248,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdRelyingPartyWebFormsVB/OpenIdRelyingPartyWebFormsVB.vbproj b/samples/OpenIdRelyingPartyWebFormsVB/OpenIdRelyingPartyWebFormsVB.vbproj index 4cfb5ef..decfc20 100644 --- a/samples/OpenIdRelyingPartyWebFormsVB/OpenIdRelyingPartyWebFormsVB.vbproj +++ b/samples/OpenIdRelyingPartyWebFormsVB/OpenIdRelyingPartyWebFormsVB.vbproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -227,4 +228,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdWebRingSsoProvider/OpenIdWebRingSsoProvider.csproj b/samples/OpenIdWebRingSsoProvider/OpenIdWebRingSsoProvider.csproj index e2081c5..70ef5ac 100644 --- a/samples/OpenIdWebRingSsoProvider/OpenIdWebRingSsoProvider.csproj +++ b/samples/OpenIdWebRingSsoProvider/OpenIdWebRingSsoProvider.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -136,4 +137,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/OpenIdWebRingSsoRelyingParty/OpenIdWebRingSsoRelyingParty.csproj b/samples/OpenIdWebRingSsoRelyingParty/OpenIdWebRingSsoRelyingParty.csproj index 524ede2..36d6d14 100644 --- a/samples/OpenIdWebRingSsoRelyingParty/OpenIdWebRingSsoRelyingParty.csproj +++ b/samples/OpenIdWebRingSsoRelyingParty/OpenIdWebRingSsoRelyingParty.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -125,4 +126,5 @@ </FlavorProperties> </VisualStudio> </ProjectExtensions> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/samples/README.html b/samples/README.html index 10e0f8c..2d82ca8 100644 --- a/samples/README.html +++ b/samples/README.html @@ -4,16 +4,16 @@ <h3>Prerequisites:</h3> <ul> <li>Microsoft .NET 3.5</li> - <li>Visual Studio 2008 or IIS (Visual Studio 2005 is reported to work, however)</li> + <li>Visual Studio 2010 or IIS</li> <li>Microsoft Windows (XP or Vista, or 2003 Server or later)</li> <li>See the tools section further below for some helpful software </li> </ul> <h2>Getting the samples running</h2> <h3>Testing the relying party/provider samples with each other</h3> <p>In this scenario you can use the Personal Web Server (PWS) that is included in Visual - Studio 2008.</p> + Studio 2010.</p> <ol> - <li>Open the DotNetOpenAuth.sln or Samples.sln file in VS2008.</li> + <li>Open the DotNetOpenAuth.sln or Samples.sln file in VS2010.</li> <li>Right-click on each web project under the Samples folder and click "View in Browser" to start PWS for each web site.</li> <li>Each web project will be dynamicly assigned a port number. Find the port number @@ -32,7 +32,7 @@ You may need to get a DNS name to point at your public IP address in order for your scenario to work.</li> <li>Ensure your firewall is configured to allow inbound and outbound TCP port 80 connections.</li> - <li>Since VS2008 Personal Web Server (PWS) does not allow web requests from other servers + <li>Since VS2010 Personal Web Server (PWS) does not allow web requests from other servers (as required by OpenID relying parties trying to log into your server), testing with external relying parties requires you to use IIS to host your server.</li> </ul> @@ -43,7 +43,7 @@ requests to you on, if applicable.</li> <li>Enable anonymous access to each site.</li> </ul> - <p>Configure VS2008 to use IIS rather than PWS</p> + <p>Configure VS2010 to use IIS rather than PWS</p> <ol> <li>Right-click on one of the web projects within Solution Explorer.</li> <li>Select Property Pages.</li> diff --git a/samples/Samples.proj b/samples/Samples.proj index d076695..b1f212f 100644 --- a/samples/Samples.proj +++ b/samples/Samples.proj @@ -9,6 +9,7 @@ For creating or publishing to web sites: $(SampleWebRoot): the full physical path to where samples should be copied to, excluding $(BranchName) --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <ItemGroup> @@ -103,4 +104,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project> diff --git a/samples/Samples.sln b/samples/Samples.sln index 0a138cc..35d9e03 100644 --- a/samples/Samples.sln +++ b/samples/Samples.sln @@ -33,47 +33,6 @@ Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "InfoCardRelyingParty", "Inf VWDPort = "4490" EndProjectSection EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "OAuthConsumer", "OAuthConsumer\", "{5100F73C-3082-4B81-95DD-F443F90B8EA7}" - ProjectSection(WebsiteProperties) = preProject - TargetFrameworkMoniker = ".NETFramework,Version%3Dv3.5" - Debug.AspNetCompiler.VirtualPath = "/OAuthConsumer" - Debug.AspNetCompiler.PhysicalPath = "OAuthConsumer\" - Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\OAuthConsumer\" - Debug.AspNetCompiler.Updateable = "true" - Debug.AspNetCompiler.ForceOverwrite = "true" - Debug.AspNetCompiler.FixedNames = "false" - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.VirtualPath = "/OAuthConsumer" - Release.AspNetCompiler.PhysicalPath = "OAuthConsumer\" - Release.AspNetCompiler.TargetPath = "PrecompiledWeb\OAuthConsumer\" - Release.AspNetCompiler.Updateable = "true" - Release.AspNetCompiler.ForceOverwrite = "true" - Release.AspNetCompiler.FixedNames = "false" - Release.AspNetCompiler.Debug = "False" - VWDPort = "10335" - EndProjectSection -EndProject -Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "OAuthServiceProvider", "OAuthServiceProvider\", "{DD52C0C8-F986-495A-AAA1-090CFE2F801F}" - ProjectSection(WebsiteProperties) = preProject - TargetFrameworkMoniker = ".NETFramework,Version%3Dv3.5" - Debug.AspNetCompiler.VirtualPath = "/OAuthServiceProvider" - Debug.AspNetCompiler.PhysicalPath = "OAuthServiceProvider\" - Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\OAuthServiceProvider\" - Debug.AspNetCompiler.Updateable = "true" - Debug.AspNetCompiler.ForceOverwrite = "true" - Debug.AspNetCompiler.FixedNames = "false" - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.VirtualPath = "/OAuthServiceProvider" - Release.AspNetCompiler.PhysicalPath = "OAuthServiceProvider\" - Release.AspNetCompiler.TargetPath = "PrecompiledWeb\OAuthServiceProvider\" - Release.AspNetCompiler.Updateable = "true" - Release.AspNetCompiler.ForceOverwrite = "true" - Release.AspNetCompiler.FixedNames = "false" - Release.AspNetCompiler.Debug = "False" - VWDPort = "65169" - VWDDynamicPort = "false" - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OAuthConsumerWpf", "OAuthConsumerWpf\OAuthConsumerWpf.csproj", "{6EC36418-DBC5-4AD1-A402-413604AA7A08}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIdRelyingPartyMvc", "OpenIdRelyingPartyMvc\OpenIdRelyingPartyMvc.csproj", "{07B193F1-68AD-4E9C-98AF-BEFB5E9403CB}" @@ -108,6 +67,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenIdOfflineProvider", "Op EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "OpenIdRelyingPartyWebFormsVB", "OpenIdRelyingPartyWebFormsVB\OpenIdRelyingPartyWebFormsVB.vbproj", "{F289B925-4307-4BEC-B411-885CE70E3379}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OAuthConsumer", "OAuthConsumer\OAuthConsumer.csproj", "{9529606E-AF76-4387-BFB7-3D10A5B399AA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OAuthServiceProvider", "OAuthServiceProvider\OAuthServiceProvider.csproj", "{E135F455-0669-49F8-9207-07FCA8C8FC79}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CodeAnalysis|Any CPU = CodeAnalysis|Any CPU @@ -139,18 +102,6 @@ Global {BE7016A8-D1B9-471A-AA53-A3D0CB800D35}.Debug|Any CPU.Build.0 = Debug|Any CPU {BE7016A8-D1B9-471A-AA53-A3D0CB800D35}.Release|Any CPU.ActiveCfg = Debug|Any CPU {BE7016A8-D1B9-471A-AA53-A3D0CB800D35}.Release|Any CPU.Build.0 = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {5100F73C-3082-4B81-95DD-F443F90B8EA7}.Release|Any CPU.Build.0 = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {DD52C0C8-F986-495A-AAA1-090CFE2F801F}.Release|Any CPU.Build.0 = Debug|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.CodeAnalysis|Any CPU.ActiveCfg = CodeAnalysis|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.CodeAnalysis|Any CPU.Build.0 = CodeAnalysis|Any CPU {6EC36418-DBC5-4AD1-A402-413604AA7A08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -199,6 +150,18 @@ Global {F289B925-4307-4BEC-B411-885CE70E3379}.Debug|Any CPU.Build.0 = Debug|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Release|Any CPU.ActiveCfg = Release|Any CPU {F289B925-4307-4BEC-B411-885CE70E3379}.Release|Any CPU.Build.0 = Release|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9529606E-AF76-4387-BFB7-3D10A5B399AA}.Release|Any CPU.Build.0 = Release|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.CodeAnalysis|Any CPU.ActiveCfg = Release|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.CodeAnalysis|Any CPU.Build.0 = Release|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E135F455-0669-49F8-9207-07FCA8C8FC79}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -213,9 +176,9 @@ Global {B64A1E7E-6A15-4B91-AF13-7D48F7DA5942} = {A4059F7E-8E6F-4FA2-A1D5-1B9B46C93F82} {5C65603B-235F-47E6-B536-06385C60DE7F} = {A4059F7E-8E6F-4FA2-A1D5-1B9B46C93F82} {F289B925-4307-4BEC-B411-885CE70E3379} = {A4059F7E-8E6F-4FA2-A1D5-1B9B46C93F82} - {5100F73C-3082-4B81-95DD-F443F90B8EA7} = {812D828E-C91A-45AB-BAE9-3FC6D9560F9F} - {DD52C0C8-F986-495A-AAA1-090CFE2F801F} = {812D828E-C91A-45AB-BAE9-3FC6D9560F9F} {6EC36418-DBC5-4AD1-A402-413604AA7A08} = {812D828E-C91A-45AB-BAE9-3FC6D9560F9F} + {9529606E-AF76-4387-BFB7-3D10A5B399AA} = {812D828E-C91A-45AB-BAE9-3FC6D9560F9F} + {E135F455-0669-49F8-9207-07FCA8C8FC79} = {812D828E-C91A-45AB-BAE9-3FC6D9560F9F} {BE7016A8-D1B9-471A-AA53-A3D0CB800D35} = {9145144C-1192-41C9-9A6D-D8F6BFE350F2} EndGlobalSection EndGlobal diff --git a/samples/tools.proj b/samples/tools.proj index 94da8c8..e7d89d9 100644 --- a/samples/tools.proj +++ b/samples/tools.proj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <Target Name="Layout"> @@ -55,4 +56,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj index 7993ed5..179c825 100644 --- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj +++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> @@ -161,11 +162,5 @@ </BootstrapperPackage> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj index 596c499..f4d0bb3 100644 --- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj +++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -391,4 +392,5 @@ </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/src/DotNetOpenAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs b/src/DotNetOpenAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs index 9ba433d..e0c2de6 100644 --- a/src/DotNetOpenAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs +++ b/src/DotNetOpenAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs @@ -6,6 +6,8 @@ namespace DotNetOpenAuth.Test.Messaging.Bindings { using System; + + using DotNetOpenAuth.Configuration; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.Test.Mocks; @@ -30,10 +32,22 @@ namespace DotNetOpenAuth.Test.Messaging.Bindings { this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false); } + [TestCase] + public void VerifyFutureTimestampWithinClockSkewIsAccepted() { + this.Channel = CreateChannel(MessageProtections.Expiration); + this.ParameterizedReceiveProtectedTest(DateTime.UtcNow + DotNetOpenAuthSection.Configuration.Messaging.MaximumClockSkew - TimeSpan.FromSeconds(1), false); + } + [TestCase, ExpectedException(typeof(ExpiredMessageException))] - public void VerifyBadTimestampIsRejected() { + public void VerifyOldTimestampIsRejected() { this.Channel = CreateChannel(MessageProtections.Expiration); this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardExpirationBindingElement.MaximumMessageAge - TimeSpan.FromSeconds(1), false); } + + [TestCase, ExpectedException(typeof(ProtocolException))] + public void VerifyFutureTimestampIsRejected() { + this.Channel = CreateChannel(MessageProtections.Expiration); + this.ParameterizedReceiveProtectedTest(DateTime.UtcNow + DotNetOpenAuthSection.Configuration.Messaging.MaximumClockSkew + TimeSpan.FromSeconds(1), false); + } } } diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs index 1e0ede5..2c2da64 100644 --- a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs +++ b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs @@ -8,6 +8,7 @@ namespace DotNetOpenAuth.Test.Messaging { using System; using System.Collections.Generic; using System.Collections.Specialized; + using System.Diagnostics; using System.IO; using System.Net; using System.Text.RegularExpressions; @@ -227,5 +228,67 @@ namespace DotNetOpenAuth.Test.Messaging { string roundTripped = MessagingUtilities.Decrypt(cipher, key); Assert.AreEqual(PlainText, roundTripped); } + + /// <summary> + /// Verifies that the time-independent string equality check works accurately. + /// </summary> + [TestCase] + public void EqualsConstantTime() { + this.EqualsConstantTimeHelper(null, null); + this.EqualsConstantTimeHelper(null, string.Empty); + this.EqualsConstantTimeHelper(string.Empty, string.Empty); + this.EqualsConstantTimeHelper(string.Empty, "a"); + this.EqualsConstantTimeHelper(null, "a"); + this.EqualsConstantTimeHelper("a", "a"); + this.EqualsConstantTimeHelper("a", "A"); + this.EqualsConstantTimeHelper("A", "A"); + this.EqualsConstantTimeHelper("ab", "ab"); + this.EqualsConstantTimeHelper("ab", "b"); + } + + /// <summary> + /// Verifies that EqualsConstantTime actually has the same execution time regardless of how well a value matches. + /// </summary> + [TestCase, Category("Performance")] + public void EqualsConstantTimeIsActuallyConstantTime() { + string expected = new string('A', 5000); + string totalmismatch = new string('B', 5000); + string almostmatch = new string('A', 4999) + 'B'; + + const int Iterations = 4000; + var totalMismatchTimer = new Stopwatch(); + totalMismatchTimer.Start(); + for (int i = 0; i < Iterations; i++) { + MessagingUtilities.EqualsConstantTime(expected, totalmismatch); + } + totalMismatchTimer.Stop(); + + var almostMatchTimer = new Stopwatch(); + almostMatchTimer.Start(); + for (int i = 0; i < Iterations; i++) { + MessagingUtilities.EqualsConstantTime(expected, almostmatch); + } + almostMatchTimer.Stop(); + + const double ToleranceFactor = 0.06; + long averageTimeTicks = (totalMismatchTimer.ElapsedTicks + almostMatchTimer.ElapsedTicks) / 2; + var tolerableDifference = TimeSpan.FromTicks((long)(averageTimeTicks * ToleranceFactor)); + var absoluteDifference = TimeSpan.FromTicks(Math.Abs(totalMismatchTimer.ElapsedTicks - almostMatchTimer.ElapsedTicks)); + double actualFactor = (double)absoluteDifference.Ticks / averageTimeTicks; + Assert.IsTrue(absoluteDifference <= tolerableDifference, "A total mismatch took {0} but a near match took {1}, which is too different to be indistinguishable. The tolerable difference is {2} but the actual difference is {3}. This represents a difference of {4}%, beyond the tolerated {5}%.", totalMismatchTimer.Elapsed, almostMatchTimer.Elapsed, tolerableDifference, absoluteDifference, Math.Round(actualFactor * 100), Math.Round(ToleranceFactor * 100)); + Console.WriteLine("A total mismatch took {0} and a near match took {1}. The tolerable difference is {2}, and the actual difference is {3}. This represents a difference of {4}%, within the tolerated {5}%.", totalMismatchTimer.Elapsed, almostMatchTimer.Elapsed, tolerableDifference, absoluteDifference, Math.Round(actualFactor * 100), Math.Round(ToleranceFactor * 100)); + Console.WriteLine("The equality test execution time difference was only {0}%, within the tolerable {1}%", Math.Round(100 * actualFactor), Math.Round(ToleranceFactor * 100)); + } + + /// <summary> + /// Verifies that the time-independent string equality check works for a given pair of strings. + /// </summary> + /// <param name="value1">The first value.</param> + /// <param name="value2">The second value.</param> + private void EqualsConstantTimeHelper(string value1, string value2) { + bool expected = string.Equals(value1, value2, StringComparison.Ordinal); + Assert.AreEqual(expected, MessagingUtilities.EqualsConstantTime(value1, value2)); + Assert.AreEqual(expected, MessagingUtilities.EqualsConstantTime(value2, value1)); + } } } diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs index dd6738f..54ed37e 100644 --- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs @@ -359,7 +359,7 @@ namespace DotNetOpenAuth.Test.OAuth.ChannelElements { { "Name", "Andrew" }, { "Location", "http://hostb/pathB" }, { "Timestamp", XmlConvert.ToString(DateTime.UtcNow, XmlDateTimeSerializationMode.Utc) }, - { "realm" , "someValue" }, + { "realm", "someValue" }, }; IProtocolMessage requestMessage = this.channel.ReadFromRequest(CreateHttpRequestInfo(scheme, fields)); Assert.IsNotNull(requestMessage); diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj index 1287b61..f402c95 100644 --- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj +++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <PropertyGroup> - <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode> @@ -860,4 +860,5 @@ http://opensource.org/licenses/ms-pl.html </Target> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/src/DotNetOpenAuth/Messaging/Bindings/StandardExpirationBindingElement.cs b/src/DotNetOpenAuth/Messaging/Bindings/StandardExpirationBindingElement.cs index ddfa88a..4396c16 100644 --- a/src/DotNetOpenAuth/Messaging/Bindings/StandardExpirationBindingElement.cs +++ b/src/DotNetOpenAuth/Messaging/Bindings/StandardExpirationBindingElement.cs @@ -83,11 +83,19 @@ namespace DotNetOpenAuth.Messaging.Bindings { if (expiringMessage != null) { // Yes the UtcCreationDate is supposed to always be in UTC already, // but just in case a given message failed to guarantee that, we do it here. - DateTime expirationDate = expiringMessage.UtcCreationDate.ToUniversalTimeSafe() + MaximumMessageAge; + DateTime creationDate = expiringMessage.UtcCreationDate.ToUniversalTimeSafe(); + DateTime expirationDate = creationDate + MaximumMessageAge; if (expirationDate < DateTime.UtcNow) { throw new ExpiredMessageException(expirationDate, expiringMessage); } + // Mitigate HMAC attacks (just guessing the signature until they get it) by + // disallowing post-dated messages. + ErrorUtilities.VerifyProtocol( + creationDate <= DateTime.UtcNow + DotNetOpenAuthSection.Configuration.Messaging.MaximumClockSkew, + MessagingStrings.MessageTimestampInFuture, + creationDate); + return MessageProtections.Expiration; } diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs index e34dc03..f600330 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs +++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs @@ -322,6 +322,15 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Looks up a localized string similar to This message has a timestamp of {0}, which is beyond the allowable clock skew for in the future.. + /// </summary> + internal static string MessageTimestampInFuture { + get { + return ResourceManager.GetString("MessageTimestampInFuture", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to A non-empty string was expected.. /// </summary> internal static string NonEmptyStringExpected { diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx index d7d0b01..7f9d91b 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx +++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx @@ -312,4 +312,7 @@ <data name="EncoderInstantiationFailed" xml:space="preserve"> <value>Unable to instantiate the message part encoder/decoder type {0}.</value> </data> -</root>
\ No newline at end of file + <data name="MessageTimestampInFuture" xml:space="preserve"> + <value>This message has a timestamp of {0}, which is beyond the allowable clock skew for in the future.</value> + </data> +</root> diff --git a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs index 1860770..9dbd1b9 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth/Messaging/MessagingUtilities.cs @@ -682,6 +682,43 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Compares to string values for ordinal equality in such a way that its execution time does not depend on how much of the value matches. + /// </summary> + /// <param name="value1">The first value.</param> + /// <param name="value2">The second value.</param> + /// <returns>A value indicating whether the two strings share ordinal equality.</returns> + /// <remarks> + /// In signature equality checks, a difference in execution time based on how many initial characters match MAY + /// be used as an attack to figure out the expected signature. It is therefore important to make a signature + /// equality check's execution time independent of how many characters match the expected value. + /// See http://codahale.com/a-lesson-in-timing-attacks/ for more information. + /// </remarks> + internal static bool EqualsConstantTime(string value1, string value2) { + // If exactly one value is null, they don't match. + if (value1 == null ^ value2 == null) { + return false; + } + + // If both values are null (since if one is at this point then they both are), it's a match. + if (value1 == null) { + return true; + } + + if (value1.Length != value2.Length) { + return false; + } + + // This looks like a pretty crazy way to compare values, but it provides a constant time equality check, + // and is more resistant to compiler optimizations than simply setting a boolean flag and returning the boolean after the loop. + int result = 0; + for (int i = 0; i < value1.Length; i++) { + result |= value1[i] ^ value2[i]; + } + + return result == 0; + } + + /// <summary> /// Adds a set of HTTP headers to an <see cref="HttpResponse"/> instance, /// taking care to set some headers to the appropriate properties of /// <see cref="HttpResponse" /> diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs index fdf6e08..cb81139 100644 --- a/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOpenAuth/OAuth/ChannelElements/SigningBindingElementBase.cs @@ -273,7 +273,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { Contract.Requires<ArgumentNullException>(message != null); string signature = this.GetSignature(message); - return message.Signature == signature; + return MessagingUtilities.EqualsConstantTime(message.Signature, signature); } /// <summary> diff --git a/src/DotNetOpenAuth/OAuth/Messages/AuthorizedTokenRequest.cs b/src/DotNetOpenAuth/OAuth/Messages/AuthorizedTokenRequest.cs index 1228290..02c6c1d 100644 --- a/src/DotNetOpenAuth/OAuth/Messages/AuthorizedTokenRequest.cs +++ b/src/DotNetOpenAuth/OAuth/Messages/AuthorizedTokenRequest.cs @@ -42,7 +42,7 @@ namespace DotNetOpenAuth.OAuth.Messages { public string VerificationCode { get; set; } /// <summary> - /// Gets or sets the unauthorized Request Token used to obtain authorization. + /// Gets or sets the authorized Request Token used to obtain authorization. /// </summary> [MessagePart("oauth_token", IsRequired = true)] internal string RequestToken { get; set; } diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs index 3f4a998..30310ac 100644 --- a/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs +++ b/src/DotNetOpenAuth/OpenId/ChannelElements/SigningBindingElement.cs @@ -134,7 +134,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements { Association association = this.GetSpecificAssociation(signedMessage); if (association != null) { string signature = this.GetSignature(signedMessage, association); - if (!string.Equals(signedMessage.Signature, signature, StringComparison.Ordinal)) { + if (!MessagingUtilities.EqualsConstantTime(signedMessage.Signature, signature)) { Logger.Bindings.Error("Signature verification failed."); throw new InvalidSignatureException(message); } diff --git a/src/DotNetOpenAuth/OpenId/Identifier.cs b/src/DotNetOpenAuth/OpenId/Identifier.cs index 36ec784..305976a 100644 --- a/src/DotNetOpenAuth/OpenId/Identifier.cs +++ b/src/DotNetOpenAuth/OpenId/Identifier.cs @@ -36,7 +36,7 @@ namespace DotNetOpenAuth.OpenId { /// <summary> /// Gets the original string that was normalized to create this Identifier. /// </summary> - public string OriginalString { get; private set; } + internal string OriginalString { get; private set; } /// <summary> /// Gets the Identifier in the form in which it should be serialized. diff --git a/tools/DotNetOpenAuth.automated.props b/tools/DotNetOpenAuth.automated.props index 6037967..69e0b38 100644 --- a/tools/DotNetOpenAuth.automated.props +++ b/tools/DotNetOpenAuth.automated.props @@ -10,5 +10,6 @@ <!-- Validation controls whether extra builds are done in order to fully validate what we're distributing, even if we're not distributing the built bits (as is the case for project templates). --> <Validation Condition=" '$(Validation)' == '' ">Full</Validation> + <NUnitToolPath Condition=" '$(NUnitToolPath)' == '' ">$(ProjectRoot)tools\NUnit\bin\net-2.0</NUnitToolPath> </PropertyGroup> </Project> diff --git a/tools/DotNetOpenAuth.props b/tools/DotNetOpenAuth.props index 1d57fa6..b282db5 100644 --- a/tools/DotNetOpenAuth.props +++ b/tools/DotNetOpenAuth.props @@ -4,7 +4,6 @@ <ProductName>DotNetOpenAuth</ProductName> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v3.5</TargetFrameworkVersion> - <ProjectRoot Condition="'$(ProjectRoot)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\'))</ProjectRoot> <DropsRoot>$(ProjectRoot)drops\$(TargetFrameworkVersion)\$(Configuration)\</DropsRoot> <OutputPath>$(ProjectRoot)bin\$(TargetFrameworkVersion)\$(Configuration)\</OutputPath> <DocOutputPath>$(ProjectRoot)doc\</DocOutputPath> diff --git a/tools/NUnit/Logo.ico b/tools/NUnit/Logo.ico Binary files differnew file mode 100644 index 0000000..13c4ff9 --- /dev/null +++ b/tools/NUnit/Logo.ico diff --git a/tools/NUnit/doc/addinsDialog.html b/tools/NUnit/doc/addinsDialog.html new file mode 100644 index 0000000..af58b8f --- /dev/null +++ b/tools/NUnit/doc/addinsDialog.html @@ -0,0 +1,109 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - AddinsDialog</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Addins Dialog</h2> + +<p>The Addins Dialog is displayed using the Tools | Addins menu item on the main +menu. It lists all addins that have been found and loaded by NUnit.</p> + +<div class="screenshot-right"> + <img src="img/addinsDialog.jpg"></div> + +<h3>Addin</h3> + +<p>This column lists the name of the addin, as defined by its author. + +<h3>Status</h3> + +<p>This column shows the status of each addin. Possible values are +<ul> +<li>Unknown +<li>Enabled +<li>Disabled +<li>Loaded +<li>Error +</ul> + +<h3>Description</h3> + +<p>If the author of an addin has provided a description, it is +shown here when the addin is selected. + +<h3>Message</h3> + +<p>If the addin failed to load, its status will be shown as Error +and any error message displayed here when that addin is selected. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li id="current"><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/assemblyIsolation.html b/tools/NUnit/doc/assemblyIsolation.html new file mode 100644 index 0000000..7fb24f5 --- /dev/null +++ b/tools/NUnit/doc/assemblyIsolation.html @@ -0,0 +1,108 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - AssemblyIsolation</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>Assembly Isolation</h3> + +<p>NUnit isolates test assemblies from its own code and from one another + by use of separate AppDomains and/or Processes. + +<p>By default, NUnit loads a test assembly into a separate <b>AppDomain</b>, + while its own code runs in the primary <b>AppDomain</b>. + +<p>When multiple assemblies are run at the same time, NUnit loads them differently + depending on how they were specified. For assemblies that are part of an + NUnit project, then a single <b>AppDomain</b> is used. If the assemblies + were specified on the console runner command line, then a separate + <b>AppDomain</b> is used for each of them. + +<p>If greater separation is desired, test assemblies may be loaded into + a separate <b>Process</b> or into multiple processes. This is done + automatically by NUnit in the case where the tests are to be run under + a different runtime from the one that NUnit is currently using. + +<h3>Controlling Isolation</h3> + +<p>Beyond the NUnit default behavior, the user may control the level of isolation + through the command line or through NUnit's general settings. Process and AppDomain + isolation may also be specified as part of the settings of an NUnit project. + +<h4>Command Line</h4> + +<p>Assembly Isolation may be specified on the console runner commandline using + the <b>/process</b> and <b>/domain</b> options. See + <a href="consoleCommandLine.html">NUnit-Console Command Line Options</a> for more information. + +<h4>General Settings</h4> + +<p>The built-in NUnit defaults may be overridden using the <b>Assembly Isolation</b> + panel of the NUnit <b>Settings Dialog</b>. Settings made here are saved and become + the new default values for all executions of NUnit until changed. For more info, + see the <a href="settingsDialog.html">Settings Dialog</a> page. + +<h4>Project Settings</h4> + +<p>Isolation settings may be specified for an individual NUnit project using the + <a href="projectEditor.html">Project Editor</a>. +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li id="current"><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/assertions.html b/tools/NUnit/doc/assertions.html new file mode 100644 index 0000000..8a8073d --- /dev/null +++ b/tools/NUnit/doc/assertions.html @@ -0,0 +1,105 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Assertions</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Assertions</h2> + +<p>Assertions are central to unit testing in any of the xUnit frameworks, and NUnit + is no exception. NUnit provides a rich set of assertions as static methods of + the Assert class.</p> + +<p>If an assertion fails, the method call does not return and an error is reported. + If a test contains multiple assertions, any that follow the one that failed + will not be executed. For this reason, it's usually best to try for one + assertion per test.</p> + +<p>Each method may be called without a message, with a simple text message or with + a message and arguments. In the last case the message is formatted using the + provided text and arguments.</p> + +<h3>Two Models</h3> + +<p>Before NUnit 2.4, a separate method of the Assert class was used for each + different assertion. We call this the "Classic Model." It + continues to be supported in NUnit, since many people prefer it.</p> + +<p>Beginning with NUnit 2.4, a new "Constraint-based" model was + introduced. This approach uses a single method of the Assert class + for all assertions, passing a <a href="constraintModel.html">Constraint</a> object that specifies the test to be performed. + +<p>This constraint-based model is now used internally by NUnit + for all assertions. The methods of the classic approach have been + re-implemented on top of this new model. + + <!-- +<h4>See Also...</h4> +<ul> +<li> +</ul> +--> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li id="current"><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/attributes.html b/tools/NUnit/doc/attributes.html new file mode 100644 index 0000000..df39467 --- /dev/null +++ b/tools/NUnit/doc/attributes.html @@ -0,0 +1,107 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Attributes</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Attributes</h2> +<p>Version 1 of NUnit used the classic approach to identifying tests based on + inheritance and naming conventions. From version 2.0 on, NUnit has used custom + attributes for this purpose.</p> +<p>Because NUnit test fixtures do not inherit from a framework class, the developer + is free to use inheritance in other ways. And because there is no arbitrary + convention for naming tests, the choice of names can be entirely oriented + toward communicating the purpose of the test.</p> +<p>All NUnit attributes are contained in the NUnit.Framework namespace. Each source + file that contains tests must include a using statement for that namespace and + the project must reference the framework assembly, nunit.framework.dll.</p> +<p>Beginning with NUnit 2.4.6, NUnit's attributes are no longer sealed and any + attributes that derive from them will be recognized by NUnit. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li id="current"><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/category.html b/tools/NUnit/doc/category.html new file mode 100644 index 0000000..28064ee --- /dev/null +++ b/tools/NUnit/doc/category.html @@ -0,0 +1,283 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Category</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>CategoryAttribute (NUnit 2.2)</h3> +<p>The Category attribute provides an alternative to suites for dealing with groups + of tests. Either individual test cases or fixtures may be identified as + belonging to a particular category. Both the gui and console test runners allow + specifying a list of categories to be included in or excluded from the run. + When categories are used, only the tests in the selected categories will be + run. Those tests in categories that are not selected are not reported at all.</p> +<p>This feature is accessible by use of the /include and /exclude arguments to the + console runner and through a separate "Categories" tab in the gui. The gui + provides a visual indication of which categories are selected at any time.</p> + +<h4>Test Fixture Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + [Category("LongRunning")] + public class LongRunningTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Category("LongRunning")> + Public Class LongRunningTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [Category("LongRunning")] + public __gc class LongRunningTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Category("LongRunning") */ +public class LongRunningTests +{ + // ... +} +</pre> +</div> +<h4>Test Syntax</h4> +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] + [Category("Long")] + public void VeryLongTest() + { /* ... */ } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> + Public Class SuccessTests + <Test(), Category("Long")> Public Sub VeryLongTest() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test][Category("Long")] void VeryLongTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Category("Long") */ + public void VeryLongTest() + { /* ... */ } +} +</pre> + +</div> + +<h3>Custom Category Attributes</h3> + +<p>Beginning with <b>NUnit 2.4</b>, it is possible to define custom +attributes that derive from <b>CategoryAttribute</b> and have them +recognized by NUnit. The default protected constructor of CategoryAttribute +sets the category name to the name of your class. + +<p>Here's an example that creates a category of Critical tests. It works +just like any other category, but has a simpler syntax. A test reporting +system might make use of the attribute to provide special reports. + +<div class=code><pre> +[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] +public class CriticalAttribute : CategoryAttribute { } + +... + +[Test, Critical] +public void MyTest() +{ /*...*/ } +</pre></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li id="current"><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/codeFuncs.js b/tools/NUnit/doc/codeFuncs.js new file mode 100644 index 0000000..7acfc2f --- /dev/null +++ b/tools/NUnit/doc/codeFuncs.js @@ -0,0 +1,77 @@ +window.onload = init; + +var langElements = new Array(); + +function init() { + var els = document.getElementsByTagName( 'pre' ); + var elsLen = els.length; + var pattern = new RegExp('(^|\\s)(cs|vb|mc|js)(\\s|$)'); + for (i = 0, j = 0; i < elsLen; i++) { + if ( pattern.test(els[i].className) ) { + //els[i].style.background = "#fcc"; + langElements[j] = els[i]; + j++; + } + } + + var lang = getCookie( "lang" ); + if ( lang == null ) lang = "cs"; + showLang(lang); +} + +function getCookie(name) { + var cname = name + "="; + var dc = document.cookie; + if ( dc.length > 0 ) { + begin = dc.indexOf(cname); + if ( begin != -1 ) { + begin += cname.length; + end = dc.indexOf(";",begin); + if (end == -1) end = dc.length; + return unescape(dc.substring(begin, end) ); + } + } +} + +function setCookie(name,value,expires) { + document.cookie = name + "=" + escape(value) + "; path=/" + + ((expires == null) ? "" : "; expires=" + expires.toGMTString()); +} + +function showLang(lang) { + var pattern = new RegExp('(^|\\s)'+lang+'(\\s|$)'); + var elsLen = langElements.length; + for (i = 0; i < elsLen; i++ ) + { + var el = langElements[i]; + if ( pattern.test( el.className ) ) + el.style.display = ""; + else + el.style.display = "none"; + } + setCookie("lang",lang); +} + +function Show( id ) { + document.getElementById(id).style.display = ""; +} + +function Hide( id ) { + document.getElementById(id).style.display = "none"; +} + +function ShowCS() { + showLang('cs'); +} + +function ShowVB() { + showLang('vb'); +} + +function ShowMC() { + showLang('mc'); +} + +function ShowJS() { + showLang('js'); +} diff --git a/tools/NUnit/doc/collectionAssert.html b/tools/NUnit/doc/collectionAssert.html new file mode 100644 index 0000000..0fb941f --- /dev/null +++ b/tools/NUnit/doc/collectionAssert.html @@ -0,0 +1,175 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - CollectionAssert</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>CollectionAssert (NUnit 2.4 / 2.5)</h2> +<p>The CollectionAssert class provides a number of methods that are useful +when examining collections and their contents or for comparing two collections.</p> + +<p>The <b>AreEqual</b> overloads succeed if the two collections contain the same objects, +in the same order. <b>AreEquivalent</b> tests whether the collections contain the same +objects, without regard to order.</p> + +<p>Beginning with NUnit 2.4.6, these methods may be used on any object that +implements IEnumerable. Prior to 2.4.6, only true collections were supported. + +<div class="code" style="width: 38em"> +<pre>CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection, + Type expectedType ); +CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection, + Type expectedType, string message ); +CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection, + Type expectedType, string message, params object[] args ); + +CollectionAssert.AllItemsAreNotNull( IEnumerable collection ); +CollectionAssert.AllItemsAreNotNull( IEnumerable collection, + string message ); +CollectionAssert.AllItemsAreNotNull( IEnumerable collection, + string message, params object[] args ); + +CollectionAssert.AllItemsAreUnique( IEnumerable collection ); +CollectionAssert.AllItemsAreUnique( IEnumerable collection, + string message ); +CollectionAssert.AllItemsAreUnique( IEnumerable collection, + string message, params object[] args ); + +CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual ); +CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual, + string message ); +CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual + string message, params object[] args ); + +CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual); +CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual, + string message ); +CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual + string message, params object[] args ); + +CollectionAssert.AreNotEqual( IEnumerable expected, IEnumerable actual ); +CollectionAssert.AreNotEqual( IEnumerable expected, IEnumerable actual, + string message ); +CollectionAssert.AreNotEqual( IEnumerableon expected, IEnumerable actual + string message, params object[] args ); + +CollectionAssert.AreNotEquivalent( IEnumerable expected, + IEnumerable actual ); +CollectionAssert.AreNotEquivalent( IEnumerable expected, + IEnumerable actual, string message ); +CollectionAssert.AreNotEquivalent( IEnumerable expected, + IEnumerable actual, string message, params object[] args ); + +CollectionAssert.Contains( IEnumerable expected, object actual ); +CollectionAssert.Contains( IEnumerable expected, object actual, + string message ); +CollectionAssert.Contains( IEnumerable expected, object actual + string message, params object[] args ); + +CollectionAssert.DoesNotContain( IEnumerable expected, object actual ); +CollectionAssert.DoesNotContain( IEnumerable expected, object actual, + string message ); +CollectionAssert.DoesNotContain( IEnumerable expected, object actual + string message, params object[] args ); + +CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset ); +CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset, + string message ); +CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset, + string message, params object[] args ); + +CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset); +CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset, + string message ); +CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset, + string message, params object[] args ); + +CollectionAssert.IsEmpty( IEnumerable collection ); +CollectionAssert.IsEmpty( IEnumerable collection, string message ); +CollectionAssert.IsEmpty( IEnumerable collection, string message, + params object[] args ); + +CollectionAssert.IsNotEmpty( IEnumerable collection ); +CollectionAssert.IsNotEmpty( IEnumerable collection, string message ); +CollectionAssert.IsNotEmpty( IEnumerable collection, string message, + params object[] args ); +</pre></div> + +<p>The following methods are available beginning with NUnit 2.5 + +<div class="code" style="width: 38em"><pre> +CollectionAssert.IsOrdered( IEnumerable collection ); +CollectionAssert.IsOrdered( IEnumerable collection, string message ); +CollectionAssert.IsOrdered( IEnumerable collection, string message, + params object[] args ); + +CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer ); +CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer, + string message ); +CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer, + string message, params object[] args ); +</pre></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li id="current"><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/collectionConstraints.html b/tools/NUnit/doc/collectionConstraints.html new file mode 100644 index 0000000..8311b87 --- /dev/null +++ b/tools/NUnit/doc/collectionConstraints.html @@ -0,0 +1,325 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - CollectionConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Collection Constraints (NUnit 2.4 / 2.5)</h2> + +<p>Collection constraints perform tests that are specific to collections. + The following collection constraints are provided. Before NUnit 2.4.6, + these constraints only operated on true Collections. Beginning with 2.4.6, + they can work with any object that implements IEnumerable. + +<p>Beginning with NUnit 2.4.2, use of an improper argument type caused tests + to fail. Later releases give an error rather than a failure, so that negated + constraints will not appear to succeed. + +<p>For example, both of the following statements give an error in later releases, + but the second would have succeeded in earlier versions of NUnit. + +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; + +Assert.That( 5, Is.SubsetOf( iarray ) ); // Fails in early releases +Assert.That( 5, Is.Not.SubsetOf( iarray ) ); / +</pre></div> + +<h3>AllItemsConstraint</h3> + +<h4>Action</h4> +<p>Applies a constraint to each item in a collection, succeeding only if all of them succeed. + +<h4>Constructor</h4> +<div class="code"><pre> +AllItemsConstraint(Constraint itemConstraint) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.All... +Has.All... +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( iarray, Is.All.Not.Null ); +Assert.That( sarray, Is.All.InstanceOf<string>() ); +Assert.That( iarray, Is.All.GreaterThan(0) ); +Assert.That( iarray, Has.All.GreaterThan(0) ); +</pre></div> + +<h3>SomeItemsConstraint</h3> + +<h4>Action</h4> +<p>Applies a constraint to each item in a collection, succeeding if at least one of them succeeds. + +<h4>Constructor</h4> +<div class="code"><pre> +SomeItemsConstraint(Constraint itemConstraint) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Has.Some... +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( iarray, Has.Some.GreaterThan(2) ); +Assert.That( sarray, Has.Some.Length(1) ); +</pre></div> + +<h3>NoItemConstraint</h3> + +<h4>Action</h4> +<p>Applies a constraint to each item in a collection, succeeding only if all of them fail. + +<h4>Constructor</h4> +<div class="code"><pre> +NoItemConstraint(Constraint itemConstraint) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Has.None... +Has.No... +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( iarray, Has.None.Null ); +Assert.That( iarray, Has.No.Null ); +Assert.That( sarray, Has.None.EqualTo("d") ); +Assert.That( iarray, Has.None.LessThan(0) ); +</pre></div> + +<h3>UniqueItemsConstraint</h3> + +<h4>Action</h4> +<p>Tests that a collection contains only unique items. + +<h4>Constructor</h4> +<div class="code"><pre> +UniqueItemsConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.Unique +</pre></div> + +<h4>Example of Use</h4> +<div class="code"><pre> +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( sarray, Is.Unique ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li>?? +</ol> + +<h3>CollectionContainsConstraint</h3> + +<h4>Action</h4> +<p>Tests that a collection contains an object. + +<h4>Constructor</h4> +<div class="code"><pre> +CollectionContainsConstraint( object ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Has.Member( object ) +Contains.Item( object ) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( iarray, Has.Member(3) ); +Assert.That( sarray, Has.Member("b") ); +Assert.That( sarray, Contains.Item("c") ); +Assert.That( sarray, Has.No.Member("x") ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li>For references, <b>Has.Member</b> uses object equality to find a member in a +collection. To check for an object equal to an item the collection, use +<b>Has.Some.EqualTo(...)</b>. +</ol> + +<h3>CollectionEquivalentConstraint</h3> + +<h4>Action</h4> +<p>Tests that two collections are equivalent - that they contain +the same items, in any order. + +<h4>Constructor</h4> +<div class="code"><pre> +CollectionEquivalentConstraint( IEnumerable other ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.EquivalentTo( IEnumerable other ) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "a", "b", "c" }; + +Assert.That( new string[] { "c", "a", "b" }, Is.EquivalentTo( sarray ) ); +Assert.That( new int[] { 1, 2, 2 }, Is.Not.EquivalentTo( iarray ) ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li>To compare collections for equality, use Is.EqualTo(). +</ol> + +<h3>CollectionSubsetConstraint</h3> + +<h4>Action</h4> +<p>Tests that one collection is a subset of another. + +<h4>Constructor</h4> +<div class="code"><pre> +CollectionSubsetConstraint( ICollection ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.SubsetOf( IEnumerable ) +</pre></div> + +<h4>Example of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; + +Assert.That( new int[] { 1, 3 }, Is.SubsetOf( iarray ) ); +</pre></div> + +<h3>CollectionOrderedConstraint (NUnit 2.5)</h3> + +<h4>Action</h4> +<p>Tests that a collection is ordered. + +<h4>Constructor</h4> +<div class="code"><pre> +CollectionOrderedConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.Ordered +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Descending +...By(string propertyName) +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 }; +string[] sarray = new string[] { "c", "b", "a" }; +string[] sarray2 = new string[] ( "a", "aa", "aaa" ); + +Assert.That( iarray, Is.Ordered ); +Assert.That( sarray, Is.Ordered.Descending ); +Assert.That( sarray2, Is.Ordered.By("Length"); +</pre></div> + +<h4>Notes</h4> +<ol> +<li>Modifiers may be combined and may appear in any order. If the +same modifier is used more than once, the result is undefined. +<li>The syntax of Is.Ordered has changed from earlier betas. +</ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li id="current"><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/combinatorial.html b/tools/NUnit/doc/combinatorial.html new file mode 100644 index 0000000..d5d8eaa --- /dev/null +++ b/tools/NUnit/doc/combinatorial.html @@ -0,0 +1,125 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Combinatorial</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>CombinatorialAttribute (NUnit 2.5)</h3> + +<p>The <b>CombinatorialAttribute</b> is used on a test to specify that NUnit should + generate test cases for all possible combinations of the individual + data items provided for the parameters of a test. Since this is the + default, use of this attribute is optional. + +<h4>Example</h4> + +<p>The following test will be executed six times, as follows: +<pre> + MyTest(1, "A") + MyTest(1, "B") + MyTest(2, "A") + MyTest(2, "B") + MyTest(3, "A") + MyTest(3, "B") +</pre> +<div class="code"><pre> +[Test, Combinatorial] +public void MyTest( + [Values(1,2,3)] int x, + [Values("A","B")] string s) +{ + ... +} +</pre></div> + +<h4>See also...</h4> +<ul> +<li><a href="sequential.html">SequentialAttribute</a><li><a href="pairwise.html">PairwiseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li id="current"><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/comparisonAsserts.html b/tools/NUnit/doc/comparisonAsserts.html new file mode 100644 index 0000000..14418be --- /dev/null +++ b/tools/NUnit/doc/comparisonAsserts.html @@ -0,0 +1,269 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ComparisonAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Comparisons (NUnit 2.2.4)</h2> + +<p>The following methods test whether one object is greater than than another. + Contrary to the normal order of Asserts, these methods are designed to be + read in the "natural" English-language or mathematical order. Thus + <b>Assert.Greater( x, y )</b> asserts that x is greater than y ( x > y ). </p> + +<div class="code" style="width: 36em" > +<pre>Assert.Greater( int arg1, int arg2 ); +Assert.Greater( int arg1, int arg2, string message ); +Assert.Greater( int arg1, int arg2, string message, + object[] parms ); + +Assert.Greater( uint arg1, uint arg2 ); +Assert.Greater( uint arg1, uint arg2, string message ); +Assert.Greater( uint arg1, uint arg2, string message, + object[] parms ); + +Assert.Greater( long arg1, long arg2 ); +Assert.Greater( long arg1, long arg2, string message ); +Assert.Greater( long arg1, long arg2, string message, + object[] parms ); + +Assert.Greater( ulong arg1, ulong arg2 ); +Assert.Greater( ulong arg1, ulong arg2, string message ); +Assert.Greater( ulong arg1, ulong arg2, string message, + object[] parms ); + +Assert.Greater( decimal arg1, decimal arg2 ); +Assert.Greater( decimal arg1, decimal arg2, string message ); +Assert.Greater( decimal arg1, decimal arg2, string message, + object[] parms ); + +Assert.Greater( double arg1, double arg2 ); +Assert.Greater( double arg1, double arg2, string message ); +Assert.Greater( double arg1, double arg2, string message, + object[] parms ); + +Assert.Greater( double arg1, double arg2 ); +Assert.Greater( double arg1, double arg2, string message ); +Assert.Greater( double arg1, double arg2, string message, + object[] parms ); + +Assert.Greater( float arg1, float arg2 ); +Assert.Greater( float arg1, float arg2, string message ); +Assert.Greater( float arg1, float arg2, string message, + object[] parms ); + +Assert.Greater( IComparable arg1, IComparable arg2 ); +Assert.Greater( IComparable arg1, IComparable arg2, string message ); +Assert.Greater( IComparable arg1, IComparable arg2, string message, + object[] parms );</pre> +</div> + +<p>The following methods test whether one object is greater than or equal to another. + Contrary to the normal order of Asserts, these methods are designed to be + read in the "natural" English-language or mathematical order. Thus + <b>Assert.GreaterOrEqual( x, y )</b> asserts that x is greater than or equal to y ( x >= y ). </p> + +<div class="code" style="width: 36em" > +<pre>Assert.GreaterOrEqual( int arg1, int arg2 ); +Assert.GreaterOrEqual( int arg1, int arg2, string message ); +Assert.GreaterOrEqual( int arg1, int arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( uint arg1, uint arg2 ); +Assert.GreaterOrEqual( uint arg1, uint arg2, string message ); +Assert.GreaterOrEqual( uint arg1, uint arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( long arg1, long arg2 ); +Assert.GreaterOrEqual( long arg1, long arg2, string message ); +Assert.GreaterOrEqual( long arg1, long arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( ulong arg1, ulong arg2 ); +Assert.GreaterOrEqual( ulong arg1, ulong arg2, string message ); +Assert.GreaterOrEqual( ulong arg1, ulong arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( decimal arg1, decimal arg2 ); +Assert.GreaterOrEqual( decimal arg1, decimal arg2, string message ); +Assert.GreaterOrEqual( decimal arg1, decimal arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( double arg1, double arg2 ); +Assert.GreaterOrEqual( double arg1, double arg2, string message ); +Assert.GreaterOrEqual( double arg1, double arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( double arg1, double arg2 ); +Assert.GreaterOrEqual( double arg1, double arg2, string message ); +Assert.GreaterOrEqual( double arg1, double arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( float arg1, float arg2 ); +Assert.GreaterOrEqual( float arg1, float arg2, string message ); +Assert.GreaterOrEqual( float arg1, float arg2, string message, + object[] parms ); + +Assert.GreaterOrEqual( IComparable arg1, IComparable arg2 ); +Assert.GreaterOrEqual( IComparable arg1, IComparable arg2, string message ); +Assert.GreaterOrEqual( IComparable arg1, IComparable arg2, string message, + object[] parms );</pre> +</div> + +<p>The following methods test whether one object is less than than another. + Contrary to the normal order of Asserts, these methods are designed to be + read in the "natural" English-language or mathematical order. Thus + <b>Assert.Less( x, y )</b> asserts that x is less than y ( x < y ). </p> + +<div class="code" style="width: 36em" > +<pre>Assert.Less( int arg1, int arg2 ); +Assert.Less( int arg1, int arg2, string message ); +Assert.Less( int arg1, int arg2, string message, + object[] parms ); + +Assert.Less( uint arg1, uint arg2 ); +Assert.Less( uint arg1, uint arg2, string message ); +Assert.Less( uint arg1, uint arg2, string message, + object[] parms ); + +Assert.Less( long arg1, long arg2 ); +Assert.Less( long arg1, long arg2, string message ); +Assert.Less( long arg1, long arg2, string message, + object[] parms ); + +Assert.Less( ulong arg1, ulong arg2 ); +Assert.Less( ulong arg1, ulong arg2, string message ); +Assert.Less( ulong arg1, ulong arg2, string message, + object[] parms ); + +Assert.Less( decimal arg1, decimal arg2 ); +Assert.Less( decimal arg1, decimal arg2, string message ); +Assert.Less( decimal arg1, decimal arg2, string message, + object[] parms ); + +Assert.Less( double arg1, double arg2 ); +Assert.Less( double arg1, double arg2, string message ); +Assert.Less( double arg1, double arg2, string message, + object[] parms ); + +Assert.Less( float arg1, float arg2 ); +Assert.Less( float arg1, float arg2, string message ); +Assert.Less( float arg1, float arg2, string message, + object[] parms ); + +Assert.Less( IComparable arg1, IComparable arg2 ); +Assert.Less( IComparable arg1, IComparable arg2, string message ); +Assert.Less( IComparable arg1, IComparable arg2, string message, + object[] parms );</pre> +</div> + +<p>The following methods test whether one object is less than or equal to another. + Contrary to the normal order of Asserts, these methods are designed to be + read in the "natural" English-language or mathematical order. Thus + <b>Assert.LessOrEqual( x, y )</b> asserts that x is less than or equal to y ( x <= y ). </p> + +<div class="code" style="width: 36em" > +<pre>Assert.LessOrEqual( int arg1, int arg2 ); +Assert.LessOrEqual( int arg1, int arg2, string message ); +Assert.LessOrEqual( int arg1, int arg2, string message, + object[] parms ); + +Assert.LessOrEqual( uint arg1, uint arg2 ); +Assert.LessOrEqual( uint arg1, uint arg2, string message ); +Assert.LessOrEqual( uint arg1, uint arg2, string message, + object[] parms ); + +Assert.LessOrEqual( long arg1, long arg2 ); +Assert.LessOrEqual( long arg1, long arg2, string message ); +Assert.LessOrEqual( long arg1, long arg2, string message, + object[] parms ); + +Assert.LessOrEqual( ulong arg1, ulong arg2 ); +Assert.LessOrEqual( ulong arg1, ulong arg2, string message ); +Assert.LessOrEqual( ulong arg1, ulong arg2, string message, + object[] parms ); + +Assert.LessOrEqual( decimal arg1, decimal arg2 ); +Assert.LessOrEqual( decimal arg1, decimal arg2, string message ); +Assert.LessOrEqual( decimal arg1, decimal arg2, string message, + object[] parms ); + +Assert.LessOrEqual( double arg1, double arg2 ); +Assert.LessOrEqual( double arg1, double arg2, string message ); +Assert.LessOrEqual( double arg1, double arg2, string message, + object[] parms ); + +Assert.LessOrEqual( float arg1, float arg2 ); +Assert.LessOrEqual( float arg1, float arg2, string message ); +Assert.LessOrEqual( float arg1, float arg2, string message, + object[] parms ); + +Assert.LessOrEqual( IComparable arg1, IComparable arg2 ); +Assert.LessOrEqual( IComparable arg1, IComparable arg2, string message ); +Assert.LessOrEqual( IComparable arg1, IComparable arg2, string message, + object[] parms );</pre> +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li id="current"><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/comparisonConstraints.html b/tools/NUnit/doc/comparisonConstraints.html new file mode 100644 index 0000000..d9935e5 --- /dev/null +++ b/tools/NUnit/doc/comparisonConstraints.html @@ -0,0 +1,238 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ComparisonConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Comparison Constraints (NUnit 2.4 / 2.5)</h2> + +<p>Comparison constraints are able to test whether one value +is greater or less than another. Comparison constraints work +on numeric values, as well as other objects that implement the +<b>IComparable</b> interface or - beginning with NUnit 2.5 - +<b>IComparable<T></b>. + +<p>Beginning with NUnit 2.5, you may supply your own comparison +algorithm through the <b>Using</b> modifier. + +<h3>GreaterThanConstraint</h3> + +<h4>Action</h4> +<p>Tests that one value is greater than another. + +<h4>Constructor</h4> +<div class="code"><pre> +GreaterThanConstraint(object expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.GreaterThan(object expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That(7, Is.GreaterThan(3)); +Assert.That(myOwnObject, + Is.GreaterThan(theExpected).Using(myComparer)); +</pre></div> + +<h3>GreaterThanOrEqualConstraint</h3> + +<h4>Action</h4> +<p>Tests that one value is greater than or equal to another. + +<h4>Constructor</h4> +<div class="code"><pre> +GreaterThanOrEqualConstraint(object expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.GreaterThanOrEqualTo(object expected) +Is.AtLeast(object expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That(7, Is.GreaterThanOrEqualTo(3)); +Assert.That(7, Is.AtLeast(3)); +Assert.That(7, Is.GreaterThanOrEqualTo(7)); +Assert.That(7, Is.AtLeast(7)); +Assert.That(myOwnObject, + Is.GreaterThanOrEqualTo(theExpected).Using(myComparer)); +</pre></div> + +<h3>LessThanConstraint</h3> + +<h4>Action</h4> +<p>Tests that one value is less than another. + +<h4>Constructor</h4> +<div class="code"><pre> +LessThanConstraint(object expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.LessThan(object expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That(3, Is.LessThan(7)); +Assert.That(myOwnObject, + Is.LessThan(theExpected).Using(myComparer)); +</pre></div> + +<h3>LessThanOrEqualConstraint</h3> + +<h4>Action</h4> +<p>Tests that one value is less than or equal to another. + +<h4>Constructor</h4> +<div class="code"><pre> +LessThanOrEqualConstraint(object expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.LessThanOrEqualTo(object expected) +Is.AtMost(object expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That(3, Is.LessThanOrEqualTo(7)); +Assert.That(3, Is.AtMost(7)); +Assert.That(3, Is.LessThanOrEqualTo(3)); +Assert.That(3, Is.AtMost(3)); +Assert.That(myOwnObject, + Is.LessThanOrEqualTo(theExpected).Using(myComparer)); +</pre></div> + +<h3>RangeConstraint</h3> + +<h4>Action</h4> +<p> + +<h4>Constructor</h4> +<div class="code"><pre> +RangeConstraint(IComparable from, IComparable to) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.InRange(IComparable from, IComparable to) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +int[] iarray = new int[] { 1, 2, 3 } + +Assert.That( 42, Is.InRange(1, 100) ); +Assert.That( iarray, Is.All.InRange(1, 3) ); +Assert.That(myOwnObject, + Is.InRange(lowExpected, highExpected).Using(myComparer)); +</pre></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li id="current"><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/compoundConstraints.html b/tools/NUnit/doc/compoundConstraints.html new file mode 100644 index 0000000..a84c2e6 --- /dev/null +++ b/tools/NUnit/doc/compoundConstraints.html @@ -0,0 +1,95 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - CompoundConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Compound Constraints (NUnit 2.4)</h2> + +<p>Compound constraints are used to combine other constraints in various ways. + +<table class="constraints"> +<tr><th>Syntax Helper</th><th>Constructor</th><th>Operation</th></tr> +<tr><td>Is.Not...</td><td>NotConstraint( Constraint )</td><td>Negates or reverses the effect of a constraint</td></tr> +<tr><td>Is.All...</td><td>AllItemsConstraint( Constraint )</td><td>Tests that all members of a collection match the constraint</td></tr> +<tr><td>Constraint & Constraint</td><td>AndConstraint( Constraint, Constraint )</td><td>Tests that both of the constraints are met</td></tr> +<tr><td>Constraint | Constraint</td><td>OrConstraint( Constraint, Constraint )</td><td>Tests that at least one of the constraints is met</td></tr> +</table> + +<h4>Examples of Use</h4> + +<div class="code"><pre> +Assert.That( 2 + 2, Is.Not.EqualTo( 5 ); +Assert.That( new int[] { 1, 2, 3 }, Is.All.GreaterThan( 0 ) ); +Assert.That( 2.3, Is.GreaterThan( 2.0 ) & Is.LessThan( 3.0 ) ); +Assert.That( 3, Is.LessThan( 5 ) | Is.GreaterThan( 10 ) ); + +// Using inheritance +Expect( 2 + 2, Not.EqualTo( 5 ) ); +Expect( 2.3, GreaterThan( 2.0 ) & LessThan( 3.0 ) ); +</pre></div> +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li id="current"><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/conditionAsserts.html b/tools/NUnit/doc/conditionAsserts.html new file mode 100644 index 0000000..b79763f --- /dev/null +++ b/tools/NUnit/doc/conditionAsserts.html @@ -0,0 +1,142 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConditionAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Condition Asserts</h2> + +<p>Methods that test a specific condition are named for the condition they test and + take the value tested as their first argument and, optionally a message as the + second. The following methods are provided:</p> +<div class="code" style="width: 36em"> +<pre>Assert.IsTrue( bool condition ); +Assert.IsTrue( bool condition, string message ); +Assert.IsTrue( bool condition, string message, object[] parms ); + +Assert.True( bool condition ); +Assert.True( bool condition, string message ); +Assert.True( bool condition, string message, object[] parms ); + +Assert.IsFalse( bool condition); +Assert.IsFalse( bool condition, string message ); +Assert.IsFalse( bool condition, string message, object[] parms ); + +Assert.False( bool condition); +Assert.False( bool condition, string message ); +Assert.False( bool condition, string message, object[] parms ); + +Assert.IsNull( object anObject ); +Assert.IsNull( object anObject, string message ); +Assert.IsNull( object anObject, string message, object[] parms ); + +Assert.Null( object anObject ); +Assert.Null( object anObject, string message ); +Assert.Null( object anObject, string message, object[] parms ); + +Assert.IsNotNull( object anObject ); +Assert.IsNotNull( object anObject, string message ); +Assert.IsNotNull( object anObject, string message, object[] parms ); + +Assert.NotNull( object anObject ); +Assert.NotNull( object anObject, string message ); +Assert.NotNull( object anObject, string message, object[] parms ); + +Assert.IsNaN( double aDouble ); +Assert.IsNaN( double aDouble, string message ); +Assert.IsNaN( double aDouble, string message, object[] parms ); + +Assert.IsEmpty( string aString ); +Assert.IsEmpty( string aString, string message ); +Assert.IsEmpty( string aString, string message, + params object[] args ); + +Assert.IsNotEmpty( string aString ); +Assert.IsNotEmpty( string aString, string message ); +Assert.IsNotEmpty( string aString, string message, + params object[] args ); + +Assert.IsEmpty( ICollection collection ); +Assert.IsEmpty( ICollection collection, string message ); +Assert.IsEmpty( ICollection collection, string message, + params object[] args ); + +Assert.IsNotEmpty( ICollection collection ); +Assert.IsNotEmpty( ICollection collection, string message ); +Assert.IsNotEmpty( ICollection collection, string message, + params object[] args );</pre> +</div> + +<p>Two forms are provided for the True, False, Null and NotNull +conditions. The "Is" forms are compatible with earlier versions +of the NUnit framework, while those without "Is" are provided +for compatibility with NUnitLite. + +<p>Assert.IsEmpty and Assert.IsNotEmpty may be used to test either a string +or a collection.</p> + + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li id="current"><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/conditionConstraints.html b/tools/NUnit/doc/conditionConstraints.html new file mode 100644 index 0000000..e715c4d --- /dev/null +++ b/tools/NUnit/doc/conditionConstraints.html @@ -0,0 +1,212 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConditionConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Condition Constraints (NUnit 2.4)</h2> + +<p>ConditionConstraints test a specific condition and are named for the condition + they test. They verify that the actual value satisfies the condition. The + following condition helpers are provided. + +<h3>NullConstraint</h3> + +<h4>Action</h4> +<p>Tests that a value is Null. + +<h4>Constructor</h4> +<div class="code"><pre> +NullConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.Null +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That( anObject, Is.Null ); +Assert.That( anObject, Is.Not.Null ); +</pre></div> + +<h3>TrueConstraint</h3> + +<h4>Action</h4> +<p>Tests that a value is true. + +<h4>Constructor</h4> +<div class="code"><pre> +TrueConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.True +</pre></div> + +<h4>Example of Use</h4> +<div class="code"><pre> +Assert.That( condition, Is.True ); +</pre></div> + +<h3>FalseConstraint</h3> + +<h4>Action</h4> +<p>Tests that a value is false. + +<h4>Constructor</h4> +<div class="code"><pre> +FalseConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.False +</pre></div> + +<h4>Example of Use</h4> +<div class="code"><pre> +Assert.That( condition, Is.False ); +</pre></div> + +<h3>NaNConstraint</h3> + +<h4>Action</h4> +<p>Tests that a value is floating-point NaN. + +<h4>Constructor</h4> +<div class="code"><pre> +NaNConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.NaN +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That( aDouble, Is.NaN ); +Assert.That( aDouble, Is.Not.NaN ); +</pre></div> + +<h3>EmptyConstraint</h3> + +<h4>Action</h4> +<p>Tests that an object is an empty string, directory or collection. + +<h4>Constructor</h4> +<div class="code"><pre> +EmptyConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.Empty +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That( aString, Is.Empty ); +Assert.Thst( dirInfo, Is.Empty ); +Assert.That( collection, Is.Empty ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>EmptyConstraint</b> creates and uses either an <b>EmptyStringConstraint</b>, +<b>EmptyDirectoryConstraint</b> or <b>EmptyCollectionConstraint</b> depending on +the argument tested. +<li>A <b>DirectoryInfo</b> argument is required in order to test for an empty directory. +To test whether a string represents a directory path, you must first construct +a <b>DirectoryInfo</b>. +</ol> + +<h3>UniqueItemsConstraint</h3> + +<h4>Action</h4> +<p>Tests that an array, collection or other IEnumerable is composed +of unique items with no duplicates. + +<h4>Constructor</h4> +<div class="code"><pre> +UniqueItemsConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.Unique +</pre></div> + +<h4>Example of Use</h4> + +<div class="code"><pre> +Assert.That( collection, Is.Unique ); +</pre></div> +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li id="current"><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/configEditor.html b/tools/NUnit/doc/configEditor.html new file mode 100644 index 0000000..9265f3c --- /dev/null +++ b/tools/NUnit/doc/configEditor.html @@ -0,0 +1,103 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConfigEditor</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Configuration Editor</h2> + +<p>The Configuration Editor is displayed using the Project | Configuration | Edit… menu item and +supports the following operations:</p> + +<div class="screenshot-right"> + <img src="img/configEditor.jpg"></div> + +<h3>Remove</h3> +<p>Remove the selected configuration. If it was +the active config, then the next one in the list +is made active.</p> + +<h3>Rename</h3> +<p>Rename the selected configuration.</p> + +<h3>Add…</h3> +<p>Add a new configuration. The Add +Configuration dialog allows specifying an +existing configuration to use as a template.</p> + +<h3>Make Active</h3> +<p>Makes the selected configuration active.</p> + +<h3>Close</h3> +<p>Exits the configuration editor</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li id="current"><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/configFiles.html b/tools/NUnit/doc/configFiles.html new file mode 100644 index 0000000..2d38b8d --- /dev/null +++ b/tools/NUnit/doc/configFiles.html @@ -0,0 +1,159 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConfigFiles</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Configuration Files</h2> + +<p>NUnit uses configuration files for the test runner executable – either nunit-console.exe or +nunitgui.exe – as well as for the tests being run. Only settings that pertain to NUnit itself should be in +the nunit-console.exe.config and nunit-gui.exe.config, while those that pertain to your own +application and tests should be in a separate configuration file.</p> + +<h3>NUnit Configuration Files</h3> + +<p>One main purpose of the nunit-console and nunit-gui config files is to allow +NUnit to run with various versions of the .NET framework. NUnit is built using +versions 1.1 and 2.0 of the framework. The two builds are provided as separate +downloads and either build can be made to run against other versions of the CLR.</p> + +<p>As delivered, the <startup> section of each config file is commented out, +causing NUnit to run with the version of .NET used to build it. If you uncomment +the <startup> section, the entries there control the order in which alternate +framework versions are selected.</p> + +<h3>Test Configuration File</h3> + +<p>When a configuration file is used to provide settings or to control the environment in which a test +is run, specific naming conventions must be followed.</p> + +<p>If a single assembly is being loaded, then the configuration file is given the name of the assembly +file with the config extension. For example, the configuration file used to run nunit.tests.dll must +be named nunit.tests.dll.config and located in the same directory as the dll.</p> + +<p>If an NUnit project is being loaded into a single AppDomain, the configuration file uses the +name of the project file with the extension <i>changed</i> to config. For example, the project +AllTests.nunit would require a configuration file named AllTests.config, located in the same +directory as AllTests.nunit. The same rule is followed when loading Visual Studio projects or solutions.</p> + +<blockquote> +<p><b>Note:</b> The above only applies if a single AppDomain is being used. If an NUnit +project is loaded using a separate AppDomain for each assembly, then the individual +configuration files for each of the assemblies are used. +</blockquote> + +<p>Generally, you should be able to simply copy your application config file and rename it as +described above.</p> + +<p>It is also possible to effect the behavior of NUnit by adding special sections +to the test config file. A config file using these sections might look like this: + +<div class="code" style="width: 36em"> +<pre> +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <configSections> + <sectionGroup name="NUnit"> + <section name="TestCaseBuilder" + type="System.Configuration.NameValueSectionHandler"/> + <section name="TestRunner" + type="System.Configuration.NameValueSectionHandler"/> + </sectionGroup> + </configSections> + + <NUnit> + <TestCaseBuilder> + <add key="OldStyleTestCases" value="false" /> + </TestCaseBuilder> + <TestRunner> + <add key="ApartmentState" value="MTA" /> + <add key="ThreadPriority" value="Normal" /> + <add key="DefaultLogThreshold" value="Error" /> + </TestRunner> + </NUnit> + + ... + +</configuration> +</pre> +</div> + +<p>The entries in the above file are all +set to default values. The meaning of each setting is as follows: + +<h4>OldStyleTestCases</h4> +<p>If set to "true" NUnit will recognize methods beginning +"test..." as tests. The prefix is case insensitive. + +<h4>ApartmentState</h4> +<p>Sets the apartment state for the thread used to run tests. + +<h4>ThreadPriority</h4> +<p>Sets the thread priority for the test thread. + +<h4>DefaultLogThreshold</h4> +<p>Sets the level for logging captured by NUnit. In the +current version only log4net logging is captured, so the +level must be one that is defined by log4net. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li id="current"><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/consoleCommandLine.html b/tools/NUnit/doc/consoleCommandLine.html new file mode 100644 index 0000000..699ab1d --- /dev/null +++ b/tools/NUnit/doc/consoleCommandLine.html @@ -0,0 +1,306 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConsoleCommandLine</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit-Console Command Line Options</h2> +<p>The console interface has a few additional options compared to the forms + interface. The command line must always specify one or more file names. The + console interface always creates an XML representation of the test results. + This file by default is called TestResult.xml and is placed in the working + directory.</p> +<p><b>Note:</b> By default the nunit-console program is not added to your path. You + must do this manually if this is the desired behavior.</p> +<p><b>Note:</b> Under the Windows operating system, options may be prefixed by either + a forward slash or a hyphen. Under Linux, a hyphen must be used. Options that + take values may use an equal sign, a colon or a space to separate the option + from its value.</p> +<h4>Specifying an Assembly</h4> +<p>The console program must always have an assembly or project specified. To run +the tests contained in the nunit.tests.dll use the following command:</p> +<pre class="programtext"> nunit-console nunit.tests.dll</pre> + +<p>To run the tests in nunit.tests.dll through the Visual Studio project, use:</p> + <pre class="programtext"> nunit-console nunit.tests.csproj</pre> + +<p>To run the same tests through an NUnit test project you have defined, use:</p> + <pre class="programtext"> nunit-console nunit.tests.nunit</pre> + +<h4>Specifying an Assembly and a Test to be Run</h4> +<p>You may specify a test to be run by proviig the full name of the test along +with the containing assembly. For example to run NUnit.Tests.AssertionTests +in the nunit.tests assembly use the following command: +<pre class="programtext"> nunit-console /run:NUnit.Tests.AssertionTests nunit.tests.dll</pre> + +<p>The name of the test to be run may be that of a test case, test fixture or +a namespace. Unlike the <b>/fixture</b> option, this option affects the running +rather than the loading of the tests. Consequently it supports much broader use, +including situations involving SetUpFixtures, which are not run if the class +in question is not loaded. You should use <b>/run</b> in lieu of <b>/fixture</b> +in most cases. + +<h4>Specifying an Assembly and a Fixture to be Loaded</h4> +<p>When specifying a fixture, you must give the full name of the test fixture + along with the containing assembly. For example, to load the + NUnit.Tests.AssertionTests in the nunit.tests.dll assembly use the following + command: + <pre class="programtext"> nunit-console /fixture:NUnit.Tests.AssertionTests nunit.tests.dll</pre> +</p> +<p>The name specified after the <b>/fixture</b> option may be that of a TestFixture + class, a legacy suite (using the Suite property ) or a namespace. If a + namespace is given, then all fixtures under that namespace are loaded.</p> +<p>This option is provided for backward compatibility. In most cases, you will +be better served by using the <b>/run</b> option. + +<h4>Specifying the .NET Framework Version</h4> + +<p>Most applications are written to run under a specific version of the CLR. +A few are designed to operate correctly under multiple versions. In either case, +it is important to be able to specify the CLR version to be used for testing.</p> + +<p>Prior to version 2.5, it was necessary to run the console program itself using +the CLR version under which you wanted to run tests. This was done either by +editing the nunit-console.exe.config file or by setting the COMPLUS_Version +environment variable before running the program. + +<p>Under NUnit 2.5 and later versions, you may still use either of these approaches, +but a simpler method is available. + +<p>The <b>/framework</b> option allows you to specify the version of the runtime + to be used in executing tests. If that version specified is different from the + one being used by NUnit, the tests are run in a separate process. For example, + you may enter + <pre class="programtext"> nunit-console myassembly.dll /framework:net-1.1</pre> +</p> + +<p>This command will run tests under .NET 1.1 even if you are running the .NET 2.0 + build of the nunit-console. Beginning with version 2.5.3, all versions of .NET + through 4.0 as well as Mono profiles 1.0, 2.0 and 3.5 are supported. + +<h4>Specifying Test Categories to Include or Exclude</h4> +<p>NUnit provides CategoryAttribute for use in marking tests as belonging to + one or more categories. Categories may be included or excluded in a test run + using the <b>/include</b> and <b>/exclude</b> options. The following command + runs only the tests in the BaseLine category: + <pre class="programtext"> nunit-console myassembly.dll /include:BaseLine</pre> +</p> +<p>The following command runs all tests <b>except</b> those in the Database + category: + <pre class="programtext"> nunit-console myassembly.dll /exclude:Database</pre> +</p> +<p> +Multiple categories may be specified on either option, by using commas to +separate them. +<p><b>Notes:</b> Beginning with NUnit 2.4, the /include and /exclude options may + be combined on the command line. When both are used, all tests with the included + categories are run except for those with the excluded categories.</p> + +<p>Beginning with NUnit 2.4.6, you may use a <b>Category Expression</b> with either +of these options: +<dl> + <dt>A|B|C + <dd>Selects tests having any of the categories A, B or C. + <dt>A,B,C + <dd>Selects tests having any of the categories A, B or C. + <dt>A+B+C + <dd>Selects only tests having all three of the categories assigned + <dt>A+B|C + <dd>Selects tests with both A and B OR with category C. + <dt>A+B-C + <dd>Selects tests with both A and B but not C. + <dt>-A + <dd>Selects tests not having category A assigned + <dt>A+(B|C) + <dd>Selects tests having both category A and either of B or C +</dl> +<p>The comma operator is equivalent to | but has a higher precendence. Order +of evaluation is as follows: +<ol> +<li>Unary exclusion operator (-) +<li>High-precendence union operator (,) +<li>Intersection and set subtraction operators (+ and binary -) +<li>Low-precedence union operator (|) +</ol> + +<p><b>Note:</b> Because the operator characters have special meaning, +you should avoid creating a category that uses any of them in it's name. +For example, the category "db-tests" could not be used on the command +line, since it appears to means "run category db, except for category tests." +The same limitation applies to characters that have special meaning for +the shell you are using. + +<p>For a clear understanding of how category + selection works, review the documentation for both the + <a href="category.html">Category Attribute</a> and the + <a href="explicit.html">Explicit Attribute</a>.</p> +<h4>Redirecting Output</h4> +<p>Output created by the test, which is normally shown on the console, may be + redirected to a file. The following command redirects standard output to the + file TestResult.txt: + <pre class="programtext"> nunit-console nunit.tests.dll /out:TestResult.txt</pre> +</p> +<p>The following command redirects standard error output to the StdErr.txt file. + <pre class="programtext"> nunit-console nunit.tests.dll /err:StdErr.txt</pre> +</p> + +<p><b>Note:</b>This option only redirects output produced <b>by the tests</b>, + together with selected NUnit output that is interspersed with the test output. + It does not redirect <b>all</b> console output. If you want to redirect <b>all</b> + output to a file, you should use command line redirection as supported by the + shell you are using. This option exists for the purpose of separating test + output from other output, such as the NUnit summary report. + +<h4>Labeling Test Output</h4> +<p>The output from each test normally follows right after that of the preceding + test. You may use the <b>/labels</b> option to cause an identifying label to be + displayed at the start of each test case.</p> +<h4>Specifying the XML file name</h4> +<p>As stated above, the console program always creates an XML representation of the + test results. To change the name of the output file to + "console-test.xml" use the following command line option: + <pre class="programtext"> nunit-console /xml:console-test.xml nunit.tests.dll</pre> +</p> +<p><b>Note:</b> For additional information see the XML schema for the test results. + This file is in the same directory as the executable and is called + <a href="files/Results.xsd">Results.xsd</a>. + +<h4>Specifying which Configuration to run</h4> +<p>When running tests from a Visual Studio or NUnit project, the first + configuration found will be loaded by default. Usually this is Debug. The + configuration loaded may be controlled by using the <b>/config</b> switch. The + following will load and run tests for the Release configuration of + nunit.tests.dll. + <pre class="programtext"> nunit-console nunit.tests.csproj /config:Release</pre> +</p> +<p><b>Note:</b> This option has no effect when loading an assembly directly.</p> +<h4>Specifying Multiple Assemblies</h4> +<p>You may run tests from multiple assemblies in one run using the console + interface even if you have not defined an NUnit test project file. The + following command would run a suite of tests contained in assembly1.dll, + assembly2.dll and assembly3.dll. + <pre class="programtext"> nunit-console assembly1.dll assembly2.dll assembly3.dll</pre> +</p> +<p><b>Notes:</b> You may specify multiple assemblies, but not multiple NUnit or + Visual Studio projects on the command line. Further, you may not specify an + NUnit or Visual Studio project together with a list of assemblies.</p> +<p>Beginning with NUnit 2.4, the console loads multiple assemblies specified + in this way into separate AppDomains by default. You may provide a separate + config file for each assembly. You may override the default by use of the + <b>/domain</b> option. +<p>Beginning with NUnit 2.4, the <b>/fixture</b> + option, when used with multiple assemblies, will run tests matching the + fixture name in all the assemblies. In earlier versions, only the first + test found was executed.</p> +<h4>Controlling the Use of Processes</h4> +<p>The <b>/process</b> option controls how NUnit loads tests in processes. The + following values are recognized. + <dl style="margin-left: 2em"> + <dt><b>Single</b> + <dd>All the tests are run in the nunit-console process. This is the default. + <dt><b>Separate</b> + <dd>A separate process is created to run the tests. + <dt><b>Multiple</b> + <dd>A separate process is created for each test assembly, whether specified + on the command line or listed in an NUnit project file. + </dl> +<h4>Controlling the Use of AppDomains</h4> +<p>The <b>/domain</b> option controls of the creation of AppDomains for running tests. + The following values are recognized:</p> + <dl style="margin-left: 2em"> + <dt><b>None</b> + <dd>No domain is created - the tests are run in the primary domain. This normally + requires copying the <b>NUnit</b> assemblies into the same directory as your tests. + <dt><b>Single</b> + <dd>A test domain is created - this is how NUnit worked prior to version 2.4 + <dt><b>Multiple</b> + <dd>A separate test domain is created for each assembly + </dl> +<p>The default is to use multiple domains if multiple assemblies are listed on + the command line. Otherwise a single domain is used.</p> + +<h4>Specifying a Default Timeout Value</h4> +<p>The <b>/timeout</b> option takes an int value representing the default timeout +to be used for test cases in this run. If any test exceeds the timeout value, +it is cancelled and reported as an error. The default value may be overridden +for selected tests by use of <b>TimeoutAttribute</b>. + +<p><b>Note:</b> If you do not use this option, no timeout is set and tests +may run for any amount of time. + +<h4>Other Options</h4> +<p>The <b>/noshadow</b> option disables shadow copying of the assembly in order to + provide improved performance.</p> +<p>The <b>/nothread</b> option suppresses use of a separate thread for running the + tests and uses the main thread instead.</p> +<p>The <b>/wait</b> option causes the program to wait for user input before + exiting. This is useful when running nunit-console from a shortcut.</p> +<p>The <b>/xmlconsole</b> option displays raw XML output on the console rather than + transforming it. This is useful when debugging problems with the XML format.</p> +<p>The <b>/nologo</b> option disables display of the copyright information at the + start of the program.</p> +<p>The <b>/help</b> or <b>/?</b> option displays a brief help message</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<ul> +<li id="current"><a href="consoleCommandLine.html">Command-Line</a></li> +</ul> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/constraintModel.html b/tools/NUnit/doc/constraintModel.html new file mode 100644 index 0000000..962b6a6 --- /dev/null +++ b/tools/NUnit/doc/constraintModel.html @@ -0,0 +1,166 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ConstraintModel</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Constraint-Based Assert Model (NUnit 2.4)</h2> + +<p>The constraint-based Assert model uses a single method of the Assert class + for all assertions. The logic necessary to carry out each assertion is + embedded in the constraint object passed as the second parameter to that + method. + +<p>Here's a very simple assert using the constraint model: +<pre> Assert.That( myString, Is.EqualTo("Hello") );</pre> + +<p>The second argument in this assertion uses one of NUnit's <b>syntax helpers</b> +to create an <b>EqualConstraint</b>. The same assertion could also be made in this form: +<pre> Assert.That( myString, new EqualConstraint("Hello") );</pre> + +<p>Using this model, all assertions are made using one of the forms of the + Assert.That() method, which has a number of overloads... + +<div class="code" style="width: 36em"> +<pre> +Assert.That( object actual, IResolveConstraint constraint ) +Assert.That( object actual, IResolveConstraint constraint, + string message ) +Assert.That( object actual, IResolveConstraint constraint, + string message, object[] parms ) + +Assert.That( ActualValueDelegate del, IResolveConstraint constraint ) +Assert.That( ActualValueDelegate del, IResolveConstraint constraint, + string message ) +Assert.That( ActualValueDelegate del, IResolveConstraint constraint, + string message, object[] parms ) + +Assert.That<T>( ref T actual, IResolveConstraint constraint ) +Assert.That<T>( ref T actual, IResolveConstraint constraint, + string message ) +Assert.That<T>( ref T actual, IResolveConstraint constraint, + string message, object[] parms ) + +Assert.That( bool condition ); +Assert.That( bool condition, string message ); +Assert.That( bool condition, string message, object[] parms ); + +Assert.That( TestDelegate del, IResolveConstraint constraint ); +</pre> +</div> + +<p>If you derive your test fixture class from <b>AssertionHelper</b>, the +Expect() method may be used in place of Assert.That()... + +<div class="code" style="width: 36em"> +<pre> +Expect( object actual, IResolveConstraint constraint ) +Expect( object actual, IResolveConstraint constraint, + string message ) +Expect( object actual, IResolveConstraint constraint, + string message, object[] parms ) + +Expect( ActualValueDelegate del, IResolveConstraint constraint ) +Expect( ActualValueDelegate del, IResolveConstraint constraint, + string message ) +Expect( ActualValueDelegate del, IResolveConstraint constraint, + string message, object[] parms ) + +Expect<T>( ref T actual, IResolveConstraint constraint ) +Expect<T>( ref T actual, IResolveConstraint constraint, + string message ) +Expect<T>( ref T actual, IResolveConstraint constraint, + string message, object[] parms ) + +Expect( bool condition ); +Expect( bool condition, string message ); +Expect( bool condition, string message, object[] parms ); + +Expect( TestDelegate del, IResolveConstraint constraint ); +</pre> +</div> + +<p>The overloads that take a bool work exactly like Assert.IsTrue. + +<p>For overloads taking a constraint, the argument must be a object implementing + the <b>IConstraint</b> interface, which supports performing a test + on an actual value and generating appropriate messages. This interface + is described in more detail under + <a href="customConstraints.html">Custom Constraints</a>. + +<p>NUnit provides a number of constraint classes similar to the <b>EqualConstraint</b> + used in the example above. Generally, these classes may be used directly or + through a syntax helper. Test fixture classes inheriting from <b>AssertionHelper</b> + are able to use shorter forms. The valid forms are described on the pages related to + each constraint. Note that the menu items listed to the right generally reflect the + names of the syntax helpers. + +<p><b>See also:</b> the +<a href="classicModel.html">classic model</a> of assertions. + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li id="current"><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/contextMenu.html b/tools/NUnit/doc/contextMenu.html new file mode 100644 index 0000000..bcc7442 --- /dev/null +++ b/tools/NUnit/doc/contextMenu.html @@ -0,0 +1,116 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ContextMenu</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Context Menu</h2> + +<p>The context menu is displayed when one of the tree nodes is right-clicked.</p> + +<h4>Run</h4> +<p>Runs the selected test - disabled if a test is running.</p> + +<h4>Run All</h4> +<p>Runs all the tests.</p> + +<h4>Run Failed</h4> +<p>Runs only the tests that failed on the previous run.</p> + +<h4>Show Checkboxes</h4> +<p>Turns the display of checkboxes in the tree on or off. The checkboxes may + be used to select multiple tests for running.</p> + +<h4>Expand</h4> +<p>Expands the selected test node – invisible if the node is expanded or has no children.</p> + +<h4>Collapse</h4> +<p>Collapses the selected test node – invisible if the node is collapsed or has no children.</p> + +<h4>Expand All</h4> +<p>Expands all nodes of the tree.</p> + +<h4>Collapse All</h4> +<p>Collapses all nodes in the tree to the root.</p> + +<h4>Load Fixture</h4> +<p>Reloads only the currently selected fixture or namespace. The fixture, +once loaded, remains in effect through any subsequent reloads. This generally +results in substantial reduction in load time.</p> + +<h4>Clear Fixture</h4> +<p>Reloads all the tests, clearing the currently loaded fixture.</p> + +<h4>Properties</h4> +<p>Displays the <a href="testProperties.html">Test Properties</a> for the selected test node.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li id="current"><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/culture.html b/tools/NUnit/doc/culture.html new file mode 100644 index 0000000..f16b565 --- /dev/null +++ b/tools/NUnit/doc/culture.html @@ -0,0 +1,273 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Culture</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<style><!-- +div.code { width: 34em } +--></style> + +<h3>CultureAttribute (NUnit 2.4.2)</h3> +<p>The Culture attribute is used to specify cultures for which a test or fixture + should be run. It does not affect the culture setting, but merely uses it to + determine whether to run the test. If you wish to change the culture when + running a test, use the SetCulture attribute instead.</p> + +<p>If the specified culture requirements for a test are not met it is skipped. + In the gui, the tree node for the test remains gray and the status bar color is + not affected.</p> + +<p>One use of the Culture attribute is to provide alternative tests under different +cultures. You may specify either specific cultures, like "en-GB" or neutral +cultures like "de".</p> + +<h4>Test Fixture Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + [Culture("fr-FR")] + public class FrenchCultureTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Culture("fr-FR")> + Public Class FrenchCultureTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [Culture("fr-FR")] + public __gc class FrenchCultureTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Culture("fr-FR") */ +public class FrenchCultureTests +{ + // ... +} +</pre> +</div> +<h4>Test Syntax</h4> +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] + [Culture(Exclude="en,de")] + public void SomeTest() + { /* ... */ } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> + Public Class SuccessTests + <Test(), Culture(Exclude="en,de")> Public Sub SomeTest() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test][Culture(Exclude="en,de")] void SomeTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Culture(Exclude=en,de") */ + public void SomeTest() + { /* ... */ } +} +</pre> + +</div> + +<h4>See also...</h4> +<ul> +<li><a href="setCulture.html">SetCultureAttribute</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li id="current"><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/customConstraints.html b/tools/NUnit/doc/customConstraints.html new file mode 100644 index 0000000..801843e --- /dev/null +++ b/tools/NUnit/doc/customConstraints.html @@ -0,0 +1,112 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - CustomConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Custom Constraints (NUnit 2.4 / 2.5)</h2> + +<p>You can implement your own custom constraints by creating a class that +inherits from the <b>Constraint</b> abstract class, which supports performing a +test on an actual value and generating appropriate messages. The class includes +two abstract methods, which you must override and four virtual methods with +default implementation that may be overridden as needed: + +<div class="code" style="width: 36em"> +<pre>public abstract class Constraint +{ + ... + public abstract bool Matches( object actual ); + public virtual bool Matches( ActualValueDelegate del ); + public virtual bool Matches<T>( ref T actual ); + public abstract void WriteDescriptionTo( MessageWriter writer ); + public virtual void WriteMessageTo( MessageWriter writer ); + public virtual void WriteActualValueTo( MessageWriter writer ); + ... +}</pre> +</div> + +<p>Your derived class should save the actual argument to Matches in the protected +field actual for later use. + +<p>The MessageWriter abstract class is implemented in the framework by +TextMessageWriter. Examining the source for some of the builtin constraints +should give you a good idea of how to use it if you have special formatting +requirements for error messages. + +<h3>Custom Constraint Syntax</h3> + +<p>NUnit includes classes that implement a special constraint syntax, +allowing you to write things like... + +<div class="code"> +<pre>Assert.That( myArray, Is.All.InRange(1,100) );</pre> +</div> + +<p>Of course, the NUnit constraint syntax will not be aware of your +custom constraint unless you modify NUnit itself. As an alternative, +you may use the <b>Matches(Constraint)</b> syntactic element in order +to write code like... + +<div class="code"> +<pre>MyConstraint myConstraint = new MyConstraint(); +Assert.That( myArray, Has.Some.Matches(myConstraint) );</pre> +</div> + + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li id="current"><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/datapoint.html b/tools/NUnit/doc/datapoint.html new file mode 100644 index 0000000..814f499 --- /dev/null +++ b/tools/NUnit/doc/datapoint.html @@ -0,0 +1,142 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Datapoint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>DatapointAttribute / DatapointsAttribute (NUnit 2.5) (Experimental)</h3> + +<p>The <b>Datapoint</b> and <b>Datapoints</b> attributes are used + to provide data for <b>Theories</b> and are ignored for ordinary + tests - including tests with parameters. + +<h4>DataPointAttribute</h4> + +<p>When a Theory is loaded, NUnit creates arguments for each + of its parameters by using any fields of the same type + as the parameter annotated with the <b>DatapointAttribute</b>. + Fields must be members of the class containing the Theory + and their Type must exactly match the argument for which + data is being supplied. + +<h4>DataPointsAttribute</h4> + +<p>In addition to specifying individual datapoints, collections of + datapoints may be provided by use of the <b>DatapointsAttribute</b> + - note the spelling. This attribute may be placed on methods or + properties in addition to fields. The returned value must be + either an array of the required type or (beginning with NUnit + 2.5.5) an <b>IEnumerable<T></b> returning an enumeration + of the required type. The data Type must exactly match the argument + for which data is being supplied. + +<h4>Automatically Supplied Datapoints</h4> + +<p>It is normally not necessary to specify datapoints for + <b>boolean</b> or <b>enum</b> arguments. Beginning with + version 2.5.4, NUnit automatically supplies values of <b>true</b> + and <b>false</b> for <b>boolean</b> arguments and will supply all + defined values of any enumeration. + +<p>If for some reason you don't wish to use all possible values, you + can override this behavior by supplying your own datapoints. If you + supply any datapoints for an argument, automatic datapoint generation + is suppressed. + +<h4>Example</h4> + +<p>For an example of use, see <a href="theory.html">TheoryAttribute</a>. + +<h4>See also...</h4> + +<ul> +<li><a href="theory.html">TheoryAttribute</a><li><a href="parameterizedTests.html">Parameterized Tests</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li id="current"><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/datapointProviders.html b/tools/NUnit/doc/datapointProviders.html new file mode 100644 index 0000000..151813d --- /dev/null +++ b/tools/NUnit/doc/datapointProviders.html @@ -0,0 +1,124 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - DatapointProviders</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>DataPointProviders (NUnit 2.5)</h3> + +<h4>Purpose</h4> +<p>DataPointProviders are used to supply data for an individual parameter +of a parameterized test method. + +<h4>Extension Point</h4> +<p>Addins use the host to access this extension point by name: + +<pre> + IExtensionPoint listeners = host.GetExtensionPoint( "DataPointProviders" );</pre> + +<h4>Interface</h4> +<p>The extension object passed to Install must implement either the + <b>IDataPointProvider</b> or the <b>IDataPointProvider2</b> interface: + +<pre> + public interface IDataPointProvider + { + bool HasDataFor( ParameterInfo parameter ); + IEnumerable GetDataFor( ParameterInfo parameter ); + } + + public interface IDataPointProvider2 : IDatapointProvider + { + bool HasDataFor( ParameterInfo parameter, Test parentSuite ); + IEnumerable GetDataFor( ParameterInfo parameter, Test parentSuite ); + } +</pre> + +<p>NUnit will call <b>IDataPointProvider2</b> if it is available. Otherwise + <b>IDataPointProvider</b> will be used. + +<p>The <b>HasDataFor</b> method should return true if the provider is able to + supply data for the specified parameter. If a provider only wants to be used + on certain types of tests, it can examine the supplied ParameterInfo and + its associated MethodInfo and Type and/or the parent test suite. + +<p>The <b>GetDataFor</b> method should return a list of individual values to + use for the supplied parameter in running the test. + +<h4>Notes:</h4> + +<ol> +<li>Most providers will delegate one of the interface implementations + to the other if they implement both. +<li>DataPointProviders that use data from the fixture class should use + <b>IDataPointProvider2</b> interface so that they are able to access any + arguments supplied for constructing the fixture object. +<li>Providers that acquire data from outside the fixture will usually + be able to work with <b>IDataPointProvider</b> alone. +<li>The <b>IDataPointProvider2</b> interface was added in the NUnit 2.5.1 release. +</ol> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li id="current"><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/delayedConstraint.html b/tools/NUnit/doc/delayedConstraint.html new file mode 100644 index 0000000..64320e9 --- /dev/null +++ b/tools/NUnit/doc/delayedConstraint.html @@ -0,0 +1,93 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - DelayedConstraint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Delayed Constraint (NUnit 2.5)</h2> + +<p><b>DelayedConstraint</b> delays the application of another constraint until a certain + amount of time has passed. In it's simplest form, it replaces use of a Sleep + in the code but it also supports polling, which may allow use of a longer + maximum time while still keeping the tests as fast as possible. + +<p>The <b>After</b> modifier is permitted on any constraint, and the delay applies to + the entire expression up to the point where <b>After</b> appears. + +<p>Use of a <b>DelayedConstraint</b> with a value argument makes no sense, since + the value will be extracted at the point of call. It's intended use is with + delegates and references. If a delegate is used with polling, it may be called + multiple times so only methods without side effects should be used in this way. + +<table class="constraints"> +<tr><th>Syntax Helper</th><th>Constructor</th><th>Operation</th></tr> +<tr><td>After(int)</td><td>DelayedConstraint(Constraint, int)</td></td><td>tests that a constraint is satisfied after a delay.</tr> +<tr><td>After(int, int)</td><td>DelayedConstraint(Constraint, int, int)</td></td><td>tests that a constraint is satisfied after a delay using polling.</tr> +</table> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li id="current"><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/description.html b/tools/NUnit/doc/description.html new file mode 100644 index 0000000..9cd34e4 --- /dev/null +++ b/tools/NUnit/doc/description.html @@ -0,0 +1,196 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Description</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>Description (NUnit 2.4)</h3> + +<p>The Description attribute is used to apply descriptive text to a Test, +TestFixture or Assembly. The text appears in the XML output file and is +shown in the Test Properties dialog.</p> + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">[assembly: Description("Assembly description here")] + +namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture, Description("Fixture description here")] + public class SomeTests + { + [Test, Description("Test description here")] + public void OneTest() + { /* ... */ } + } +} +</pre> +<pre class="vb"><assembly: Description("Assembly description here")> + +Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Description("Fixture description here")>_ + Public Class SomeTests + <Test(), Description("Test description here")>_ + Public Sub OneTest() + ' ... + End Sub + End Class +End Namespace +</pre> +<pre class="mc">[assembly:Description("Assembly description here")] + +#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture, Description("Fixture description here")] + public __gc class SomeTests + { + [Test, Description("Test description here")] + void OneTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">/** @assembly NUnit.Framework.Description("Assembly description here") */ + +package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Description("Fixture description here") */ +public class SomeTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Description("Test description here") */ + public void OneTest() + { /* ... */ } +} +</pre> +</div> + +<p><b>Note:</b> The Test and TestFixture attributes continue to support an +optional Description property. The Description attribute should be used for +new applciations. If both are used, the Description attribute takes precedence.</p> + + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li id="current"><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/directoryAssert.html b/tools/NUnit/doc/directoryAssert.html new file mode 100644 index 0000000..ae91f56 --- /dev/null +++ b/tools/NUnit/doc/directoryAssert.html @@ -0,0 +1,168 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - DirectoryAssert</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>DirectoryAssert (NUnit 2.5)</h2> +<p>The DirectoryAssert class provides methods for making asserts about +file system directories, which may be provided as DirectoryInfos or as strings +giving the path to each directory.</p> + +<p> <b>DirectoryAssert.AreEqual()</b> and <b>DirectoryAssert.AreNotEqual()</b> +compare two directories for equality. Directories are considered equal if +they have the same FullName, Attributes, CreationTime and LastAccessTime. + +<p><b>Note:</b> Two different directories containing the same files are not +considered to be equal. + +<div class="code" style="width: 40em"><pre> + +DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual ); +DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual, + string message ); +DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual, + string message, params object[] args ); + +DirectoryAssert.AreEqual( string expected, string actual ); +DirectoryAssert.AreEqual( string expected, string actual, + string message ); +DirectoryAssert.AreEqual( string expected, string actual, + string message, params object[] args ); + +DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual ); +DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual, + string message ); +DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual, + string message, params object[] args ); + +DirectoryAssert.AreNotEqual( string expected, string actual ); +DirectoryAssert.AreNotEqual( string expected, string actual, + string message ); +DirectoryAssert.AreNotEqual( string expected, string actual, + string message, params object[] args ); + +</pre></div> + +<p><b>DirectoryAssert.IsEmpty()</b> and <b>DirectoryAssert.IsNotEmpty()</b> +test whether the specified directory is empty. + +<div class="code" style="width: 40em"><pre> + +DirectoryAssert.IsEmpty( DirectoryInfo directory ); +DirectoryAssert.IsEmpty( DirectoryInfo directory, string message ); +DirectoryAssert.IsEmpty( DirectoryInfo directory, + string message, params object[] args ); + +DirectoryAssert.IsEmpty( string directory ); +DirectoryAssert.IsEmpty( string directory, string message ); +DirectoryAssert.IsEmpty( string directory, + string message, params object[] args ); + +DirectoryAssert.IsNotEmpty( DirectoryInfo directory ); +DirectoryAssert.IsNotEmpty( DirectoryInfo directory, string message ); +DirectoryAssert.IsNotEmpty( DirectoryInfo directory, + string message, params object[] args ); + +DirectoryAssert.IsNotEmpty( string directory ); +DirectoryAssert.IsNotEmpty( string directory, string message ); +DirectoryAssert.IsNotEmpty( string directory, + string message, params object[] args ); + +</pre></div> + +<p><b>DirectoryAssert.IsWithin()</b> and <b>DirectoryAssert.IsNotWithin()</b> +test whether the second directory is a direct or indirect subdirectory +of the first directory. + +<div class="code" style="width: 40em"><pre> + +DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual ); +DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual, + string message ); +DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual, + string message, params object[] args ); + +DirectoryAssert.IsWithin( string expected, string actual ); +DirectoryAssert.IsWithin( string expected, string actual, + string message ); +DirectoryAssert.IsWithin( string expected, string actual, + string message, params object[] args ); + +DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual ); +DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual, + string message ); +DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual, + string message, params object[] args ); + +DirectoryAssert.IsNotWithin( string expected, string actual ); +DirectoryAssert.IsNotWithin( string expected, string actual, + string message ); +DirectoryAssert.IsNotWithin( string expected, string actual, + string message, params object[] args ); + +</pre></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li id="current"><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/equalConstraint.html b/tools/NUnit/doc/equalConstraint.html new file mode 100644 index 0000000..29ff4b3 --- /dev/null +++ b/tools/NUnit/doc/equalConstraint.html @@ -0,0 +1,254 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - EqualConstraint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Equal Constraint (NUnit 2.4 / 2.5)</h2> + +<p>An EqualConstraint is used to test whether an actual value + is equal to the expected value supplied in its constructor, + optionally within a specified tolerance. + +<h4>Constructor</h4> +<div class="code"><pre> +EqualConstraint(object expected ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.EqualTo( object expected ) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +...AsCollection +...NoClip +...Within(object tolerance) + .Ulps + .Percent + .Days + .Hours + .Minutes + .Seconds + .Milliseconds + .Ticks +...Using(IEqualityComparer comparer) +...Using(IEqualityComparer<T> comparer) +...Using(IComparer comparer) +...Using<T>(IComparer<T> comparer) +...Using<T>(Comparison<T> comparer) +</pre></div> + +<h4>Comparing Numerics</h4> +<p>Numerics are compared based on their values. Different types + may be compared successfully if their values are equal. + +<p>Using the <b>Within</b> modifier, numerics may be tested +for equality within a fixed or percent tolerance. + +<div class="code"><pre> +Assert.That(2 + 2, Is.EqualTo(4.0)); +Assert.That(2 + 2 == 4); +Assert.That(2 + 2, Is.Not.EqualTo(5)); +Assert.That(2 + 2 != 5); +Assert.That( 5.0, Is.EqualTo( 5 ); +Assert.That( 5.5, Is.EqualTo( 5 ).Within(0.075); +Assert.That( 5.5, Is.EqualTo( 5 ).Within(1.5).Percent; +</pre></div> + +<h4>Comparing Floating Point Values</h4> +<p>Values of type float and double are normally compared using a tolerance +specified by the <b>Within</b> modifier. The special values PositiveInfinity, +NegativeInfinity and NaN compare +as equal to themselves. + +<p>With version 2.5, floating-point values may be compared using a tolerance +in "Units in the Last Place" or ULPs. For certain types of numerical work, +this is safer than a fixed tolerance because it automatically compensates +for the added inaccuracy of larger numbers. + +<div class="code" style="width: 42em"><pre> +Assert.That( 2.1 + 1.2, Is.EqualTo( 3.3 ).Within( .0005 ); +Assert.That( double.PositiveInfinity, Is.EqualTo( double.PositiveInfinity ) ); +Assert.That( double.NegativeInfinity, Is.EqualTo( double.NegativeInfinity ) ); +Assert.That( double.NaN, Is.EqualTo( double.NaN ) ); +Assert.That( 20000000000000004.0, Is.EqualTo(20000000000000000.0).Within(1).Ulps); +</pre></div> + +<h4>Comparing Strings</h4> + +<p>String comparisons normally respect case. The <b>IgnoreCase</b> modifier + causes the comparison to be case-insensitive. It may also be used when + comparing arrays or collections of strings. + +<div class="code"><pre> +Assert.That( "Hello!", Is.Not.EqualTo( "HELLO!" ) ); +Assert.That( "Hello!", Is.EqualTo( "HELLO!" ).IgnoreCase ); + +string[] expected = new string[] { "Hello", World" }; +string[] actual = new string[] { "HELLO", "world" }; +Assert.That( actual, Is.EqualTo( expected ).IgnoreCase; +</pre></div> + +<h4>Comparing DateTimes and TimeSpans</h4> + +<p><b>DateTimes</b> and <b>TimeSpans</b> may be compared either with or without + a tolerance. A tolerance is specified using <b>Within</b> with either a + <b>TimeSpan</b> as an argument or with a numeric value followed by a one of + the time conversion modifiers: <b>Days</b>, <b>Hours</b>, <b>Minutes</b>, + <b>Seconds</b>, <b>Milliseconds</b> or <b>Ticks</b>. + +<div class="code"><pre> +DateTime now = DateTime.Now; +DateTime later = now + TimeSpan.FromHours(1.0); + +Assert.That( now, Is.EqualTo(now) ); +Assert.That( later. Is.EqualTo(now).Within(TimeSpan.FromHours(3.0); +Assert.That( later, Is.EqualTo(now).Within(3).Hours; +</pre></div> + +<h4>Comparing Arrays and Collections</h4> + +<p>Since version 2.2, NUnit has been able to compare two single-dimensioned arrays. + Beginning with version 2.4, multi-dimensioned arrays, nested arrays (arrays of arrays) + and collections may be compared. With version 2.5, any IEnumerable is supported. + Two arrays, collections or IEnumerables are considered equal if they have the + the same dimensions and if each of the corresponding elements is equal.</p> + +<p>If you want to treat two arrays of different shapes as simple collections + for purposes of comparison, use the <b>AsCollection</b> modifier, which causes + the comparison to be made element by element, without regard for the rank or + dimensions of the array. Note that jagged arrays (arrays of arrays) do not + have a single underlying collection. The modifier would be applied + to each array separately, which has no effect in most cases. + +<div class="code"><pre> +int[] i3 = new int[] { 1, 2, 3 }; +double[] d3 = new double[] { 1.0, 2.0, 3.0 }; +int[] iunequal = new int[] { 1, 3, 2 }; +Assert.That(i3, Is.EqualTo(d3)); +Assert.That(i3, Is.Not.EqualTo(iunequal)); + +int array2x2 = new int[,] { { 1, 2 } { 3, 4 } }; +int array4 = new int[] { 1, 2, 3, 4 }; +Assert.That( array2x2, Is.Not.EqualTo( array4 ) ); +Assert.That( array2x2, Is.EqualTo( array4 ).AsCollection ); +</pre></div> + +<h4>User-Specified Comparers</h4> + +<p>If the default NUnit or .NET behavior for testing equality doesn't +meet your needs, you can supply a comparer of your own through the +<b>Using</b> modifier. When used with <b>EqualConstraint</b>, you +may supply an <b>IEqualityComparer</b>, <b>IEqualityComparer<T></b>, +<b>IComparer</b>, <b>IComparer<T></b>; or <b>Comparison<T></b> +as the argument to <b>Using</b>. + +<div class="code"><pre> +Assert.That( myObj1, Is.EqualTo( myObj2 ).Using( myComparer ) ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><p>When checking the equality of user-defined classes, NUnit makes use + of the <b>Equals</b> override on the expected object. If you neglect to + override <b>Equals</b>, you can expect failures non-identical objects. + In particular, overriding <b>operator==</b> without overriding <b>Equals</b> + has no effect. +<li><p>The <b>Within</b> modifier was originally designed for use with floating point + values only. Beginning with NUnit 2.4, comparisons of <b>DateTime</b> values + may use a <b>TimeSpan</b> as a tolerance. Beginning with NUnit 2.4.2, + non-float numeric comparisons may also specify a tolerance. +<li><p>Beginning with NUnit 2.4.4, float and double comparisons for which no + tolerance is specified use a default, use the value of + <b>GlobalSettings.DefaultFloatingPointTolerance</b>. If this is not + set, a tolerance of 0.0d is used. +<li><p>Prior to NUnit 2.2.3, comparison of two NaN values would always fail, + as specified by IEEE floating point standards. The new behavior, was + introduced after some discussion becuase it seems more useful in tests. + To avoid confusion, consider using <b>Is.NaN</b> where appropriate. +<li><p>When an equality test between two strings fails, the relevant portion of + of both strings is displayed in the error message, clipping the strings to + fit the length of the line as needed. Beginning with 2.4.4, this behavior + may be modified by use of the <b>NoClip</b> modifier on the constraint. In + addition, the maximum line length may be modified for all tests by setting + the value of <b>TextMessageWriter.MaximumLineLength</b> in the appropriate + level of setup. +<li><p>When used with arrays or collections, EqualConstraint operates + recursively. Any modifiers are saved and used as they apply to + individual items in the collection. +<li><p>A user-specified comparer will not be called by <b>EqualConstraint</b> + if either or both arguments are null. If both are null, the Constraint + succeeds. If only one is null, it fails. +<li><p>NUnit has special semantics for comparing <b>Streams</b> and +<b>DirectoryInfos</b>. For a <b>Stream</b>, the contents are compared. +For a <b>DirectoryInfo</b>, the first-level directory contents are compared. +</ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li id="current"><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/equalityAsserts.html b/tools/NUnit/doc/equalityAsserts.html new file mode 100644 index 0000000..38fbd70 --- /dev/null +++ b/tools/NUnit/doc/equalityAsserts.html @@ -0,0 +1,185 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - EqualityAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Equality Asserts</h2> + +<p>These methods test whether the two arguments are equal. Overloaded +methods are provided for common value types so that languages that don't +automatically box values can use them directly.</p> + +<div class="code" style="width: 36em" > + <pre>Assert.AreEqual( int expected, int actual ); +Assert.AreEqual( int expected, int actual, string message ); +Assert.AreEqual( int expected, int actual, string message, + params object[] parms ); + +Assert.AreEqual( uint expected, uint actual ); +Assert.AreEqual( uint expected, uint actual, string message ); +Assert.AreEqual( uint expected, uint actual, string message, + params object[] parms ); + +Assert.AreEqual( decimal expected, decimal actual ); +Assert.AreEqual( decimal expected, decimal actual, string message ); +Assert.AreEqual( decimal expected, decimal actual, string message, + params object[] parms ); + +Assert.AreEqual( float expected, float actual, float tolerance ); +Assert.AreEqual( float expected, float actual, float tolerance, + string message ); +Assert.AreEqual( float expected, float actual, float tolerance, + string message, params object[] parms ); + +Assert.AreEqual( double expected, double actual, double tolerance ); +Assert.AreEqual( double expected, double actual, double tolerance, + string message ); +Assert.AreEqual( double expected, double actual, double tolerance, + string message, params object[] parms ); + +Assert.AreEqual( object expected, object actual ); +Assert.AreEqual( object expected, object actual, string message ); +Assert.AreEqual( object expected, object actual, string message, + params object[] parms ); + +Assert.AreNotEqual( int expected, int actual ); +Assert.AreNotEqual( int expected, int actual, string message ); +Assert.AreNotEqual( int expected, int actual, string message, + params object[] parms ); + +Assert.AreNotEqual( long expected, long actual ); +Assert.AreNotEqual( long expected, long actual, string message ); +Assert.AreNotEqual( long expected, long actual, string message, + params object[] parms ); + +Assert.AreNotEqual( uint expected, uint actual ); +Assert.AreNotEqual( uint expected, uint actual, string message ); +Assert.AreNotEqual( uint expected, uint actual, string message, + params object[] parms ); + +Assert.AreNotEqual( ulong expected, ulong actual ); +Assert.AreNotEqual( ulong expected, ulong actual, string message ); +Assert.AreNotEqual( ulong expected, ulong actual, string message, + params object[] parms ); + +Assert.AreNotEqual( decimal expected, decimal actual ); +Assert.AreNotEqual( decimal expected, decimal actual, string message ); +Assert.AreNotEqual( decimal expected, decimal actual, string message, + params object[] parms ); + +Assert.AreNotEqual( float expected, float actual ); +Assert.AreNotEqual( float expected, float actual, string message ); +Assert.AreNotEqual( float expected, float actual, string message, + params object[] parms ); + +Assert.AreNotEqual( double expected, double actual ); +Assert.AreNotEqual( double expected, double actual, string message ); +Assert.AreNotEqual( double expected, double actual, string message, + params object[] parms ); + +Assert.AreNotEqual( object expected, object actual ); +Assert.AreNotEqual( object expected, object actual, string message ); +Assert.AreNotEqual( object expected, object actual, string message, + params object[] parms );</pre> +</div> + +<h4>Comparing Numerics of Different Types</h4> + +<p>The method overloads that compare two objects make special provision so that numeric + values of different types compare as expected. This assert succeeds: + <pre> Assert.AreEqual( 5, 5.0 );</pre> +</p> + +<h4>Comparing Floating Point Values</h4> + +<p>Values of type float and double are normally compared using an additional +argument that indicates a tolerance within which they will be considered +as equal. Beginning with NUnit 2.4.4, the value of +<b>GlobalSettings.DefaultFloatingPointTolerance</b> is used if a third argument +is not provided. In earlier versions, or if the default has not been set, +values are tested for exact equality. + +<p>Special values are handled so that the following Asserts succeed:</p> + +<pre> Assert.AreEqual( double.PositiveInfinity, double.PositiveInfinity ); + Assert.AreEqual( double.NegativeInfinity, double.NegativeInfinity ); + Assert.AreEqual( double.NaN, double.NaN );</pre> + +<blockquote><i><b>Note:</b> The last example above represents a change with NUnit 2.2.3. + In earlier releases, the test would fail. We have made this change + because the new behavior seems to be more useful in tests. To avoid confusion, + we suggest using the new Assert.IsNaN method where appropriate.</i></blockquote> + +<h4>Comparing Arrays and Collections</h4> + +<p>Since version 2.2, NUnit has been able to compare two single-dimensioned arrays. + Beginning with version 2.4, multi-dimensioned arrays, nested arrays (arrays of arrays) + and collections may be compared. Two arrays or collections will be treated as equal + by Assert.AreEqual if they have the same dimensions and if each of the corresponding + elements is equal.</p> + +</div> +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li id="current"><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/eventListeners.html b/tools/NUnit/doc/eventListeners.html new file mode 100644 index 0000000..673db50 --- /dev/null +++ b/tools/NUnit/doc/eventListeners.html @@ -0,0 +1,105 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - EventListeners</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>EventListeners (NUnit 2.4.4)</h3> + +<h4>Purpose</h4> +<p>EventListeners are able to respond to events that occur in the course +of a test run, usually by recording information of some kind. Note that +EventListeners called asynchronously with respect to test execution and +are not able to affect the actual execution of the test. + +<h4>Extension Point</h4> +<p>Addins use the host to access this extension point by name: + +<pre> + IExtensionPoint listeners = host.GetExtensionPoint( "EventListeners" );</pre> + +<h4>Interface</h4> +<p>The extension object passed to Install must implement the EventListener interface: + +<pre> + public interface EventListener + { + void RunStarted( string name, int testCount ); + void RunFinished( TestResult result ); + void RunFinished( Exception exception ); + void TestStarted(TestName testName); + void TestFinished(TestCaseResult result); + void SuiteStarted(TestName testName); + void SuiteFinished(TestSuiteResult result); + void UnhandledException( Exception exception ); + void TestOutput(TestOutput testOutput); + } +</pre> + +<p>You must provide all the methods, but the body may be empty for any +that you have no need of. + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li id="current"><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/exception.html b/tools/NUnit/doc/exception.html new file mode 100644 index 0000000..f3a23fc --- /dev/null +++ b/tools/NUnit/doc/exception.html @@ -0,0 +1,316 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Exception</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>ExpectedExceptionAttribute (NUnit 2.0 plus Updates)</h3> + +<p>This is the way to specify that the execution of a test will throw an + exception. This attribute has a number of positional and + named parameters, which we will discuss in separate sections + according to the purpose they serve.</p> + +<h4>Specifying the Expected Exception Type</h4> + +<p>The original attribute, introduced with NUnit 2.0 took a single +argument giving the exact type of the expected exception. For example...</p> + + +<div class="code"><pre>[ExpectedException( typeof( ArgumentException ) )] +public void TestMethod() +{ +...</pre></div> + +<p>Beginning with NUnit 2.2.4, it became possible to specify the type +of exception as a string, avoiding the need for a reference to the +defining assembly...</p> + +<div class="code"><pre>[ExpectedException( "System.ArgumentException" ) )] +public void TestMethod() +{ +...</pre></div> + +<p>The above two examples function identically: the test only succeeds if a +System.Argument exception is thrown.</p> + +<h4>Specifying the Expected Message</h4> + +<p>NUnit 2.1 introduced a constructor with a second argument, specifying the +exact text of the message property of the exception. After NUnit 2.2.4, the +same extension was made to the constructor taking a string argument. With +NUnit 2.4, these arguments are marked obsolete, and a named parameter +is provided instead...</p> + +<div class="code" style="width: 44em"><pre>// Obsolete form: +[ExpectedException( typeof( ArgumentException ), "expected message" )] +[ExpectedException( "System.ArgumentException", "expected message" )] + +// Prefered form: +[ExpectedException( typeof( ArgumentException ), ExpectedMessage="expected message" )] +[ExpectedException( "System.ArgumentException", ExpectedMessage="expected message" )]</pre></div> + +<p>With NUnit 2.4, it is possible to specify additional tests on the +exception message, beyond a simple exact match. This is done using the +MatchType named parameter, whose argument is an enumeration, defined as +follows:</p> + +<div class="code"> +<pre>public enum MessageMatch +{ + /// Expect an exact match + Exact, + /// Expect a message containing the parameter string + Contains, + /// Match the regular expression provided as a parameter + Regex, + /// Expect a message starting with the parameter string + StartsWith +}</pre></div> + +<p>The following example is for a test that passes only if an ArgumentException +with a message containing "unspecified" is received.</p> + +<div class="code" style="width: 57em"> +<pre>[ExpectedException( typeof( ArgumentException), ExpectedMessage="unspecified", MatchType=MessageMatch.Contains )] +public void TestMethod() +{ +...</pre></div> + +<p>If MatchType is not specified, an exact match is used as before.</p> + +<h4>Specifying a Custom Error Message</h4> + +<p>With NUnit 2.4, it is possible to specify a custom message to be +displayed if the ExpectedException attribute is not satisfied. This +is done through the UserMessage named parameter...</p> + +<div class="code" style="width: 41em"> +<pre>[ExpectedException( typeof( ArgumentException ), UserMessage="Custom message" )] +public void TestMethod() +{ +...</pre> +</div> + +<h4>Handling the Exception in Code</h4> + +<p>If the processing required for an exception is too complex to express +in the attribute declaration, the normal practice is to process it in the +test code using a try/catch block. As an alternative, NUnit 2.4 allows +designating a method that will be called to process the exception. This +is particularly useful when multiple exceptions need to be processed +in the same way.</p> + +<p>An common exception handler may be designated by implementing the +<b>IExpectExceptionInterface</b>, which is defined as follows...</p> + +<div class="code"> +<pre>public interface IExpectException +{ + void HandleException( System.Exception ex ); +}</pre> +</div> + +<p>The exception handler is only called for methods marked with +the <b>ExpectedException</b> attribute. If all checks - including +the type of the exception - are to be performed in code, the +attribute may be specified without any arguments in order to +indicate that an exception is expected.</p> + +<p>An handler may be designated for a particular method +using the <b>Handler</b> named parameter.</p> + +<div class="code"><pre>[ExpectedException( Handler="HandlerMethod" )] +public void TestMethod() +{ +... +} + +public void HandlerMethod( System.Exception ex ) +{ +... +}</pre></div> + +<p>This technique may be +used without implementing <b>IExpectException</b> or in +combination with it. In the latter case, the designated handler +applies to any method that specifies it, while the normal +exception handler applies to any other methods that specify +an <b>ExpectedException</b>.</p> + +<p>However it is specified, the handler method should examine the exception and +<b>Assert</b> on whatever properties are relevant. Any resulting failure message +will then be consistent in format with other assertions performed in the tests.</p> + + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void ExpectAnExceptionByType() + { /* ... */ } + + [Test] + [ExpectedException("System.InvalidOperationException")] + public void ExpectAnExceptionByName() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <Test(), ExpectedException(GetType(Exception))> + Public Sub ExpectAnExceptionByType() + ' ... + End Sub + + <TestFixture()> Public Class SuccessTests + <Test(), ExpectedException("System.Exception")> + Public Sub ExpectAnExceptionByName() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test] + [ExpectedException(__typeof(InvalidOperationException))] + void ExpectAnExceptionByType(); + + [Test] + [ExpectedException(S"SystemInvalidOperationException")] + void ExpectAnExceptionByName(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li id="current"><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/exceptionAsserts.html b/tools/NUnit/doc/exceptionAsserts.html new file mode 100644 index 0000000..65fe804 --- /dev/null +++ b/tools/NUnit/doc/exceptionAsserts.html @@ -0,0 +1,234 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ExceptionAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Exception Asserts (NUnit 2.5)</h2> + +<p>The <b>Assert.Throws</b> method is pretty much in a class by itself. Rather than + comparing values, it attempts to invoke a code snippet, represented as + a delegate, in order to verify that it throws a particular exception. + +<p>It's also in a class by itself in that it returns an Exception, rather + than void, if the Assert is successful. See the example below for + a few ways to use this. + +<p><b>Assert.Throws</b> may be used with a constraint argument, which is applied + to the actual exception thrown, or with the Type of exception expected. + The Type format is available in both both a non-generic and (in the .NET 2.0 version) + generic form. + +<p><b>Assert.DoesNotThrow</b> simply verifies that the delegate does not throw + an exception. + +<p><b>Assert.Catch</b> is similar to <b>Assert.Throws</b> but will pass for an exception + that is derived from the one specified. + +<div class="code" style="width: 40em"><pre> +Exception Assert.Throws( Type expectedExceptionType, TestDelegate code ); +Exception Assert.Throws( Type expectedExceptionType, TestDelegate code, + string message ); +Exception Assert.Throws( Type expectedExceptionType, TestDelegate code, + string message, params object[] parms); + +Exception Assert.Throws( IResolveConstraint constraint, TestDelegate code ); +Exception Assert.Throws( IResolveConstraint constraint, TestDelegate code, + string message ); +Exception Assert.Throws( IResolveConstraint constraint, TestDelegate code, + string message, params object[] parms); + +T Assert.Throws<T>( TestDelegate code ); +T Assert.Throws<T>( TestDelegate code, string message ); +T Assert.Throws<T>( TestDelegate code, string message, + params object[] parms); + +void Assert.DoesNotThrow( TestDelegate code ); +void Assert.DoesNotThrow( TestDelegate code, string message ); +void Assert.DoesNotThrow( TestDelegate code, string message, + params object[] parms); + +Exception Assert.Catch( TestDelegate code ); +Exception Assert.Catch( TestDelegate code, string message ); +Exception Assert.Catch( TestDelegate code, string message, + params object[] parms); + +Exception Assert.Catch( Type expectedExceptionType, TestDelegate code ); +Exception Assert.Catch( Type expectedExceptionType, TestDelegate code, + string message ); +Exception Assert.Catch( Type expectedExceptionType, TestDelegate code, + string message, params object[] parms); + +T Assert.Catch<T>( TestDelegate code ); +T Assert.Catch<T>( TestDelegate code, string message ); +T Assert.Catch<T>( TestDelegate code, string message, + params object[] parms); +</pre></div> + +<p>In the above code <b>TestDelegate</b> is a delegate of the form +<b>void TestDelegate()</b>, which is used to execute the code +in question. Under .NET 2.0, this may be an anonymous delegate. +If compiling under C# 3.0, it may be a lambda expression. + +<p>The following example shows different ways of writing the +same test. + +<div class="code"><pre> +[TestFixture] +public class AssertThrowsTests +{ + [Test] + public void Tests() + { + // .NET 1.x + Assert.Throws( typeof(ArgumentException), + new TestDelegate(MethodThatThrows) ); + + // .NET 2.0 + Assert.Throws<ArgumentException>( MethodThatThrows() ); + + Assert.Throws<ArgumentException>( + delegate { throw new ArgumentException(); } ); + + // Using C# 3.0 + Assert.Throws<ArgumentException>( + () => throw new ArgumentException(); } ); + } + + void MethodThatThrows() + { + throw new ArgumentException(); + } + +</pre></div> + +<p>This example shows use of the return value to perform +additional verification of the exception. + +<div class="code"><pre> +[TestFixture] +public class UsingReturnValue +{ + [Test] + public void TestException() + { + MyException ex = Assert.Throws<MyException>( + delegate { throw new MyException( "message", 42 ); } ); + Assert.That( ex.Message, Is.EqualTo( "message" ) ); + Assert.That( ex.MyParam, Is.EqualTo( 42 ) ); + } +</pre></div> + +<p>This example does the same thing +using the overload that includes a constraint. + +<div class="code"><pre> +[TestFixture] +public class UsingConstraint +{ + [Test] + public void TestException() + { + Assert.Throws( Is.Typeof<MyException>() + .And.Message.EqualTo( "message" ) + .And.Property( "MyParam" ).EqualTo( 42 ), + delegate { throw new MyException( "message", 42 ); } ); + } +</pre></div> + +<p>Use the form that matches your style of coding. + +<h3>Exact Versus Derived Types</h3> + +<p>When used with a Type argument, <b>Assert.Throws</b> requires +that exact type to be thrown. If you want to test for any +derived Type, use one of the forms that allows specifying +a constraint. Alternatively, you may use <b>Assert.Catch</b>, +which differs from <b>Assert.Throws</b> in allowing derived +types. See the following code for examples: + +<div class="code"> +<pre> +// Require an ApplicationException - derived types fail! +Assert.Throws( typeof(ApplicationException), code ); +Assert.Throws<ApplicationException>()( code ); + +// Allow both ApplicationException and any derived type +Assert.Throws( Is.InstanceOf( typeof(ApplicationException), code ); +Assert.Throws( Is.InstanceOf<ApplicationException>(), code ); + +// Allow both ApplicationException and any derived type +Assert.Catch<ApplicationException>( code ); + +// Allow any kind of exception +Assert.Catch( code ); +</pre> +</div> + +<h4>See also...</h4> +<ul> +<li><a href="throwsConstraint.html">ThrowsConstraint</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li id="current"><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/explicit.html b/tools/NUnit/doc/explicit.html new file mode 100644 index 0000000..0ce3068 --- /dev/null +++ b/tools/NUnit/doc/explicit.html @@ -0,0 +1,274 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Explicit</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>ExplicitAttribute (NUnit 2.2)</h3> + +<p>The Explicit attribute causes a test or test fixture to be ignored unless it is + explicitly selected for running. The test or fixture will be run if it is + selected in the gui, if its name is specified on the console runner command + line as the fixture to run or if it is included by use of a Category filter.</p> + +<p>An optional string argument may be used to give the reason for marking + the test Explicit.</p> + +<p>If a test or fixture with the Explicit attribute is encountered in the course of + running tests, it is skipped unless it has been specifically selected by one + of the above means. The test does not affect the outcome of the run at all: + it is not considered as ignored and is not even counted in the total number + of tests. In the gui, the tree node for the test remains gray and the + status bar color is not affected.</p> + +<blockquote><i><b>Note:</b> In versions of NUnit prior to 2.4, these tests were + shown as ignored.</i></blockquote> + +<h4>Test Fixture Syntax</h4> + +<div id="trace"> +</div> + +<div class="code cs"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture, Explicit] + public class ExplicitTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Explicit()> + Public Class ExplicitTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [Explicit] + public __gc class ExplicitTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Explicit() */ +public class ExplicitTests +{ + // ... +} +</pre> + +</div> + +<h4>Test Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test, Explicit] + public void ExplicitTest() + { /* ... */ } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> + Public Class SuccessTests + <Test(), Explicit()> Public Sub ExplicitTest() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test][Explicit] void ExplicitTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Explicit() */ + public void ExplicitTest() + { /* ... */ } +} +</pre> + +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li id="current"><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/extensibility.html b/tools/NUnit/doc/extensibility.html new file mode 100644 index 0000000..6c8fc98 --- /dev/null +++ b/tools/NUnit/doc/extensibility.html @@ -0,0 +1,78 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Extensibility</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit Extensibility</h2> + +<p>NUnit is designed to be extended in a number of ways.</p> + +<p>Extensions to the NUnit framework - the part of NUnit that is referenced +by tests - usually take the form of +<a href="customConstraints.html">Custom Constraints</a>, written by users to +encapsulate tests that pertain to their specific projects.</p> + +<p>Extending the features found within NUnit itself depends on the use of +<a href="nunitAddins.html">NUnit Addins</a>. +Currently, The Addin mechanism only supports extensions to the NUnit core - +the part of NUnit that builds and executes test suites. However, the API that +is used provides for the future ability to extend the client side of NUnit, +including the GUI.</p> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li id="current"><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/extensionTips.html b/tools/NUnit/doc/extensionTips.html new file mode 100644 index 0000000..d538255 --- /dev/null +++ b/tools/NUnit/doc/extensionTips.html @@ -0,0 +1,95 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ExtensionTips</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>Tips for Writing Extensions</h3> + +<p>An Extenders Guide will be published in the future. At the moment, writing an +extension is a bit of an adventure. Extension authors are advised to join the +nunit-developer list and post questions and comments there. + +<p>For the moment, the following tips may be of assistance. +<ul> +<li>The <b>nunit.core.interfaces</b> assembly is intended to be stable in the future +while the <b>nunit.core</b> assembly will change from release to release. Right now, +both assemblies are still in flux, but extensions that depend solely on the interfaces +assembly will have a much better chance of surviving NUnit version changes. Unfortunately, +this is rather difficult to do without duplicating a great deal of NUnit code. Most +of the add-in samples provided with NUnit are currently version dependent. + +<li>If you place the definition of a custom attribute in the same assembly as your +add-in, then user tests are dependent on the add-in assembly. If the add-in is +version-dependent, then the user tests will also be version-dependent. We suggest +placing any types referenced by user tests in a separate assembly, particularly if +your extension relies on nunit.core. + +<li>If using Visual Studio, set Copy Local to false for any references to nunit.core +or nunit.core.interfaces. This is especially important if you are also building +NUnit itself. + +<li>There is currently no mechanism to allow decorators to apply in a particular order. +NUnit applies decorators in the order in which they are returned through reflection, +which may vary among different runtimes. + +<li>Avoid trying to "stretch" the existing extension points to do more than they were +intended to do. Rather, let us know what further extension points you would like to see! +</ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<li id="current"><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/favicon.ico b/tools/NUnit/doc/favicon.ico Binary files differnew file mode 100644 index 0000000..b95fa81 --- /dev/null +++ b/tools/NUnit/doc/favicon.ico diff --git a/tools/NUnit/doc/fileAssert.html b/tools/NUnit/doc/fileAssert.html new file mode 100644 index 0000000..de4d7e0 --- /dev/null +++ b/tools/NUnit/doc/fileAssert.html @@ -0,0 +1,112 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - FileAssert</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>FileAssert (NUnit 2.4)</h2> +<p>The FileAssert class provides methods for comparing two files, +which may be provided as Streams, as FileInfos or as strings +giving the path to each file.</p> + +<div class="code" style="width: 36em"> +<pre>FileAssert.AreEqual( Stream expected, Stream actual ); +FileAssert.AreEqual( Stream expected, Stream actual, + string message ); +FileAssert.AreEqual( Stream expected, Stream actual, + string message, params object[] args ); + +FileAssert.AreEqual( FileInfo expected, FileInfo actual ); +FileAssert.AreEqual( FileInfo expected, FileInfo actual, + string message ); +FileAssert.AreEqual( FileInfo expected, FileInfo actual, + string message, params object[] args ); + +FileAssert.AreEqual( string expected, string actual ); +FileAssert.AreEqual( string expected, string actual, + string message ); +FileAssert.AreEqual( string expected, string actual, + string message, params object[] args ); + +FileAssert.AreNotEqual( Stream expected, Stream actual ); +FileAssert.AreNotEqual( Stream expected, Stream actual, + string message ); +FileAssert.AreNotEqual( Stream expected, Stream actual, + string message, params object[] args ); + +FileAssert.AreNotEqual( FileInfo expected, FileInfo actual ); +FileAssert.AreNotEqual( FileInfo expected, FileInfo actual, + string message ); +FileAssert.AreNotEqual( FileInfo expected, FileInfo actual, + string message, params object[] args ); + +FileAssert.AreNotEqual( string expected, string actual ); +FileAssert.AreNotEqual( string expected, string actual, + string message ); +FileAssert.AreNotEqual( string expected, string actual, + string message, params object[] args );</pre> +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li id="current"><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/files/QuickStart.Spanish.doc b/tools/NUnit/doc/files/QuickStart.Spanish.doc Binary files differnew file mode 100644 index 0000000..b60a15a --- /dev/null +++ b/tools/NUnit/doc/files/QuickStart.Spanish.doc diff --git a/tools/NUnit/doc/files/QuickStart.doc b/tools/NUnit/doc/files/QuickStart.doc Binary files differnew file mode 100644 index 0000000..d92ad94 --- /dev/null +++ b/tools/NUnit/doc/files/QuickStart.doc diff --git a/tools/NUnit/doc/files/Results.xsd b/tools/NUnit/doc/files/Results.xsd new file mode 100644 index 0000000..df3e76e --- /dev/null +++ b/tools/NUnit/doc/files/Results.xsd @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + <xs:complexType name="failureType"> + <xs:sequence> + <xs:element ref="message" /> + <xs:element ref="stack-trace" /> + </xs:sequence> + </xs:complexType> + <xs:complexType name="reasonType"> + <xs:sequence> + <xs:element ref="message" /> + </xs:sequence> + </xs:complexType> + <xs:element name="message" type="xs:string" /> + <xs:complexType name="resultsType"> + <xs:choice> + <xs:element name="test-suite" type="test-suiteType" maxOccurs="unbounded" /> + <xs:element name="test-case" type="test-caseType" maxOccurs="unbounded" minOccurs="0" /> + </xs:choice> + </xs:complexType> + <xs:element name="stack-trace" type="xs:string" /> + <xs:element name="test-results" type="resultType" /> + <xs:complexType name="categoriesType"> + <xs:sequence> + <xs:element name="category" type="categoryType" maxOccurs="unbounded" minOccurs="1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="categoryType"> + <xs:attribute name="name" type="xs:string" use="required"/> + </xs:complexType> + <xs:complexType name="resultType"> + <xs:sequence> + <xs:element name="test-suite" type="test-suiteType" /> + </xs:sequence> + <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="total" type="xs:decimal" use="required" /> + <xs:attribute name="failures" type="xs:decimal" use="required" /> + <xs:attribute name="not-run" type="xs:decimal" use="required" /> + <xs:attribute name="date" type="xs:string" use="required" /> + <xs:attribute name="time" type="xs:string" use="required" /> + </xs:complexType> + <xs:complexType name="test-caseType"> + <xs:sequence> + <xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" /> + <xs:choice> + <xs:element name="failure" type="failureType" minOccurs="0" /> + <xs:element name="reason" type="reasonType" minOccurs="0" /> + </xs:choice> + </xs:sequence> + + <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="description" type="xs:string" use="optional" /> + <xs:attribute name="success" type="xs:string" use="optional" /> + <xs:attribute name="time" type="xs:string" use="optional" /> + <xs:attribute name="executed" type="xs:string" use="required" /> + <xs:attribute name="asserts" type="xs:string" use="optional" /> + </xs:complexType> + <xs:complexType name="test-suiteType"> + <xs:sequence> + <xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" /> + <xs:element name="results" type="resultsType" /> + </xs:sequence> + <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="description" type="xs:string" use="optional" /> + <xs:attribute name="success" type="xs:string" use="required" /> + <xs:attribute name="time" type="xs:string" use="required" /> + <xs:attribute name="asserts" type="xs:string" use="optional" /> + </xs:complexType> + +</xs:schema>
\ No newline at end of file diff --git a/tools/NUnit/doc/files/Summary.xslt b/tools/NUnit/doc/files/Summary.xslt new file mode 100644 index 0000000..004806d --- /dev/null +++ b/tools/NUnit/doc/files/Summary.xslt @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:output method='text'/> + +<xsl:template match="/"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="test-results"> +<xsl:text>Tests run: </xsl:text> +<xsl:value-of select="@total"/> +<xsl:text>, Failures: </xsl:text> +<xsl:value-of select="@failures"/> +<xsl:text>, Not run: </xsl:text> +<xsl:value-of select="@not-run"/> +<xsl:text>, Time: </xsl:text> +<xsl:value-of select="test-suite/@time"/> +<xsl:text> seconds +</xsl:text> +<xsl:text> +</xsl:text> + +<xsl:if test="//test-case[failure]"><xsl:text>Failures: +</xsl:text></xsl:if> +<xsl:apply-templates select="//test-case[failure]"/> +<xsl:if test="//test-case[@executed='False']"><xsl:text>Tests not run: +</xsl:text></xsl:if> +<xsl:apply-templates select="//test-case[@executed='False']"/> +<xsl:text disable-output-escaping='yes'>
</xsl:text> +</xsl:template> + +<xsl:template match="test-case"> + <xsl:value-of select="position()"/><xsl:text>) </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text> : </xsl:text> + <xsl:value-of select="child::node()/message"/> +<xsl:text disable-output-escaping='yes'>
</xsl:text> + <xsl:if test="failure"> + <xsl:value-of select="failure/stack-trace"/> +<xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + +</xsl:stylesheet> + +
\ No newline at end of file diff --git a/tools/NUnit/doc/fixtureSetup.html b/tools/NUnit/doc/fixtureSetup.html new file mode 100644 index 0000000..b8e8722 --- /dev/null +++ b/tools/NUnit/doc/fixtureSetup.html @@ -0,0 +1,238 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - FixtureSetup</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestFixtureSetUpAttribute (NUnit 2.1 / 2.5)</h3> + +<p>This attribute is used inside a TestFixture to provide a single set of + functions that are performed once prior to executing any of the tests + in the fixture. + +<p><b>Before NUnit 2.5</b>, a TestFixture could have only one TestFixtureSetUp method + and it was required to be an instance method. + +<p><b>Beginning with NUnit 2.5</b>, TestFixtureSetUp methods may be either static or + instance methods and you may define more than one of them in a fixture. + Normally, multiple TestFixtureSetUp methods are only defined at different levels + of an inheritance hierarchy, as explained below. + +<p>If a TestFixtueSetUp method fails or throws an exception, none of the tests + in the fixure are executed and a failure or error is reported. + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [TestFixtureSetUp] public void Init() + { /* ... */ } + + [TestFixtureTearDown] public void Cleanup() + { /* ... */ } + + [Test] public void Add() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <TestFixtureSetUp()> Public Sub Init() + ' ... + End Sub + + <TestFixtureTearDown()> Public Sub Cleanup() + ' ... + End Sub + + <Test()> Public Sub Add() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [TestFixtureSetUp] void Init(); + [TestFixtureTearDown] void Cleanup(); + + [Test] void Add(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.TestFixtureSetUp() */ + public void Init() + { /* ... */ } + + /** @attribute NUnit.Framework.TestFixtureTearDown() */ + public void Cleanup() + { /* ... */ } + + /** @attribute NUnit.Framework.Test() */ + public void Add() + { /* ... */ } +} +</pre> + +</div> + +<h3>Inheritance</h3> + +<p>The TestFixtureSetUp attribute is inherited from any base class. Therefore, if a base + class has defined a SetFixtureSetUp method, that method will be called + after each test method in the derived class. + +<p>Before NUnit 2.5, you were permitted only one TestFixtureSetUp method. If you wanted to + have some TestFixtureSetUp functionality in the base class and add more in the derived + class you needed to call the base class method yourself. + +<p>With NUnit 2.5, you can achieve the same result by defining a TestFixtureSetUp method + in the base class and another in the derived class. NUnit will call base + class TestFixtureSetUp methods before those in the derived classes. + +<p><b>Note:</b> Although it is possible to define multiple TestFixtureSetUp methods + in the same class, you should rarely do so. Unlike methods defined in + separate classes in the inheritance hierarchy, the order in which they + are executed is not guaranteed. + +<h4>See also...</h4> +<ul> +<li><a href="setup.html">SetUpAttribute</a><li><a href="teardown.html">TearDownAttribute</a><li><a href="fixtureTeardown.html">TestFixtureTearDownAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li id="current"><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/fixtureTeardown.html b/tools/NUnit/doc/fixtureTeardown.html new file mode 100644 index 0000000..1632b88 --- /dev/null +++ b/tools/NUnit/doc/fixtureTeardown.html @@ -0,0 +1,238 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - FixtureTeardown</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestFixtureTearDownAttribute (NUnit 2.1 / 2.5)</h3> + +<p>This attribute is used inside a TestFixture to provide a single set of + functions that are performed once after all tests are completed. + +<p><b>Before NUnit 2.5</b>, a TestFixture could have only one SetUp method + and it was required to be an instance method. + +<p><b>Beginning with NUnit 2.5</b>, TestFixtureTearDown methods may be either static or + instance methods and you may define more than one of them in a fixture. + Normally, multiple TestFixtureTearDown methods are only defined at different levels + of an inheritance hierarchy, as explained below. + +<p>So long as any TestFixtureSetUp method runs without error, the TestFixtureTearDown method is + guaranteed to run. It will not run if a TestFixtureSetUp method fails or throws an + exception.</p> + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [TestFixtureSetUp] public void Init() + { /* ... */ } + + [TestFixtureTearDown] public void Cleanup() + { /* ... */ } + + [Test] public void Add() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <TestFixtureSetUp()> Public Sub Init() + ' ... + End Sub + + <TestFixtureTearDown()> Public Sub Cleanup() + ' ... + End Sub + + <Test()> Public Sub Add() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [TestFixtureSetUp] void Init(); + [TestFixtureTearDown] void Cleanup(); + + [Test] void Add(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.TestFixtureSetUp() */ + public void Init() + { /* ... */ } + + /** @attribute NUnit.Framework.TestFixtureTearDown() */ + public void Cleanup() + { /* ... */ } + + /** @attribute NUnit.Framework.Test() */ + public void Add() + { /* ... */ } +} +</pre> + +</div> + +<h3>Inheritance</h3> + +<p>The TestFixtureTearDown attribute is inherited from any base class. Therefore, if a base + class has defined a TestFixtureTearDown method, that method will be called + after each test method in the derived class. + +<p>Before NUnit 2.5, you were permitted only one TestFixtureTearDown method. If you wanted to + have some TestFixtureTearDown functionality in the base class and add more in the derived + class you needed to call the base class method yourself. + +<p>With NUnit 2.5, you can achieve the same result by defining a TestFixtureTearDown method + in the base class and another in the derived class. NUnit will call base + class TestFixtureTearDown methods after those in the derived classes. + +<p><b>Note:</b> Although it is possible to define multiple TestFixtureTearDown methods + in the same class, you should rarely do so. Unlike methods defined in + separate classes in the inheritance hierarchy, the order in which they + are executed is not guaranteed. + +<h4>See also...</h4> +<ul> +<li><a href="setup.html">SetUpAttribute</a><li><a href="teardown.html">TearDownAttribute</a><li><a href="fixtureSetup.html">TestFixtureSetUpAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li id="current"><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/getStarted.html b/tools/NUnit/doc/getStarted.html new file mode 100644 index 0000000..e11644c --- /dev/null +++ b/tools/NUnit/doc/getStarted.html @@ -0,0 +1,80 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - GetStarted</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Getting Started with NUnit</h2> + +<p>If you haven't already done so, go to our <a href="http://www.nunit.org/download.html">Download</a> page, select a version of NUnit and download it. The + <a href="installation.html">Installation</a> page + contains instructions for installing on your system.</p> + +<p>To get started using NUnit, read the <a href="quickStart.html">Quick Start</a> page. This article demonstrates the development process with NUnit in the + context of a C# banking application. Check the + <a href="samples.html">Samples</a> page for additional examples, + including some in VB.Net, J# and managed C++.</p> + +<h3>Which Test Runner to use?</h3> + +<p>NUnit has two different ways to run your tests. The + <a href="nunit-console.html">console runner</a>, nunit-console.exe, + is the fastest to launch, but is not interactive. + The <a href="nunit-gui.html">gui runner</a>, + nunit.exe, is a Windows Forms application that allows you to work + selectively with your tests and provides graphical feedback.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li id="current"><a href="getStarted.html">Getting Started</a></li> +<ul> +<li><a href="quickStart.html">Quick Start</a></li> +<li><a href="installation.html">Installation</a></li> +</ul> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/guiCommandLine.html b/tools/NUnit/doc/guiCommandLine.html new file mode 100644 index 0000000..80448ec --- /dev/null +++ b/tools/NUnit/doc/guiCommandLine.html @@ -0,0 +1,193 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - GuiCommandLine</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit Command Line Options</h2> +<p>The forms interface may be run with or without the name of a file containing + tests on the command line. If the program is started without any file + specified, it automatically loads the most recently loaded assembly.</p> +<p><b>Note:</b> Options that take values may use an equal sign, a colon or a space + to separate the option from its value.</p> +<p><b>Note:</b> Under the Windows operating system, options may be prefixed by either + a forward slash or a hyphen. Under Linux, a hyphen must be used. Options that + take values may use an equal sign, a colon or a space to separate the option + from its value.</p> +<h4>Run without loading an Assembly</h4> +<p>To suppress loading of the most recent assembly, use the <b>/noload</b> switch: + <pre class="programtext"> nunit /noload</pre> +</p> +<h4>Specifying an Assembly</h4> +<p>The other option is to specify an assembly or project file name on the command + line. The following will start the forms interface with the assembly + nunit.tests.dll: + <pre class="programtext"> nunit nunit.tests.dll</pre> +</p> +<p>The following will start the forms interface loading the same assembly through + its Visual Studio project definition: + <pre class="programtext"> nunit nunit.tests.csproj</pre> +</p> +<p>Assuming an NUnit test project has been created containing the assembly, the + following will again load nunit.tests.dll: + <pre class="programtext"> nunit nunit.tests.nunit</pre> +</p> +<h4>Specifying an Assembly and a Fixture</h4> +<p> + When specifying a a fixture, you must give the full name of the test fixture + along with the containing assembly. For example, to load only the + NUnit.Tests.AssertionTests in the nunit.tests.dll assembly use the following + command: + <pre class="programtext"> nunit /fixture:NUnit.Tests.AssertionTests nunit.tests.dll</pre> +</p> +<p>The name specified after the <b>/fixture</b> option may be that of a TestFixture + class, or a namespace. If a namespace is given, then all fixtures under that + namespace are loaded. This option may be used with Visual Studio or NUnit + projects as well.</p> + +<h4>Specifying Test Categories to Include or Exclude</h4> +<p>NUnit provides CategoryAttribute for use in marking tests as belonging to + one or more categories. Categories may be included or excluded in a test run + using the <b>/include</b> or <b>/exclude</b> options. The following command + starts the gui with only the tests in the BaseLine category selected: + <pre class="programtext"> nunit myassembly.dll /include:BaseLine</pre> +</p> +<p>The following command selects all tests <b>except</b> those in the Database + category: + <pre class="programtext"> nunit myassembly.dll /exclude:Database</pre> +</p> +<p> +Multiple categories may be specified on either option, by using commas to +separate them. +<p><b>Note:</b> At this time, the /include and /exclude options may not be +combined on the command line.</p> +<!-- +<h4>Specifying the Version of the CLR</h4> + +<p>Most applications are written to run under a specific version of the CLR. +A few are designed to operate correctly under multiple versions. In either case, +it is important to be able to specify the CLR version to be used for testing.</p> + +<p>When only one version of the CLR is used, the config files for nunit and +nunit-console may be set up to specify that version. As a more convenient +alternative when switching CLRs, you may use the provided <b>clr.bat</b> +command to specify the version under which NUnit should run.</p> + +<p>For example, to run the gui under the RTM version of +the .Net 2.0 framework, use:</p> + +<pre class="programtext"> clr net-2.0 nunit</pre> + +<p>The <b>clr.bat</b> file is located in the NUnit <b>bin</b> directory. You may +put this on your path, or copy it to a convenient location. Enter <b>clr /?</b> +for a list of options.</p> + +<p><b>Note:</b> If you use a <startup> section in the config file, it takes +precedence over this option.</p> + +<p><b>Note:</b> This command is specific to the Microsoft .Net +framework. The Mono framework provides other means to specify the version +to be used when running a command and the NUnit Windows interface does +not currently run under Mono.</p> +--> + +<h4>Load and Run All Tests</h4> +Normally, nunit only loads an assembly and then waits for the user to click +on the Run button. If you wish to have the tests run immediately, use the <b>/run</b> +option: +<pre class="programtext"> nunit nunit.tests.dll /run</pre> +</p> +<h4>Load and Run Selected Tests</h4> +To load and immediately rerun the last selected tests, use the <b>/runselected</b> +option: +<pre class="programtext"> nunit nunit.tests.dll /runselected</pre> +</p> +<p><b>Note:</b> If no selection has been saved, this option works just like <b>/run</b>. +<h4>Specifying which Configuration to Load</h4> +<p>When loading a Visual Studio project or an NUnit project, the first + configuration found will be loaded by default. Usually this is Debug. The + configuration loaded may be controlled using the <b>/config</b> switch. The + following will load the Release configuration of the nunit.tests.dll: + <pre class="programtext"> nunit nunit.tests.csproj /config:Release</pre> +</p> +<p><b>Note:</b> This option has no effect when loading an assembly directly.</p> +<h4>Specifying Multiple Assemblies</h4> +<p>The forms interface does <b>not</b> currently provide for specifying more than + one assembly on the command line. Multiple-assembly projects must be loaded by + specifying the name of a Visual Studio solution file or an NUnit test project.</p> +<h4>Clearing the ShadowCopy Cache</h4> +<p>The <b>/cleanup</b> option erases the shadow copy cache and exits. +<h4>Displaying Help</h4> +<p>The <b>/help</b> or <b>/?</b> option displays a message box containing a brief + help message.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li id="current"><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/identityAsserts.html b/tools/NUnit/doc/identityAsserts.html new file mode 100644 index 0000000..eb60ec0 --- /dev/null +++ b/tools/NUnit/doc/identityAsserts.html @@ -0,0 +1,97 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - IdentityAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Identity Asserts</h2> + +<p><b>Assert.AreSame</b> and <b>Assert.AreNotSame</b> test whether the same objects are +referenced by the two arguments.</p> + +<div class="code" style="width: 36em" > +<pre>Assert.AreSame( object expected, object actual ); +Assert.AreSame( object expected, object actual, string message ); +Assert.AreSame( object expected, object actual, string message, + params object[] parms ); + +Assert.AreNotSame( object expected, object actual ); +Assert.AreNotSame( object expected, object actual, string message ); +Assert.AreNotSame( object expected, object actual, string message, + params object[] parms );</pre> +</div> + +<p><b>Assert.Contains</b> is used to test whether an object is contained in an array +or list.</p> + +<div class="code" width="36em"> +<pre>Assert.Contains( object anObject, IList collection ); +Assert.Contains( object anObject, IList collection, + string message ); +Assert.Contains( object anObject, IList collection, + string message, params object[] parms );</pre> +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li id="current"><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/ignore.html b/tools/NUnit/doc/ignore.html new file mode 100644 index 0000000..d4bef12 --- /dev/null +++ b/tools/NUnit/doc/ignore.html @@ -0,0 +1,267 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Ignore</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>IgnoreAttribute (NUnit 2.0)</h3> + +<p>The ignore attribute is an attribute to not run a test or test fixture for a + period of time. The person marks either a Test or a TestFixture with the Ignore + Attribute. The running program sees the attribute and does not run the test or + tests. The progress bar will turn yellow if a test is not run and the test will + be mentioned in the reports that it was not run.</p> + +<p>This feature should be used to temporarily not run a test or fixture. This is a + better mechanism than commenting out the test or renaming methods, since the + tests will be compiled with the rest of the code and there is an indication at + run time that a test is not being run. This insures that tests will not be + forgotten.</p> + +<h4>Test Fixture Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + [Ignore("Ignore a fixture")] + public class SuccessTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Ignore("Ignore a fixture")> + Public Class SuccessTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [Ignore("Ignore a fixture")] + public __gc class SuccessTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Ignore("Ignore a fixture") */ +public class SuccessTests +{ + // ... +} +</pre> + +</div> + +<h4>Test Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] + [Ignore("Ignore a test")] + public void IgnoredTest() + { /* ... */ } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> + Public Class SuccessTests + <Test(), Ignore("Ignore a test")> Public Sub Ignored() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test][Ignore("Ignore a test")] void IgnoredTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Ignore("ignored test") */ + public void IgnoredTest() + { /* ... */ } +} +</pre> + +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li id="current"><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/img/addinsDialog.jpg b/tools/NUnit/doc/img/addinsDialog.jpg Binary files differnew file mode 100644 index 0000000..8f404ce --- /dev/null +++ b/tools/NUnit/doc/img/addinsDialog.jpg diff --git a/tools/NUnit/doc/img/assembliesTab.jpg b/tools/NUnit/doc/img/assembliesTab.jpg Binary files differnew file mode 100644 index 0000000..5f28745 --- /dev/null +++ b/tools/NUnit/doc/img/assembliesTab.jpg diff --git a/tools/NUnit/doc/img/bulletOff.gif b/tools/NUnit/doc/img/bulletOff.gif Binary files differnew file mode 100644 index 0000000..c709ef4 --- /dev/null +++ b/tools/NUnit/doc/img/bulletOff.gif diff --git a/tools/NUnit/doc/img/bulletOn.gif b/tools/NUnit/doc/img/bulletOn.gif Binary files differnew file mode 100644 index 0000000..a565da5 --- /dev/null +++ b/tools/NUnit/doc/img/bulletOn.gif diff --git a/tools/NUnit/doc/img/configEditor.jpg b/tools/NUnit/doc/img/configEditor.jpg Binary files differnew file mode 100644 index 0000000..faa5188 --- /dev/null +++ b/tools/NUnit/doc/img/configEditor.jpg diff --git a/tools/NUnit/doc/img/console-mock.jpg b/tools/NUnit/doc/img/console-mock.jpg Binary files differnew file mode 100644 index 0000000..103cb5d --- /dev/null +++ b/tools/NUnit/doc/img/console-mock.jpg diff --git a/tools/NUnit/doc/img/generalOptions.jpg b/tools/NUnit/doc/img/generalOptions.jpg Binary files differnew file mode 100644 index 0000000..d547547 --- /dev/null +++ b/tools/NUnit/doc/img/generalOptions.jpg diff --git a/tools/NUnit/doc/img/generalTab.jpg b/tools/NUnit/doc/img/generalTab.jpg Binary files differnew file mode 100644 index 0000000..537e688 --- /dev/null +++ b/tools/NUnit/doc/img/generalTab.jpg diff --git a/tools/NUnit/doc/img/gui-screenshot.jpg b/tools/NUnit/doc/img/gui-screenshot.jpg Binary files differnew file mode 100644 index 0000000..9543aaa --- /dev/null +++ b/tools/NUnit/doc/img/gui-screenshot.jpg diff --git a/tools/NUnit/doc/img/gui-verify.jpg b/tools/NUnit/doc/img/gui-verify.jpg Binary files differnew file mode 100644 index 0000000..b3492af --- /dev/null +++ b/tools/NUnit/doc/img/gui-verify.jpg diff --git a/tools/NUnit/doc/img/langFilter.gif b/tools/NUnit/doc/img/langFilter.gif Binary files differnew file mode 100644 index 0000000..7cdf454 --- /dev/null +++ b/tools/NUnit/doc/img/langFilter.gif diff --git a/tools/NUnit/doc/img/logo.gif b/tools/NUnit/doc/img/logo.gif Binary files differnew file mode 100644 index 0000000..7540a66 --- /dev/null +++ b/tools/NUnit/doc/img/logo.gif diff --git a/tools/NUnit/doc/img/miniGui.jpg b/tools/NUnit/doc/img/miniGui.jpg Binary files differnew file mode 100644 index 0000000..cc5613f --- /dev/null +++ b/tools/NUnit/doc/img/miniGui.jpg diff --git a/tools/NUnit/doc/img/optionsDialog.jpg b/tools/NUnit/doc/img/optionsDialog.jpg Binary files differnew file mode 100644 index 0000000..2a2fe85 --- /dev/null +++ b/tools/NUnit/doc/img/optionsDialog.jpg diff --git a/tools/NUnit/doc/img/testLoadOptions.jpg b/tools/NUnit/doc/img/testLoadOptions.jpg Binary files differnew file mode 100644 index 0000000..0a5861b --- /dev/null +++ b/tools/NUnit/doc/img/testLoadOptions.jpg diff --git a/tools/NUnit/doc/img/testOutputOptions.jpg b/tools/NUnit/doc/img/testOutputOptions.jpg Binary files differnew file mode 100644 index 0000000..390ee90 --- /dev/null +++ b/tools/NUnit/doc/img/testOutputOptions.jpg diff --git a/tools/NUnit/doc/img/testProperties.jpg b/tools/NUnit/doc/img/testProperties.jpg Binary files differnew file mode 100644 index 0000000..6d486a2 --- /dev/null +++ b/tools/NUnit/doc/img/testProperties.jpg diff --git a/tools/NUnit/doc/index.html b/tools/NUnit/doc/index.html new file mode 100644 index 0000000..f63f02a --- /dev/null +++ b/tools/NUnit/doc/index.html @@ -0,0 +1,77 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - DocHome</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit 2.5.5</h2> + +<p>This documentation covers the NUnit 2.5.5 release, + introducing a large set of new features to NUnit, particularly in + the area of parameterized or data-driven testing. + +<p>Where applicable, we have marked sections with the version in which a feature + first appeared.</p> + +<p>If you are new to NUnit, we suggest you begin by reading the + <a href="getStarted.html">Getting Started</a> section of this site. + Those who have used earlier releases may want to begin with the + <a href="upgrade.html">Upgrading</a> section.</p> + +<p>See the + <a href="releaseNotes.html">Release Notes</a> for more information on this release.</p> + +<p>All documentation is included in the release packages of NUnit. Beginning with NUnit +2.4.2, you may choose to <a href="http://www.nunit.org/download.html">download</a> the documentation +separately.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li id="current"><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/installation.html b/tools/NUnit/doc/installation.html new file mode 100644 index 0000000..0153a93 --- /dev/null +++ b/tools/NUnit/doc/installation.html @@ -0,0 +1,126 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Installation</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Installation</h2> +<p>By default the <b>NUnit</b> installation program places all of the files into the + <b>C:\Program Files\NUnit 2.5.5</b> directory. + In the installation directory there are up to four sub-directories: net-1.1, + net-2.0, doc, and samples. The actual number depends on what the user has + chosen to install. Source code is no + longer provided with the binary installation package. Download the source + package if source is needed. +<h3>Running NUnit</h3> +<p>The installation program places a number of shortcuts in the start menu, which + run NUnit under .NET or Mono, depending on what is installed on your system. + For NUnit 2.5, the gui only runs under version 2.0 of the CLR, although tests + may be executed under other versions using a separate process. + +<h3>Configuration</h3> +<p>When running NUnit from the command line or through the desktop shortcut, the + configuration files files nunit.exe.config and nunit-console.exe.config control + the operation of NUnit itself. + Settings that you place in these files are not available to your tests or to the + production code you are testing. +<p>A separate config file is used for your tests themselves. + If you are running tests from the test.dll assembly, the config file + should be named test.dll.config. If you are running tests from the NUnit test + project MyTests.nunit, the config file should be named MyTests.config. In + either case the config file must reside in the same directory as the file from + which it takes its name.</p> +<p>In addition to settings of your own, the config file for a set of tests may + contain information used by NUnit in loading your tests. In particular, this + allows you to control the apartment state and priority of the thread that NUnit + uses to run your tests. Other settings may be added in the future.</p> +<p>See the <a href="configFiles.html">Configuration Files</a> + page for further information on configuration.</p> + +<h3>Installation Verification</h3> +<p>NUnit's own tests are available as an installation option. If you installed +the tests, you may verify that the installation has worked successfully by +running the NUnit gui and loading and running NUnitTests.nunit. All tests should pass. +<div class="screenshot-left"> + <img src="img/gui-verify.jpg"></div> +<p> +<p><b>Note:</b> Although the NUnit installation has been modified to allow non-admin + users to install, there are still a large number of tests which can only run + successfully under an administrative id. This is a problem with the code in + the tests themselves, not with NUnit.</p> +<h3>Timing Tests</h3> +<p>The assembly timing-tests.dll contains several tests that measure the performance of + NUnit in loading tests. In addition, it contains some long-running tests that are used + to verify that all remoting timeout problems have been fixed. The test cases + all run for six to 12 minutes and give no indication whatsoever that they are + working! This is required since correct handling of a non-communicative user + test is what these tests are all about.</p> +<h3>Additional Tests</h3> +<p>Additional tests are included with the samples and in separate assemblies used + as data by the verification tests themselves. Failures or not run conditions in + these tests are intentional.</p> + +<h3>Manual Installation</h3> + +<p>You may build NUnit from source using one of the Visual Studio solutions or + the NAnt script. In either case, an output directory is created, which + contains all files needed in the proper relative location. Just copy this + directory to a permanent location and create shortcuts if desired. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<ul> +<li><a href="quickStart.html">Quick Start</a></li> +<li id="current"><a href="installation.html">Installation</a></li> +<ul> +<li><a href="upgrade.html">Upgrading</a></li> +</ul> +</ul> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/license.html b/tools/NUnit/doc/license.html new file mode 100644 index 0000000..708b971 --- /dev/null +++ b/tools/NUnit/doc/license.html @@ -0,0 +1,88 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - License</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit License</h2> + +<p> +Copyright © 2002-2009 Charlie Poole<br> +Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov<br> +Copyright © 2000-2002 Philip A. Craig</p> +<p> This software is provided 'as-is', without any express or implied warranty. In + no event will the authors be held liable for any damages arising from the use + of this software.</p> +<p>Permission is granted to anyone to use this software for any purpose, including + commercial applications, and to alter it and redistribute it freely, subject to + the following restrictions:</p> +<p>1. The origin of this software must not be misrepresented; you must not claim + that you wrote the original software. If you use this software in a product, an + acknowledgment (see the following) in the product documentation is required.</p> +<p>Portions Copyright © 2002-2009 Charlie Poole or + Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. + Vorontsov or Copyright © 2000-2002 Philip A. Craig</p> +<p>2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software.</p> +<p>3. This notice may not be removed or altered from any source distribution.</p> + +<h4>License Note</h4> +<p>This license is based on <A href="http://www.opensource.org/licenses/zlib-license.html"> +the open source zlib/libpng license</A>. The idea was to keep the license +as simple as possible to encourage use of NUnit in free and commercial +applications and libraries, but to keep the source code together and to give +credit to the NUnit contributors for their efforts. While this license allows +shipping NUnit in source and binary form, if shipping a NUnit variant is the +sole purpose of your product, please <a href="mailto:cpoole@pooleconsulting.com">let +us know</a>.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li id="current"><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/listMapper.html b/tools/NUnit/doc/listMapper.html new file mode 100644 index 0000000..6065bc6 --- /dev/null +++ b/tools/NUnit/doc/listMapper.html @@ -0,0 +1,98 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ListMapper</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>List Mapper (NUnit 2.4.2)</h2> + +<p>Unlike Constraint classes, <b>ListMapper</b> is used to modify the actual +value argument to Assert.That(). It transforms the actual value, which +must be a collection, creating a new collection to be tested against the +supplied constraint. Currently, ListMapper supports one transformation: creating +a collection of property values. + +<p>Normally, ListMapper will be used through the <b>List.Map()</b> syntax helper +or the inherited syntax equivalent, <b>Map()</b>. The following example +shows three forms of the same assert: + +<div class="code"><pre> +string[] strings = new string[] { "a", "ab", "abc" }; +int[] lengths = new int[] { 1, 2, 3 }; + +Assert.That(List.Map(strings).Property("Length"), + Is.EqualTo(lengths)); + +Assert.That(new ListMapper(strings).Property("Length"), + Is.EqualTo(lengths)); + +// Assuming inheritance from AssertionHelper +Expect(Map(strings).Property("Length"), EqualTo(lengths)); +</pre></div> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li id="current"><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/mainMenu.html b/tools/NUnit/doc/mainMenu.html new file mode 100644 index 0000000..981740b --- /dev/null +++ b/tools/NUnit/doc/mainMenu.html @@ -0,0 +1,275 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - MainMenu</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Main Menu</h2> + +<hr><h3>File Menu</h3><hr> + +<h4>New Project…</h4> +<p>Closes any open project, prompting the user to save it if it has been changed and then opens a +FileSave dialog to allow selecting the name and location of the new project.</p> + +<h4>Open Project…</h4> +<p>Closes any open project, prompting the user to save it if it has been changed and then opens a +FileOpen dialog to allow selecting the name and location of an assembly, a test project or (if +Visual Studio support is enabled) a Visual Studio project.</p> + +<h4>Close</h4> +<p>Closes any open project, prompting the user to save it if it has been changed.</p> + + +<h4>Save</h4> +<p>Saves the currently open project. Opens the Save As dialog if this is the first time the project +is being saved.</p> + +<h4>Save As…</h4> +<p>Opens a FileSave dialog to allow specifying the name and location to which the project +should be saved.</p> + +<h4>Reload Project</h4> +<p>Completely reloads the current project by closing and re-opening it.</p> + +<h4>Reload Tests</h4> +<p>Reloads the tests, merging any changes into the tree.</p> + +<h4>Select Runtime</h4> +<p>Displays a list of runtime versions you may select in order to reload +the tests using that runtime. This submenu is only present if you have +more than one runtime version available. Any framework versions not supported +by your NUnit installation will be disabled until you install the +necessary NUnit components. + +<h4>Recent Files…</h4> +<p>Displays a list of recently opened files from which the user is able to select one for opening.</p> + +<h4>Exit</h4> +<p>Closes and exits the application. If a test is running, the user is given the opportunity to +cancel it and or to allow it to continue. If the open project has any pending changes, the user +is given the opportunity to save it.</p> + +<hr><h3>View Menu</h3><hr> + +<h4>Full Gui</h4> +<p>Displays the complete gui - as in prior versions of NUnit. This includes the + errors and failures and other tabs and the progress bar.</p> + +<h4>Mini Gui</h4> +<p>Switches the display to the mini-gui, which consists of the tree display + only.</p> + +<h4>Result Tabs</h4> +<p>Displays a submenu that allows showing or hiding the tabs on the right + hand side of the display.</p> + +<blockquote> +<h5>Errors & Failures, Tests Not Run, etc.</h5> +<p>Selects the individual tabs to display.</p> +</blockquote> + +<h4>Tree</h4> +<p>Displays the Tree submenu.</p> + +<blockquote> +<h5>Show Checkboxes</h5> +<p>Turns the display of checkboxes in the tree on or off. The checkboxes may + be used to select multiple tests for running.</p> + +<h5>Expand</h5> +<p>Expands the currently selected tree node.</p> + +<h5>Collapse</h5> +<p>Collapses the currently selected tree node.</p> + +<h5>Expand All</h5> +<p>Expands all nodes of the tree.</p> + +<h5>Collapse All</h5> +<p>Collapses all nodes in the tree to the root.</p> + +<h5>Hide Tests</h5> +<p>Collapses all fixture nodes, hiding the test cases.</p> + +<h5>Properties…</h5> +<p>Displays the Properties Dialog for the currently selected test.</p> +</blockquote> + +<h4>GUI Font</h4> +<p>Displays a submenu that allows changing the general font used by NUnit.</p> + +<blockquote> +<h5>Increase</h5> +<p>Increases the size of the font.</p> + +<h5>Decrease</h5> +<p>Decreases the size of the font.</p> + +<h5>Change...</h5> +<p>Displays the Font Change dialog.</p> + +<h5>Restore</h5> +<p>Restores the default font.</p> +</blockquote> + +<h4>Fixed Font</h4> +<p>Displays a submenu that allows changing the fixed font used to display +console output from the tests.</p> + +<blockquote> +<h5>Increase</h5> +<p>Increases the size of the fixed font.</p> + +<h5>Decrease</h5> +<p>Decreases the size of the fixed font.</p> + +<h5>Restore</h5> +<p>Restores the default fixed font.</p> +</blockquote> + +<h4>Assembly Details...</h4> +<p>Displays information about loaded test assemblies.</p> + +<h4>Status Bar</h4> +<p>Displays or hides the status bar.</p> + +<hr><h3>Project Menu</h3><hr> + +<h4>Configurations</h4> +<p>Displays a submenu allowing selecting, adding or editing a configuration. + +<blockquote> +<h5>Debug, Release, etc.</h5> +<p>Loads the specified configuration for testing.</p> + +<h5>Add…</h5> +<p>Opens the Add Configuration Dialog, which allows entry of the name of the new +configuration and specifying an existing configuration to use as a template.</p> + +<h5>Edit…</h5> +<p>Opens the <a href="configEditor.html">Configuration Editor</a>.</p> +</blockquote> + +<h4>Add Assembly…</h4> +<p>Displays a FileOpen dialog to allow selecting an assembly to be added to the active +configuration of the currently open project.</p> + +<h4>Add VS Project…</h4> +<p>Only available if Visual Studio Support is enabled. Displays a FileOpen dialog to allows +selecting a Visual Studio project to be added to the currently open project. Entries are added +for each configuration specified in the VS project, creating new configurations in the test +project if necessary.</p> + +<h4>Edit…</h4> +<p>Opens the <a href="projectEditor.html">Project Editor</a>.</p> + +<hr><h3>Test Menu</h3><hr> + +<h4>Run All</h4> +<p>Runs all the tests.</p> + +<h4>Run Selected</h4> +<p>Runs the test or tests that are selected in the tree. If checkboxes are visible, +any checked tests are run by preference. This is the same function provided by +the Run button.</p> + +<h4>Run Failed</h4> +<p>Runs only the tests that failed on the previous run.</p> + +<h4>Stop Run</h4> +<p>Stops the test run. This is the same function provided by the Stop button.</p> + +<hr><h3>Tools Menu</h3><hr> + +<h4>Save Results as XML…</h4> +<p>Opens a FileSave Dialog for saving the test results as an XML file.</p> + +<h4>Exception Details…</h4> +<p>Displays detailed information about the last exception.</p> + +<h4>Options...</h4> +<p>Displays the <a href="optionsDialog.html">Options Dialog</a>.</p> + +<h4>Addins...</h4> +<p>Displays the <a href="addinsDialog.html">Addins Dialog</a>.</p> + +<hr><h3>Help Menu</h3><hr> + +<h4>NUnit Help</h4> +<p>Displays the NUnit documentation, if installed. Otherwise, attempts to +connect to the NUnit web site.</p> + +<h4>About NUnit…</h4> +<p>Displays info about your version of NUnit and a link to the nunit.org site.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li id="current"><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/maxtime.html b/tools/NUnit/doc/maxtime.html new file mode 100644 index 0000000..d22b8a2 --- /dev/null +++ b/tools/NUnit/doc/maxtime.html @@ -0,0 +1,119 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Maxtime</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>MaxtimeAttribute (NUnit 2.5)</h3> + +<p>The <b>MaxtimeAttribute</b> is used on test methods to specify a maximum time + in milliseconds for a test case. If the test case takes longer than the + specified time to complete, it is reported as a failure. + +<h4>Example</h4> + +<div class="code"><pre> +[Test, Maxtime(2000)] +public void TimedTest() +{ + ... +} +</pre></div> + +<h4>Notes:</h4> + +<ol> +<li>Any assertion failures take precedence over the elapsed time check. +<li>This attribute does not cancel the test if the time +is exceeded. It merely waits for the test to complete and then +compares the elapsed time to the specified maximum. If you want to +cancel long-running tests, see <a href="timeout.html">TimeoutAttribute</a>. +</ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li id="current"><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/multiAssembly.html b/tools/NUnit/doc/multiAssembly.html new file mode 100644 index 0000000..21ff5da --- /dev/null +++ b/tools/NUnit/doc/multiAssembly.html @@ -0,0 +1,134 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - MultiAssembly</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Multiple-Assembly Support</h2> + +<p>Since version 2.1, NUnit has allowed loading suites of tests from multiple assemblies in both +the console and GUI runners. This may be done on an adhoc basis or by creating NUnit test projects +saved as files of type '.nunit'. In either case, a top-level suite is constructed, which contains +the root suite for each assembly. Tests are run and reported just as for a single assembly.</p> + +<h3>Adhoc Usage</h3> + +<p>Using the console runner, multiple assemblies may be run simply by specifying their names on the +command line. See <a href="consoleCommandLine.html">NUnit-Console Command Line Options</a> for +an example of this usage.</p> + +<p>The gui runner does not support specifying multiple assemblies on the command-line. +However, you can load a single assembly and then use the Project menu to add additional +assemblies. Additionally, you can drag multiple assemblies to the tree view pane, in which +case they will replace any assemblies already loaded.</p> + +<h3>NUnit Test Projects</h3> + +<p>Running tests from multiple assemblies is facilitated by the use of NUnit test projects. These are +files with the extension .nunit containing information about the assemblies to be loaded. The +following is an example of a hypothetical test project file:</p> + +<div class="code"> +<pre><NUnitProject> + <Settings activeconfig="Debug"/> + <Config name="Debug"> + <assembly path="LibraryCore\bin\Debug\Library.dll"/> + <assembly path="LibraryUI\bin\Debug\LibraryUI.dll"/> + </Config> + <Config name="Release"> + <assembly path="LibraryCore\bin\Release\Library.dll"/> + <assembly path="LibraryUI\bin\Release\LibraryUI.dll"/> + </Config> +</NUnitProject></pre> +</div> + +<p>This project contains two configurations, each of which contains two assemblies. The Debug +configuration is currently active. By default, the assemblies will be loaded using the directory +containing this file as the ApplicationBase. The PrivateBinPath will be set automatically to +<code>LibraryCore\bin\Debug;LibraryUI\bin\Debug</code> or to the corresonding release path. +XML attributes are used to specify non-default values for the ApplicationBase, Configuration +File and PrivateBinPath. The <a href="projectEditor.html">Project Editor</a> may +be used to create or modify NUnit projects.</p> + +<p>Even when you are running a single test assembly, NUnit creates an internal project +to contain that assembly. If you are using the gui, you can save this project, edit it, +add additional assemblies, etc. Note that the gui does not display the internal project +unless you add assemblies or modify it in some other way. + +<p>If you use <a href="vsSupport.html">Visual Studio Support</a> to load Visual +Studio .Net project or solution files, NUnit converts them to Test projects internally. +As with other internal projects, these test projects are not saved automatically but may +be saved by use of the File menu.</p> + +<h3>Loading and Running</h3> + +<p>In the past, test writers have been able to rely on the current directory being set to the +directory containing the single loaded assembly. For the purpose of compatibility, NUnit continues +to set the current directory to the directory containing each assembly whenever any test from that +assembly is run.</p> + +<p>Additionally, because some assemblies may rely on unmanaged dlls in the same directory, the +current directory is also set to that of the assembly at the time the assembly is loaded. However, +in cases where multiple assemblies reference the same unmanaged assembly, this may not be sufficient +and the user may need to place the directory containing the unmanaged dll on the path.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li id="current"><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/nunit-console.html b/tools/NUnit/doc/nunit-console.html new file mode 100644 index 0000000..245436c --- /dev/null +++ b/tools/NUnit/doc/nunit-console.html @@ -0,0 +1,111 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Nunit-console</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit-Console</h2> +<p>The nunit-console.exe program is a text-based runner and can be used when you + want to run all your tests and don’t need a red/yellow/green indication of + success or failure.</p> +<p>It is useful for automation of tests and integration into other systems. It + automatically saves its results in XML format, allowing you to produce reports + or otherwise process the results. The following is a screenshot of the console + program.</p> + +<div class="screenshot-left"> + <img src="img/console-mock.jpg"></div> +<p> +<p>In this example, nunit-console has just run the tests in the mock-assembly.dll + that is part of the NUnit distribution. This assembly contains a number of tests, some + of which are either ignored or marked explicit. The summary line shows the + result of the test run. Click <a href="files/TestResult.xml">here</a> + to see the XML produced for this test run.</p> + +<h3>NUnit-Console Return Codes</h3> + +<p>Beginning with version 2.4.3, the nunit-console program returns negative + values for any program errors. A zero return code indicates that there + were no errors and that all tests passed. A positive return code represents + the number of test errors or failures. + +<table class="constraints"> +<tr><th>0</th><td>OK</td><td>Run completed with all tests passing</td></tr> +<tr><th>> 0</th><td>FAILURE_COUNT</td><td>Run completed with one or more test failures</td></tr> +<tr><th>-1</th><td>INVALID_ARG</td><td>An invalid argument was passed to nunit-console</td></tr> +<tr><th>-2</th><td>FILE_NOT_FOUND</td><td>A file specified in the command line was not found</td></tr> +<tr><th>-3</th><td>FIXTURE_NOT_FOUND</td><td>A fixture specified in the command line was not found</td></tr> +</table> + +<h3>X86 Version</h3> + +<p>The .NET 2.0 version of the nunit-console program is built using /platform:anycpu, +which causes it to be jit-compiled to 32-bit code on a 32-bit system and 64-bit code +on a 64 bit system. This causes an exception when NUnit is used to test a 32-bit +application on a 64-bit system. To avoid this problem, use the nunit-console-x86 +program, which is built using /platform:x86, when testing 32-bit code on a +64-bit system. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li id="current"><a href="nunit-console.html">Console Runner</a></li> +<ul> +<li><a href="consoleCommandLine.html">Command-Line</a></li> +</ul> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/nunit-gui.html b/tools/NUnit/doc/nunit-gui.html new file mode 100644 index 0000000..b0bd2eb --- /dev/null +++ b/tools/NUnit/doc/nunit-gui.html @@ -0,0 +1,137 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Nunit-gui</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit Gui Runner</h2> +<p>The nunit.exe program is a graphical runner. It shows the tests in an + explorer-like browser window and provides a visual indication of the success or + failure of the tests. It allows you to selectively run single tests or suites + and reloads automatically as you modify and re-compile your code. The following + is a screenshot of NUnit running the same mock-assembly.dll shown in the + nunit-console example.</p> + +<div class="screenshot-left"> + <img src="img/gui-screenshot.jpg"></div> +<p> +<h4>Tree Display</h4> +<p>This version of NUnit uses symbols in the test tree, which allow those who + are unable to easily distinguish colors to determine the test status. + Successful tests are colored green, with a check mark. Tests that are ignored + are marked with a yellow circle, containing a question mark. If any + tests had failed, they would be marked red, with an X symbol.</p> + +<p>In this example, there were a total of 11 test cases, but one of them was not + counted because it was marked Explicit. Note that it is shown as a gray + circle in the tree. Of the remaining 10 tests, 5 were run successfully and + 5 were ignored.</p> + +<p>The symbols shown in the tree are actually files in the NUnit bin directory. + These files are named Success.jpg, Failure.jpg and Ignored.jpg and may be + modified or replaced by the user.</p> + +<h4>Progress Bar</h4> +<p>The progress bar shows the progress of the test. It is colored according +to the "worst" result obtained: red if there were any failures, yellow if +some tests were ignored and green for success. + +<h4>Result Tabs</h4> +<p>The tabs along the bottom of the display show the results of running +a test. The <b>Errors and Failures</b> tab displays the error message +and stack trace for both unexpected exceptions and assertion failures. +Beginning with NUnit 2.5, source code for each stack location can be displayed +in this tab - as is seen above - provided that the program was compiled with +debug information. + +<p>The <b>Tests Not Run</b> tab provides a list of all tests that were +selected for running but were not run, together with the reason. + +<p>The Text Output tab displays text output from the tests, potentially +including console output, trace output and log output. The default display +provides a single tab, but additional tabs may be created by the user to +hold specific kinds of output. For more information on creating new tabs, +see the documentation for the +<a href="settingsDialog.html">Settings Dialog</a>. + + +<h3>Mini-Gui</h3> + +<p>Since the release of NUnit 2.4, an alternate "mini-gui" is also available. It + may be selected from the View menu. In the following screenshot, the mini + gui window has been positioned next to the Visual Studio IDE so + that both windows can be seen.</p> + +<div class="screenshot-left"> + <img src="img/miniGui.jpg"></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li id="current"><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/nunit.css b/tools/NUnit/doc/nunit.css new file mode 100644 index 0000000..174dbbe --- /dev/null +++ b/tools/NUnit/doc/nunit.css @@ -0,0 +1,126 @@ +/* HTML Elements */ +html, body { margin: 0; padding: 0; } +body { font: 90% "Verdana", "Arial", "Helvetica", sans-serif; } +img { border: none; padding: 0; margin: 0;} +table { font: 1em "Verdana", "Arial", "Helvetica", sans-serif; } +h1 { font-size: 1.8em; font-weight: bold; } +h2 { font-size: 1.5em; font-weight: bold; } +h3 { font-size: 1.2em; font-weight: bold; } +h4 { font-size: 1em; font-weight: bold; } +ul.across { width: 100%; display: block; list-style: none; } +ul.across li { float: left; display: block; width: 9em } + +/* Masthead and Main Menu */ +#header { margin: 0; padding: 0; width: 100%; } +#header img { border: none; padding: 0; margin: 0;} +#header #logo { margin: 0; padding: 0; position: absolute; top: 15px; left: 15px} +#header #nav { min-width: 670px; margin: 25px 0 10px 200px; padding: 15px 0 15px 5px; + border-top: 1px solid black; border-bottom: 1px solid black; border-left: 1px solid black; + white-space: nowrap; } +/* Hide from IE-mac \*/ +* html #nav { height: 1%; } +/* End of IE-mac hack */ + +#nav a{ text-decoration: none; color: #000; font: small "Times New Roman", Roman, serif; + text-transform: uppercase; margin: 0 5px; padding: 5px 10px; border: 1px solid black; } +#nav a.active { background: #999; } +#nav a:hover { background: #CCC; } + +/* Submenu */ +#subnav { position: absolute; top: 100px; left: 76%; background-color: #ffd; + width: 24%; margin: 1em 0 0; padding: .25em ; border: solid #ccc; + border-width: .1em 0 .1em .1em; } +#subnav ul { margin: 0; padding: 0; list-style: none; } +#subnav li{ margin: 0; padding: 2px 0 2px; } +#subnav a { font: 1em "Times New Roman", Roman, serif; margin: 0; padding: 0 0 0 26px; + text-transform: uppercase; text-decoration: none; color: #000; white-space: nowrap; + background: url(img/bulletOff.gif) no-repeat 10px 50%; display: block} +#subnav ul ul a { padding: 0 0 0 46px; background-position: 30px 50%; } +#subnav ul ul ul a { padding: 0 0 0 66px; background-position: 50px 50%; } +#subnav ul ul ul ul a { padding: 0 0 0 86px; background-position: 70px 50%; } +#subnav ul ul ul ul ul a { padding: 0 0 0 106px; background-position: 90px 50%; } +#subnav li#current a{ background-image: url(img/bulletOn.gif) } +#subnav li a:hover { background-image: url(img/bulletOn.gif) } + +/* Main Content */ +#content { margin: 3em 25% 10px 0; padding: 0 5% 1em 5%; } +#content.wide { margin: 3em 5% 0 5%; padding: 0 5% 1em 5%; } +#content p { padding: 0; margin: 0 0 1em 0; max-width: 660px; } +#content ul { max-width: 660px; } +#content ol { max-width: 660px; } +#content blockquote { max-width: 580px } +#content div.screenshot { text-align: center; margin: 1em 0; } +#content div.screenshot-right { text-align: center; float: right; margin: 0 0 0 1em; } +#content img { padding: 0; margin: 0; border: 0 } + +/* Page Footer */ +#footer { text-align: center; font-size: .8em; color: #444; clear: both; + border-top: 2px solid #999; margin: 0 30% 10px 5%; padding: 5px 0 0 0; + page-break-after: always } +#sig { text-align: right; font-size: .8em; width: 95%; display: none } + +table.nunit { margin: 1em 5%; padding: 0; width: auto; border-collapse: collapse; } +table.nunit td, table.nunit th { border: 1px solid black; padding: 6px; text-align: left } +table.nunit th { background: #ccf; font-weight: bold; } + +table.articles { margin: 20px 0 0 5%; padding: 0 10px 0 0; } + +table.downloads { margin: 1em 5%; padding: 0; width: 24em; border-collapse: collapse; } +table.downloads td, table.downloads th { border: 1px solid black; padding: 2px; text-align: left } +table.downloads th { background: #ccf; font-weight: bold; } + +table.platforms { margin: 1em 0; padding: 0; width: 24em; border-collapse: collapse; } +table.platforms td, table.platforms th { border: 1px solid black; padding: 5px; text-align: center } +table.platforms th { background: #ccf; font-weight: bold; } + +table.constraints { margin: 1em 0; padding: 0; width: auto; border-collapse: collapse; } +table.constraints td, table.constraints th { border: 1px solid black; padding: 6px; text-align: left } +table.constraints th { background: #ccf; font-weight: bold; text-align: center } + +table.roadmap { margin: 1em 0; padding: 0; width: auto; border-collapse: collapse; } +table.roadmap td, table.roadmap th { border: 1px solid black; padding: 10px; text-align: left } +table.roadmap th { background: #eef; font-weight: bold; } + +table.extensions { margin: 1em 2%; border-collapse: collapse; width: 96%; } +table.extensions td, table.extensions th { border: solid black 1px; padding: 6px } +table.extensions th { background: #bbf; font-weight: bold; text-align: center } +table.extensions td.label { font-weight: bold; text-align: left; width: 10em } + +table.quote { margin-left: 30px; margin-right: 30px; background: #FFFFFF; border: 3px black solid; + font: 1.1em/1.5em "Times New Roman", Roman, serif; font-variant: small-caps; + letter-spacing: .1em; padding: 0 } +table.quote td { padding: 0 } +table.quote td.sig { border-left: solid black 1px; padding-left: 15px } + +#news { position: absolute; top: 100px; left: 76%; border-left: 1px solid black; + width: 14%; margin: 1em 0 0; padding: 0 5%; font-size: .8em; background-color: #fff } +#news h4 { font: 1.2em "Times New Roman", Roman, serif; font-variant: small-caps; text-align: center; margin: 0 0 1em; } + +div.code { border: 1px solid #888; background-color: #ccf; width: 36em; + margin: 1.5em 0; padding: 2px 0; position: relative; } +div.code pre { font: .8em "Courier New", Courier, monospace; margin: 0 1em .25em; } +div.langFilter { position: absolute; top: 100px; left: 5%; } +div.code div.langFilter { position: absolute; top: -15px; left: 0;} +div.dropdown { position: absolute; top: 0; left: 14px; padding: 0 10px; width: 20px; + text-align: left; border: 1px solid #888; background-color: #ffd; } +div.code div.dropdown { position: absolute; left: 14px; top: 0; padding: 0 10px; width: 20px; + text-align: left; border: 1px solid #888; background-color: #ffd; } +div.notice { + margin-left: 2em; + margin-right: 2em; + text-align: center; + font-style: italic; + font-weight: bold; +} + +/* +#content.wide p { width: expression( document.documentElement.clientWidth > 700 ? "660px" : "auto" ); } +#content.wide blockquote { width: expression( document.documentElement.clientWidth > 700 ? "580px" : "auto" ); } + +pre, .programText { font-family: "Courier New", Courier, Monospace; color: #000; font-size: 1em } + +// The following was needed for IE in quirks mode - probably still needed for IE 5 + div.code div.langFilter { position: absolute; top: -14px; left: -1em; } + +// Special handling for absence of max-width in IE +*/ diff --git a/tools/NUnit/doc/nunitAddins.html b/tools/NUnit/doc/nunitAddins.html new file mode 100644 index 0000000..c3f71d2 --- /dev/null +++ b/tools/NUnit/doc/nunitAddins.html @@ -0,0 +1,223 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - NunitAddins</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>NUnit Addins</h2> + +<p>NUnit originally identified tests in the time-honored way used in many xUnit +test frameworks. Test classes inherited from the framework's +TestCase class. Individual test case methods were identified by having names +starting with "test..."</p> + +<p>With NUnit 2.0, we introduced the use of attributes to identify both fixtures +and test cases. Use of attributes in this way was a natural outcome of their +presence in .NET and gave us a way of identifying tests that was completely +independent of both inheritance and naming conventions.</p> + +<p>However, by moving away from an inheritance-based mechanism we no longer +had an easy way for others to extend NUnit's internal behavior. NUnit Addins are +intended to fill that gap, providing an mechanism to introduce new or changed +behavior without modifying NUnit itself.</p> + +<h3>Extension Points, Extensions and Addins</h3> + +<p>NUnit provides a number of <b>Extension Points</b>, places where it is +possible to extend its behavior. Because NUnit works with various hosts +and uses separate AppDomains to run tests, <b>Extension Points</b> are +categorized into three types: Core, Client and Gui. Each of these types is +supported by a different <b>Extension Host</b>. + +<p>An NUnit <b>Addin</b> provides enhanced functionality through one or more +extensions, which it installs at identified <b>Extension Points</b>. Each +<b>Addin</b> is characterized by the types of extensions it supplies, so that +an <b>Extension Host</b> knows whether to invoke it.</p> + +<blockquote> +<p><b>Note:</b> In the current release, only Core extensions are actually +supported. An Addin may characterize itself as a Client or Gui extension and +will be listed as such in the <a href="addinsDialog.html">Addins Dialog</a>, +but no other action is taken.</p> +</blockquote> + +<h3>Addin Identification, Loading and Installation</h3> + +<p>NUnit examines all assemblies in the <b>bin/addins</b> directory, looking +for public classes with the <b>NUnitAddinAttribute</b> and implementing the +<b>IAddin</b> interface. It loads all those it finds as Addins.</p> + +<p><b>NUnitAddinAttribute</b> supports three optional named parameters: Type, +Name and Description. Name and Description are strings representing the name +of the extension and a description of what it does. If no name is provided, +the name of the class is used. Type may be any one or a combination of the +ExtensionType enum members: + +<pre> + [Flags] + public enum ExtensionType + { + Core=1, + Client=2, + Gui=4 + } +</pre> + +The values may be or'ed together, allowing for future Addins that require +extensions at multiple levels of the application. If not provided, Type +defaults to ExtensionType.Core.</p> + +<p>The <b>IAddin</b> interface, which must be implemented by each Addin, +is defined as follows:</p> + +<pre> + public interface IAddin + { + bool Install( IExtensionHost host ); + } +</pre> + +<p> The <b>Install</b> method is called by each host for which the addin has +specified an ExtensionType. The addin should check that the necessary extension +points are available and install itself, returning true for success or false +for failure to install. The method will be called once for each extension +host and - for Core extensions - each time a new test domain is loaded.</p> + +<p>The Install method uses the <b>IExtensionHost</b> interface to locate +extension points. It is defined as follows:</p> + +<pre> + public interface IExtensionHost + { + IExtensionPoint[] ExtensionPoints { get; } + IExtensionPoint GetExtensionPoint( string name ); + ExtensionType ExtensionTypes { get; } + } +</pre> + +<p>The <b>ExtensionPoints</b> property returns an array of all extension points +for those extensions that need the information. The <b>ExtensionTypes</b> +property returns the flags for the type of extension supported by this host, +allowing, for example, Gui extensions to only load in a Gui host.</p> + +<p>Most addins will only need to use the <b>GetExtensionPoint</b> method to +get the interface to a particular extension point. The <b>IExtensionPoint</b> +interface is defined as follows:</p> + +<pre> + public interface IExtensionPoint + { + string Name { get; } + IExtensionHost Host { get; } + void Install( object extension ); + void Remove( object extension ); + } +</pre> + +<p>Once again, most addins will only need to use one method - the +<b>Install</b> method in this case. This method passes an extension object +to the <b>Extension Point</b> where it is installed. Generally, extensions +do not need to remove themselves once installed, but the method is +provided in any case.</p> + +<p>With NUnit 2.5, an additional interface, <b>IExtensionPoint2</b> is +available. It derives from <b>IExtensionPoint</b> and also allows setting +the priority order in which the extension will be called in comparison to +other extensions on the same extension point. The interface is defined +as follows: + +<pre> + public interface IExtensionPoint2 : IExtensionPoint + { + void Install( object extension, int priority ); + } +</pre> + +<p>Only extension points that use a priority scheme implement this interface. +In general, extension points with a priority scheme will use a default value +for priority if the Install method without a priority is called. + +<p>In the NUnit 2.5 release, only the <b>TestDecorators</b> extension point implements +<b>IExtensionPoint2</b>. + +<h3>Extension Point Details</h3> + +<p>Depending on the particular extension point, the object passed will +need to implement one or more interfaces. The following <b>ExtensionPoints</b> +are implemented in this release of NUnit: + +<ul> + <li><a href="suiteBuilders.html">SuiteBuilders</a> <li><a href="testcaseBuilders.html">TestCaseBuilders</a> <li><a href="testDecorators.html">TestDecorators</a> <li><a href="testcaseProviders.html">TestCaseProviders</a> <li><a href="datapointProviders.html">DataPointProviders</a> <li><a href="eventListeners.html">EventListeners</a></ul></p> + +<p>For examples of implementing each type of extension, see the Extensibility +samples provided with NUnit. More complete examples are available in the +code of NUnit itself, since NUnit uses the same mechanism internally.</p> + +<h4>See also...</h4> + +<ul> +<li><a href="extensionTips.html">Tips for Writing Extensions</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li id="current"><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/pairwise.html b/tools/NUnit/doc/pairwise.html new file mode 100644 index 0000000..a2343f5 --- /dev/null +++ b/tools/NUnit/doc/pairwise.html @@ -0,0 +1,109 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Pairwise</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>PairwiseAttribute (NUnit 2.5)</h3> + +<p>The <b>PairwiseAttribute</b> is used on a test to specify that NUnit should + generate test cases in such a way that all possible pairs of + values are used. This is a well-known approach for combatting + the combinatorial explosion of test cases when more than + two features (parameters) are involved. + +<p><b>Note:</b> In the current Alpha release, this attribute is +accepted but ignored and data items are combined usin the default +combinatorial approach. + +<h4>See also...</h4> +<ul> +<li><a href="sequential.html">SequentialAttribute</a><li><a href="combinatorial.html">CombinatorialAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li id="current"><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/parameterizedTests.html b/tools/NUnit/doc/parameterizedTests.html new file mode 100644 index 0000000..7893847 --- /dev/null +++ b/tools/NUnit/doc/parameterizedTests.html @@ -0,0 +1,155 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ParameterizedTests</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Parameterized Tests</h2> + +<p>NUnit 2.5 supports parameterized tests. Test methods +may have parameters and various attributes are available +to indicate what arguments should be supplied by NUnit. + +<p>Multiple sets of arguments cause the creation of multiple +tests. All arguments are created at the point of loading the +tests, so the individual test cases are available for +display and selection in the Gui, if desired. + +<p>Some attributes allow you to specify arguments inline - directly on + the attribute - while others use a separate method, property or field + to hold the arguments. In addition, some attributes identify complete test cases, + including all the necessary arguments, while others only provide data + for a single argument. This gives rise to four groups of attributes, + as shown in the following table. + +<table class="nunit"> +<tr><th></th><th>Complete Test Cases</th><th>Data for One Argument</th></tr> +<tr><th>Inline</th> + <td><a href="testCase.html">TestCaseAttribute</a></td> + <td><a href="random.html">RandomAttribute</a><br> + <a href="range.html">RangeAttribute</a><br> + <a href="values.html">ValuesAttribute</a></td></tr> +<tr><th>Separate</th> + <td><a href="testCaseSource.html">TestCaseSourceAttribute</a></td> + <td><a href="valueSource.html">ValueSourceAttribute</a></td></tr> +</table> + +<p>In addition, when data is specified for individual arguments, special attributes +may be added to the test method itself in order to tell NUnit how +to go about combining the arguments. Currently, the following attributes +are provided: + +<ul> +<li><a href="combinatorial.html">CombinatorialAttribute</a> (default) +<li><a href="pairwise.html">PairwiseAttribute</a><li><a href="sequential.html">SequentialAttribute</a></ul> + +<h3>Order of Execution</h3> + +<p>In NUnit 2.5, individual test cases are sorted alphabetically and executed in + that order. With NUnit 2.5.1, the individual cases are not sorted, but are + executed in the order in which NUnit discovers them. This order does <b>not</b> + follow the lexical order of the attributes and will often vary between different + compilers or different versions of the CLR. + +<p>The following specific rules for ordering apply: +<ol> +<li>If all arguments are specified in a <b>single TestCaseSource</b> attribute, + the ordering of the cases provided will be maintained. +<li>If each parameter has a <b>single Values</b>, <b>ValueSource</b> or + <b>Range</b> attribute and the <b>Sequential</b> combining strategy + is used - or there is only one argument - the ordering will be maintained. +<li>In all other cases, including using multiple <b>TestCase</b> attributes + or a combination of different types of attributes, the ordering of the + test cases is undefined. +</ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<ul> +<li id="current"><a href="parameterizedTests.html">Parameterized Tests</a></li> +</ul> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/pathConstraints.html b/tools/NUnit/doc/pathConstraints.html new file mode 100644 index 0000000..4024c39 --- /dev/null +++ b/tools/NUnit/doc/pathConstraints.html @@ -0,0 +1,157 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - PathConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Path Constraints (NUnit 2.5)</h2> + +<p>Path constraints perform tests on paths, without reference to any + actual files or directories. This allows testing paths that are + created by an application for reference or later use, without + any effect on the environment. + +<p>Path constraints are intended to work across multiple file systems, + and convert paths to a canonical form before comparing them. + +<p>It is usually not necessary to know the file system of the paths + in order to compare them. Where necessary, the programmer may + use the <b>IgnoreCase</b> and <b>RespectCase</b> modifiers to provide + behavior other than the system default. + +<h3>SamePathConstraint</h3> + +<h4>Action</h4> +<p>Tests that two paths are equivalent. + +<h4>Constructor</h4> +<div class="code"><pre> +SamePathConstraint( string expectedPath ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.SamePath( string expectedPath ) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +...RespectCase +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +Assert.That( "/folder1/./junk/../folder2", + Is.SamePath( "/folder1/folder2" ) ); +Assert.That( "/folder1/./junk/../folder2/x", + Is.Not.SamePath( "/folder1/folder2" ) ); + +Assert.That( @"C:\folder1\folder2", + Is.SamePath( @"C:\Folder1\Folder2" ).IgnoreCase ); +Assert.That( "/folder1/folder2", + Is.Not.SamePath( "/Folder1/Folder2" ).RespectCase ); +</pre></div> + +<h3>SamePathOrUnderConstraint</h3> + +<h4>Action</h4> +<p>Tests that one path is equivalent another path or that it is under it. + +<h4>Constructor</h4> +<div class="code"><pre> +SamePathOrUnderConstraint( string expectedPath ) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.SamePathOrUnder( string expectedPath ) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +...RespectCase +</pre></div> + +<h4>Examples of Use</h4> + +<div class="code"><pre> +Assert.That( "/folder1/./junk/../folder2", + Is.SamePathOrUnder( "/folder1/folder2" ) ); +Assert.That( "/folder1/junk/../folder2/./folder3", + Is.SamePathOrUnder( "/folder1/folder2" ) ); +Assert.That( "/folder1/junk/folder2/folder3", + Is.Not.SamePathOrUnder( "/folder1/folder2" ) ); + +Assert.That( @"C:\folder1\folder2\folder3", + Is.SamePathOrUnder( @"C:\Folder1\Folder2" ).IgnoreCase ); +Assert.That( "/folder1/folder2/folder3", + Is.Not.SamePathOrUnder( "/Folder1/Folder2" ).RespectCase ); +</pre></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li id="current"><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/platform.html b/tools/NUnit/doc/platform.html new file mode 100644 index 0000000..0c9dc28 --- /dev/null +++ b/tools/NUnit/doc/platform.html @@ -0,0 +1,309 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Platform</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<style><!-- +div.code { width: 34em } +--></style> + +<h3>PlatformAttribute (NUnit 2.2.2)</h3> +<p>The Platform attribute is used to specify platforms for which a test or fixture + should be run. Platforms are specified using case-insensitive string values + and may be either included or excluded from the run by use of the Include or + Exclude properties respectively. Platforms to be included may alternatively + be specified as an argument to the PlatformAttribute constructor. In either + case, multiple comma-separated values may be specified. + +<p>If a test or fixture with the Platform attribute does not satisfy the specified + platform requirements it is skipped. The test does not affect the outcome of + the run at all: it is not considered as ignored and is not even counted in + the total number of tests. In the gui, the tree node for the test remains + gray and the status bar color is not affected.</p> + +<blockquote><i><b>Note:</b> In versions of NUnit prior to 2.4, these tests were + shown as ignored.</i></blockquote> + +<h4>Test Fixture Syntax</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + [Platform("NET-2.0")] + public class DotNetTwoTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Platform("NET-2.0")> + Public Class DotNetTwoTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [Platform("NET-2.0")] + public __gc class DotNetTwoTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Platform("NET-2.0") */ +public class DotNetTwoTests +{ + // ... +} +</pre> +</div> +<h4>Test Syntax</h4> +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD2')" onmouseover="Show('DD2')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD2" class="dropdown" style="display: none;" onclick="Hide('DD2')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] + [Platform(Exclude="Win98,WinME")] + public void SomeTest() + { /* ... */ } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> + Public Class SuccessTests + <Test(), Platform(Exclude="Win98,WinME")> Public Sub SomeTest() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test][Platform(Exclude="Win98,WinME")] void SomeTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Platform(Exclude="Win98,WinME") */ + public void SomeTest() + { /* ... */ } +} +</pre> + +</div> + +<h3>Platform Specifiers</h3> +<p>The following values are recognized as platform specifiers. + They may be expressed in upper, lower or mixed case.</p> + +<ul class="across"> +<li>Win</li> +<li>Win32</li> +<li>Win32S</li> +<li>Win32Windows</li> +<li>Win32NT</li> +<li>WinCE</li> +<li>Win95</li> +<li>Win98</li> +<li>WinMe</li> +<li>NT3</li> +<li>NT4</li> +<li>NT5</li> +<li>NT6</li> +<li>Win2K</li> +<li>WinXP</li> +<li>Win2003Server</li> +<li>Vista</li> +<li>Win2008Server</li> +<li>Unix</li> +<li>Linux</li> +<li>Net</li> +<li>Net-1.0</li> +<li>Net-1.1</li> +<li>Net-2.0</li> +<li>Net-4.0</li> +<li>NetCF</li> +<li>SSCLI</li> +<li>Rotor</li> +<li>Mono</li> +<li>Mono-1.0</li> +<li>Mono-2.0</li> +</ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li id="current"><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/pnunit.html b/tools/NUnit/doc/pnunit.html new file mode 100644 index 0000000..9cd5ad7 --- /dev/null +++ b/tools/NUnit/doc/pnunit.html @@ -0,0 +1,98 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Pnunit</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>PNUnit</h2> + +<p><b>PNUnit</b> stands for "Parallel NUnit." It is an extension of NUNit +developed by Pablo Santos Luaces and his team at Codice Software for +their internal use in testing the Plastic (TM) Software Configuration +Management System. Codice released PNUnit to the community in 2007. + +<p>As part of the NUnit 2.5 release, we worked with the NUnit and PNUnit +teams worked together to make PNUnit work with NUnit without any modifications. +PNUnit is now included in the NUnit distribution. + +<h3>How it Works</h3> + +<p><b>PNUnit</b> is not intended for "casual" parallelism merely to +make the tests run faster. Rather, it's intended as a way to test +applications composed of distributed, communicating components. Tests +of each component run in parallel and use memory barriers to synchronize +their operation. + +<p>PNUnit uses a special executable to launch its tests. +The launcher reads an xml file that specifies the tests to be +executed and where they should run, whether on the same machine or +on another machine on the network. + +<p>For more information about using PNUnit, consult the +<a href="http://www.codicesoftware.com/opdownloads2/oppnunit.aspx">documentation</a> +at <a href="http://www.codicesoftware.com">www.codicesoftware.com</a> + +<h3>Future Plans</h3> + +<p>PNUnit will be integrated with NUnit so that parallel, distributed tests +may be used through the normal NUnit console or gui runners. +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li id="current"><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/projectEditor.html b/tools/NUnit/doc/projectEditor.html new file mode 100644 index 0000000..95507d8 --- /dev/null +++ b/tools/NUnit/doc/projectEditor.html @@ -0,0 +1,219 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ProjectEditor</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Project Editor</h2> + +<p>The Project Editor is displayed through the Project | Edit menu item and allows creating or +modifying NUnit test projects. It should be noted that a Test Project is active whenever any tests +have been loaded, even if no project was explicitly created or referenced. In the case of an +assembly being loaded, an internal wrapper project is created. This allows the user to change +settings and save the project directly without needing to perform any extra steps. The editor +consists of a common area and two tabs, as seen in the image below.</p> + +<h3>Common Area</h3> + +<p>The common area of the Project Editor contains information pertaining to + the project as a whole. Information that applies to a particular configuration + is displayed in the General and Assemblies tabs. + +<h4>Project Path</h4> +<p>This label shows the full path to the project file. In the case of a + wrapper project, the path is set to the same directory as the assembly + that was initially opened. + +<h4>Application Base</h4> +<p>This TextBox allows the user to change the project AppBase, which defaults to + the directory of the project file. The button to the right of the TextBox + allows the user to browse and select a directory. + +<h4>Process Model</h4> +<p>This dropdown list allows you to specify how operating system processes are + used in loading and running the tests in this project. Four settings are + defined: + <ul> + <li>The <b>Default</b> setting refers to the option selected by the user + on the Assembly Isolation page of the NUnit Settings Dialog. + <li><b>Single</b> means that tests are run in a test domain in the + same process as NUnit. This is the way previous versions of NUnit + ran tests. + <li><b>Separate</b> means that all the tests are run in a separate process + that NUnit creates. + <li><b>Multiple</b> means that NUnit will create a separate process for + each test assembly in the project and run its tests there. + </ul> + +<h4>Domain Usage</h4> +<p>This dropdown list allows you to specify how tests are loaded into + AppDomains by NUnit. Three settings are defined: + <ul> + <li>The <b>Default</b> setting refers to the option selected by the user + on the Assembly Isolation page of the NUnit Settings Dialog. + <li><b>Single</b> means that all tests will run in a single test domain + created by NUnit. This was the way versions of NUnit prior to 2.4 + ran tests. + <li><b>Multiple</b> means that each test assembly is loaded into a + separate AppDomain. This setting is not available when Multiple + processes are selected in the Process Model dropown. + </ul> + +<h4>Configuration</h4> +<p>This dropdown list allows you to select the particular configuration + within a project that is displayed in the bottom part of the dialog. + +<h4>Edit Configs...</h4> +<p>This button opens the + <a href="configEditor.html">Configuration Editor</a>, + which allows you to add, delete or rename configs and set the + active configuration. + +<div class="screenshot-left"> +<img src="img/generalTab.jpg"></div> + +<h3>General Tab</h3> + +<p>The General tab allows setting a number of options pertaining to the selected configuration, all of +which will be stored in the NUnit project file as attributes of the <config> xml node.</p> + +<h4>Runtime</h4> +<p>This dropdown allows you to select a particular runtime framework to be used + for loading and running tests under the current configuration. Currently, + only Microsoft .NET and Mono are supported. If <b>Any</b> is selected, the + tests will be run under the same runtime that NUnit itself is currently using. + +<h4>Version</h4> +<p>This ComboBox allows you to select the particular version of the runtime framework + to be used for loading and running tests under the current configuration. The + dropdown list contains entries for + <ul> + <li>Default + <li>1.0 + <li>1.1 + <li>2.0 + <li>4.0 + </ul> + +<p>If you select "Default" the assemblies in the project are examined to determine + the version that is required. + See <a href="runtimeSelection.html">Runtime Selection</a> for + more information on how NUnit selects the version to be used. + +<p>In special cases, you may wish to enter a version number that is not listed + in the list box. You may specify the version using two, three or four + components. The version you provide will be saved as you enter it. Leaving + the text box blank is equivalent to selecting "Default." + +<p><b>Note:</b> Running tests under a different runtime or version from the one that NUnit + is currently using will force them to run in a separate process. + +<p><b>Note:</b> To conform with normal usage, specifying Mono as the runtime + with "1.0" as the version results in use of the Mono 1.0 profile, equating + to version 1.1.4322. + +<h4>ApplicationBase</h4> +<p>The ApplicationBase defaults to the directory containing the project file. Beginning +with NUnit 2.2.3, it may be set to any location that is desired.</p> + +<h4>Configuration File Name</h4> +<p>The configuration file defaults to the name of the test project with the extension changed +from .nunit to .config. The user may substitute another name.</p> + +<h4>PrivateBinPath</h4> +<p>By default, the PrivateBinPath is generated from the assembly locations specified on the +Assemblies Tab. For those applications requiring a different level of control, it may be +specified manually or using this editor or placed in the configuration file.</p> + +<h3>Assemblies Tab</h3> + +<p>The assemblies tab contains the list of assemblies that form part of this test project.</p> + +<p>Note: Although the dialog shows the location of assemblies as absolute paths, they are always +persisted in the NUnit project file as paths relative to the application base. This allows moving +projects as a whole to a different directory location.</p> + +<div class="screenshot-left"> +<img src="img/assembliesTab.jpg"></div> + +<h4>Add...</h4> +<p>Opens a dialog allowing adding an assembly to this configuration. If Visual +Stuio support is enabled, you may also select and add a VS project.</p> + +<h4>Remove</h4> +<p>After confirmation, removes the selected assembly from this configuration.</p> + +<h4>Assembly Path</h4> +<p>This text box displays the full path to the selected assembly. You may edit +the contents to change the path to the assembly. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li id="current"><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/property.html b/tools/NUnit/doc/property.html new file mode 100644 index 0000000..ec0d208 --- /dev/null +++ b/tools/NUnit/doc/property.html @@ -0,0 +1,243 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Property</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>PropertyAttribute (NUnit 2.4)</h3> + +<p>The Property attribute provides a generalized approach to setting named + properties on any test case or fixture, using a name/value pair.</p> + +<p>In the example below, the fixture class MathTests is given a Location + value of 723 while the test case AdditionTest is given a Severity + of "Critical"</p> + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture, Property("Location",723)] + public class MathTests + { + [Test, Property("Severity", "Critical")] + public void AdditionTest() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), Property("Location",723)> + Public Class MathTests + + <Test(), Property("Severity","Critical")> + Public Sub AdditionTest() + ' ... + End Sub + + End Class + +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture, Property("Location",723)] + public __gc class MathTests + { + [Test, Property("Severity","Critical")] void AdditionTest(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.Property("Location",723) */ +public class MathTests +{ + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Property("Severity","Critical") */ + public void AdditionTest() + { /* ... */ } +} +</pre> + +</div> + +<h4>Usage Note</h4> + +<p>The PropertyAttribute is not used for any purpose by NUnit itself, but +it does display them in the XML output file and in the Test Properties +dialog of the gui.</p> + +<p>It is + possible to write extensions that access the value of specific properties. + It is also possible to access the value of properties from within a test + using reflection.</p> + +<h3>Custom Property Attributes</h3> + +<p>Users can define custom +attributes that derive from <b>PropertyAttribute</b> and have them +recognized by NUnit. PropertyAttribute provides a protected constructor +that takes the value of the property and sets the property name to the +name of the derived class. NUnit itself uses this facility: some of +it's specialized attributes are actually specializations of <b>PropertyAttribute</b>. + +<p>Here's an example that creates a Severity property. It works +just like any other property, but has a simpler syntax and is type-safe. +A test reporting system might make use of the property to provide special reports. + +<div class=code><pre> +public enum SeverityLevel +{ + Critical, + Major, + Normal, + Minor +} + +[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] +public class SeverityAttribute : PropertyAttribute +{ + public SeverityAttribute( SeverityLevel level ) + : base( level ); +} + +... + +[Test, Severity( SeverityLevel.Critical)] +public void MyTest() +{ /*...*/ } +</pre></div> + +<p>Beginning with NUnit 2.5, a property attribute is able to contain +multiple name/value pairs. This capability is not exposed publicly +but may be used by derived property classes. NUnit uses this +feature itself for certain attributes. See, for example, +<a href="requiresThread.html">RequiresThreadAttribute</a>. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li id="current"><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/propertyConstraint.html b/tools/NUnit/doc/propertyConstraint.html new file mode 100644 index 0000000..6f1d0f6 --- /dev/null +++ b/tools/NUnit/doc/propertyConstraint.html @@ -0,0 +1,87 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - PropertyConstraint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Property Constraint (NUnit 2.4.2)</h2> + +<p>PropertyConstraint is used to test for existence of a named property and +optionally tests its value. It may also be used as a prefix for other constraints +to be applied to the property. + +<table class="constraints"> +<tr><th>Syntax Helper</th><th>Constructor</th><th>Operation</th></tr> +<tr><td>Has.Property( string )</td><td>PropertyConstraint( string )</td></td><td>tests that a specific property exists</td></tr> +<tr><td>Has.Property( string, object )</td><td>PropertyConstraint( string, object )</td></td><td>tests that the value of a property is equal to the value provided</td></tr> +<tr><td>Has.Property( string, Constraint)...</td><td>PropertyConstraint</td></td><td>applies the following constraint to the value of a named property</td></tr> +<tr><td>Has.Length( int )</td><td>PropertyConstraint</td></td><td>tests that the object's Length property is equal to the value given</td></tr> +<tr><td>Has.Count( int )</td><td>PropertyConstraint</td></td><td>tests that the object's Count property is equal to the value given</td></tr> +</table> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li id="current"><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/quickStart.html b/tools/NUnit/doc/quickStart.html new file mode 100644 index 0000000..ab3953d --- /dev/null +++ b/tools/NUnit/doc/quickStart.html @@ -0,0 +1,314 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - QuickStart</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<style><!-- + div.code { width: 34em } +--></style> + +<h2>NUnit Quick Start</h2> + +<p><b>Note:</b> This page is based on the original QuickStart.doc, found in +earlier releases of NUnit. It has been pointed out that it isn't a good +example of Test-Driven Development. However, we're keeping it in the docs +because it does illustrate the basics of using NUnit. We'll revise or replace +it in a future release.</p> + +<p>Let’s start with a simple example. Suppose we are writing a bank application and we have a basic domain class – Account. Account supports operations to deposit, withdraw, and transfer funds. The Account class may look like this:</p> + +<div class="code"> +<pre>namespace bank +{ + public class Account + { + private float balance; + public void Deposit(float amount) + { + balance+=amount; + } + + public void Withdraw(float amount) + { + balance-=amount; + } + + public void TransferFunds(Account destination, float amount) + { + } + + public float Balance + { + get{ return balance;} + } + } +}</pre> +</div> + +<p>Now let’s write a test for this class – AccountTest. The first method we will test is TransferFunds.</p> + +<div class="code"> +<pre>namespace bank +{ + using NUnit.Framework; + + [TestFixture] + public class AccountTest + { + [Test] + public void TransferFunds() + { + Account source = new Account(); + source.Deposit(200.00F); + Account destination = new Account(); + destination.Deposit(150.00F); + + source.TransferFunds(destination, 100.00F); + Assert.AreEqual(250.00F, destination.Balance); + Assert.AreEqual(100.00F, source.Balance); + + } + } +}</pre> +</div> + +<p>The first thing to notice about this class is that it has a [TestFixture] attribute associated with it – this is the way to indicate that the class contains test code (this attribute can be inherited). The class has to be public and there are no restrictions on its superclass. The class also has to have a default constructor.</p> + +<p>The only method in the class – TransferFunds, has a [Test] attribute associated with it – this is an indication that it is a test method. Test methods have to return void and take no parameters. In our test method we do the usual initialization of the required test objects, execute the tested business method and check the state of the business objects. The Assert class defines a collection of methods used to check the post-conditions and in our example we use the AreEqual method to make sure that after the transfer both accounts have the correct balances (there are several overloadings of this method, the version that was used in this example has the following parameters : the first parameter is an expected value and the second parameter is the actual value).</p> + +<p>Compile and run this example. Assume that you have compiled your test code into a bank.dll. Start the NUnit Gui (the installer will have created a shortcut on your desktop and in the “Program Files” folder), after the GUI starts, select the File->Open menu item, navigate to the location of your bank.dll and select it in the “Open” dialog box. When the bank.dll is loaded you will see a test tree structure in the left panel and a collection of status panels on the right. Click the Run button, the status bar and the TransferFunds node in the test tree turn red – our test has failed. The “Errors and Failures” panel displayed the following message: + +<pre> TransferFunds : expected <250> but was <150></pre> + +and the stack trace panel right below it reported where in the test code the failure has occurred – + +<pre> at bank.AccountTest.TransferFunds() in C:\nunit\BankSampleTests\AccountTest.cs:line 17</pre></p> + +<p>That is expected behavior; the test has failed because we have not implemented the TransferFunds method yet. Now let’s get it to work. Don’t close the GUI and go back to your IDE and fix the code, make your TransferFunds method look like this:</p> + +<div class="code"> +<pre>public void TransferFunds(Account destination, float amount) +{ + destination.Deposit(amount); + Withdraw(amount); +}</pre> +</div> + + +<p>Now recompile your code and click the run button in GUI again – the status bar and the test tree turn green. (Note how the GUI has reloaded the assembly automatically for you; we will keep the GUI open all the time and continue working with our code in IDE and write more tests).</p> + +<p>Let’s add some error checking to our Account code. We are adding the minimum balance requirement for the account to make sure that banks continue to make their money by charging your minimal overdraft protection fee. Let’s add the minimum balance property to our Account class:</p> + +<div class="code"> +<pre>private float minimumBalance = 10.00F; +public float MinimumBalance +{ + get{ return minimumBalance;} +}</pre> +</div> + +<p>We will use an exception to indicate an overdraft:</p> + +<div class="code"> +<pre>namespace bank +{ + using System; + public class InsufficientFundsException : ApplicationException + { + } +}</pre> +</div> + +<p>Add a new test method to our AccountTest class:</p> + +<div class="code"> +<pre>[Test] +[ExpectedException(typeof(InsufficientFundsException))] +public void TransferWithInsufficientFunds() +{ + Account source = new Account(); + source.Deposit(200.00F); + Account destination = new Account(); + destination.Deposit(150.00F); + source.TransferFunds(destination, 300.00F); +}</pre> +</div> + +<p>This test method in addition to [Test] attribute has an [ExpectedException] attribute associated with it – this is the way to indicate that the test code is expecting an exception of a certain type; if such an exception is not thrown during the execution – the test will fail. Compile your code and go back to the GUI. As you compiled your test code, the GUI has grayed out and collapsed the test tree as if the tests were not run yet (GUI watches for the changes made to the test assemblies and updates itself when the structure of the test tree has changed – e.g. new test is added). Click the “Run” button – we have a red status bar again. We got the following Failure : + +<pre> TransferWithInsufficentFunds : InsufficientFundsException was expected</pre> + +Let’s fix our Account code again, modify the TransferFunds method this way:</p> + +<div class="code"> +<pre>public void TransferFunds(Account destination, float amount) +{ + destination.Deposit(amount); + if(balance-amount<minimumBalance) + throw new InsufficientFundsException(); + Withdraw(amount); +}</pre> +</div> + +<p>Compile and run the tests – green bar. Success! But wait, looking at the code we’ve just written we can see that the bank may be loosing money on every unsuccessful funds Transfer operation. Let’s write a test to confirm our suspicions. Add this test method:</p> + +<div class="code"> +<pre>[Test] +public void TransferWithInsufficientFundsAtomicity() +{ + Account source = new Account(); + source.Deposit(200.00F); + Account destination = new Account(); + destination.Deposit(150.00F); + try + { + source.TransferFunds(destination, 300.00F); + } + catch(InsufficientFundsException expected) + { + } + + Assert.AreEqual(200.00F,source.Balance); + Assert.AreEqual(150.00F,destination.Balance); +}</pre> +</div> + +<p>We are testing the transactional property of our business method – all operations are successful or none. Compile and run – red bar. OK, we’ve made $300.00 out of a thin air (1999.com déjà vu?) – the source account has the correct balance of 200.00 but the destination account shows : $450.00. How do we fix this? Can we just move the minimum balance check call in front of the updates:</p> + +<div class="code"> +<pre>public void TransferFunds(Account destination, float amount) +{ + if(balance-amount<minimumBalance) + throw new InsufficientFundsException(); + destination.Deposit(amount); + Withdraw(amount); +}</pre> +</div> + +<p>What if the Withdraw() method throws another exception? Should we execute a compensating transaction in the catch block or rely on our transaction manager to restore the state of the objects? We need to answer those questions at some point, but not now; but what do we do with the failing test in the meantime – remove it? A better way is to temporarily ignore it, add the following attribute to your test method</p> + +<div class="code"> +<pre>[Test] +[Ignore("Decide how to implement transaction management")] +public void TransferWithInsufficientFundsAtomicity() +{ + // code is the same +}</pre> +</div> + +<p>Compile and run – yellow bar. Click on “Tests Not Run” tab and you will see bank.AccountTest.TransferWithInsufficientFundsAtomicity() in the list along with the Reason this test is ignored.</p> + +<p>Looking at our test code we can see that some refactoring is in order. All test methods share a common set of test objects. Let’s extract this initialization code into a setup method and reuse it in all of our tests. The refactored version of our test class looks like this:</p> + +<div class="code"> +<pre>namespace bank +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class AccountTest + { + Account source; + Account destination; + + [SetUp] + public void Init() + { + source = new Account(); + source.Deposit(200.00F); + destination = new Account(); + destination.Deposit(150.00F); + } + + [Test] + public void TransferFunds() + { + source.TransferFunds(destination, 100.00f); + Assert.AreEqual(250.00F, destination.Balance); + Assert.AreEqual(100.00F, source.Balance); + } + + [Test] + [ExpectedException(typeof(InsufficientFundsException))] + public void TransferWithInsufficientFunds() + { + source.TransferFunds(destination, 300.00F); + } + + [Test] + [Ignore("Decide how to implement transaction management")] + public void TransferWithInsufficientFundsAtomicity() + { + try + { + source.TransferFunds(destination, 300.00F); + } + catch(InsufficientFundsException expected) + { + } + + Assert.AreEqual(200.00F,source.Balance); + Assert.AreEqual(150.00F,destination.Balance); + } + } +}</pre> +</div> + +<p>Note that Init method has the common initialization code, it has void return type, no parameters, and it is marked with [SetUp] attribute. Compile and run – same yellow bar!</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<ul> +<li id="current"><a href="quickStart.html">Quick Start</a></li> +<li><a href="installation.html">Installation</a></li> +</ul> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/random.html b/tools/NUnit/doc/random.html new file mode 100644 index 0000000..4950d2f --- /dev/null +++ b/tools/NUnit/doc/random.html @@ -0,0 +1,133 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Random</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RandomAttribute (NUnit 2.5)</h3> + +<p>The <b>RandomAttribute</b> is used to specify a set of random values to be provided + for an individual parameter of a parameterized test method. Since + NUnit combines the data provided for each parameter into a set of + test cases, data must be provided for all parameters if it is + provided for any of them. + +<p>By default, NUnit creates test cases from all possible combinations + of the datapoints provided on parameters - the combinatorial approach. + This default may be modified by use of specific attributes on the + test method itself. + +<p>RandomAttribute supports the following constructors: + +<div class="code"><pre> +public Random( int count ); +public Random( double min, double max, int count ); +public Random( int min, int max, int count ); +</pre></div> + +<h4>Example</h4> + +<p>The following test will be executed fifteen times, three times +for each value of x, each combined with 5 random doubles from -1.0 to +1.0. + +<div class="code"><pre> +[Test] +public void MyTest( + [Values(1,2,3)] int x, + [Random(-1.0, 1.0, 5)] double d) +{ + ... +} +</pre></div> + +<h4>See also...</h4> +<ul> +<li><a href="values.html">ValuesAttribute</a><li><a href="range.html">RangeAttribute</a><li><a href="sequential.html">SequentialAttribute</a><li><a href="combinatorial.html">CombinatorialAttribute</a><li><a href="pairwise.html">PairwiseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li id="current"><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/range.html b/tools/NUnit/doc/range.html new file mode 100644 index 0000000..077c996 --- /dev/null +++ b/tools/NUnit/doc/range.html @@ -0,0 +1,144 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Range</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RangeAttribute (NUnit 2.5)</h3> + +<p>The <b>RangeAttribute</b> is used to specify a range of values to be provided + for an individual parameter of a parameterized test method. Since + NUnit combines the data provided for each parameter into a set of + test cases, data must be provided for all parameters if it is + provided for any of them. + +<p>By default, NUnit creates test cases from all possible combinations + of the datapoints provided on parameters - the combinatorial approach. + This default may be modified by use of specific attributes on the + test method itself. + +<p>RangeAttribute supports the following constructors: + +<div class="code"><pre> +public RangeAttribute( int from, int to ); +public RangeAttribute( int from, int to, int step ); +public RangeAttribute( long from, long to, long step ); +public RangeAttribute( float from, float to, float step ); +public RangeAttribute( double from, double to, double step ); +</pre></div> + +<h4>Example</h4> + +<p>The following test will be executed nine times, as follows: +<pre> + MyTest(1, 0.2) + MyTest(1, 0.4) + MyTest(1, 0.6) + MyTest(2, 0.2) + MyTest(2, 0.4) + MyTest(2, 0.6) + MyTest(3, 0.2) + MyTest(3, 0.4) + MyTest(3, 0.6) +</pre> +<div class="code"><pre> +[Test] +public void MyTest( + [Values(1,2,3) int x, + [Range(0.2,0.6,0.2] double d) +{ + ... +} +</pre></div> + +<h4>See also...</h4> +<ul> +<li><a href="values.html">ValuesAttribute</a><li><a href="random.html">RandomAttribute</a><li><a href="sequential.html">SequentialAttribute</a><li><a href="combinatorial.html">CombinatorialAttribute</a><li><a href="pairwise.html">PairwiseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li id="current"><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/releaseDetail.html b/tools/NUnit/doc/releaseDetail.html new file mode 100644 index 0000000..b698ce6 --- /dev/null +++ b/tools/NUnit/doc/releaseDetail.html @@ -0,0 +1,861 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ReleaseDetail</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5 Final Release - Version 2.5.0.9122 - May 2, 2009</h3> + +<div style="max-width:660px;text-align:right"> +<a href="releaseNotes.html">View Combined 2.5 Changes</a> +</div> + +<h4>Framework</h4> + +<ul> +<li>A new syntax element, <b>Matches(Constraint)</b>, allows use of +custom constraints, predicates or lambda expressions in constraint expressions. + +<li>The <b>MessageMatch</b> enum used with <b>ExpectedExceptionAttribute</b> +has been extended with a new value <b>StartsWith</b>, indicating that the +exception message must start with the string provided. + +<li><b>TestCaseAttribute</b> now supports a <b>MessageMatch</b> +property. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The File menu now allows selecting an alternate runtime, +such as Mono, on a machine with multiple CLR implementations +installed. This feature is still considered experimental and +may change in the future. + +<li>The combo box in the Project Editor allowing selection of +a particular runtime type such as Mono for loading the test +has been re-enabled. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Provided a workaround to a Mono 2.4 bug in handling remote +references to an interface, where the provider is running under +MS .NET and the implementation is explicit. + +<li>Fixed a problem with the display of line numbers from a German +language stack trace, with lines terminating in a period. + +<li> The Console Runner display now shows the settings for ProcessModel, +DomainUsage and RuntimeFramework actually provided, before resolution +of any defaults. + +<li> Removed references in the docs to pages that no longer exist. +</ul> + +<h3>NUnit 2.5 Release Candidate - Version 2.5.0.9117 - April 27, 2009</h3> + +<h4>General</h4> + +<ul> +<li>The installation now uses a 'lib' subdirectory to hold dlls. + +<li>The build script target names have been changed to make more sense. +In particular, 'package' now builds the default package and +targets not intended to be called directly are no longer listed +as 'Main Targets' by the -projecthelp option. +</ul> + +<h4>Framework</h4> + +<ul> +<li>The following Constraints now use the NUnit definition +of equality in comparing items, which may lead to changed behavior +of some tests. + <ul><b> + <li>UniqueItemsConstraint + <li>CollectionContainsConstraint + <li>CollectionEquivalentConstraint + <li>CollectionSubsetConstraint + </b></ul> +The constraints listed now accept the <b>IgnoreCase</b> and <b>Using</b> +modifiers, which work exactly as they do with <b>EqualConstraint</b> +</ul> + +<h4>Core</h4> + +<ul> +<li>Caching is now used to reduce the time required to load tests. +</ul> + +<h4>Gui</h4> + +<ul> +<li>A new submenu under <b>File</b> allows selecting a runtime version +under which to reload the tests. Reloading in this way does not affect +any runtime version setting in the project file. + +<li>The project editor now provides a combo box listing known versions +of the runtime. Other versions may still be entered in the edit box. +Cross-CLR execution (for example, running Mono from .NET) has +been disabled in the Gui, since it isn't yet implemented. + +<li>The new stack trace display now follows the NUnit Font settings. +The stack display uses the general gui font, while the source code +display uses the fixed font. + +<li>The separate settings for Recent Files under .NET 1.1 +and .NET 2.0 have been combined, since the Gui now runs exclusively +under .NET 2.0. + +<li>The time required to restore the visual state of the tree after +reloading has been substantially reduced, especially for large numbers +of tests. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Use of a long assembly name for the ApplicationName of the AppDomain +was causing excessively long paths in the shadow cache. + +<li>The <b>Using</b> modifier of <b>EqualConstraint</b> now works as +expected for string operands. + +<li><b>TestCaseAttribute.ExpectedExceptionMessage</b> is no longer ignored. + +<li>The max number of files setting was not being saved when modified +in the Gui Settings dialog. + +<li>As a temporary fix, the pnunit.tests.dll has been moved to the +same directory as pnunit-agent.exe and pnunit-launcher.exe, since +pnunit tests don't allow for setting an appbase separate from the +location of the test assembly. +</ul> + +<h3>NUnit 2.5 Beta 3 Release - Version 2.5.0.9096 - April 6, 2009</h3> + +<h4>General</h4> + +<ul> +<li>The Gui is now built against .NET 2.0 only. Tests may still +be run under .NET 1.x by running in a separate process. + +<li>The Visual Studio 2003 solution has been removed. Framework +and other components may still be built under .NET 1.x through +the NAnt script. + +<li>The nunit.framework.extensions assembly has been removed +from the build. +</ul> + +<h4>Framework</h4> + +<ul> +<li><b>EqualConstraint</b> has been enhanced with + several new modifiers, which may be used immediately after + the Within(...) modifier to indicate how a numeric tolerance value + should be interpreted. + <ul> + <li><b>Ulps</b> = as units in the last place (floating point only) + <li><b>Percent</b> = as a percentage of expected value + <li><b>Days</b> = as a TimeSpan in days + <li><b>Hours</b> = as a TimeSpan in hours + <li><b>Minutes</b> = as a TimeSpan in minutes + <li><b>Seconds</b> = as a TimeSpan in seconds + <li><b>Milliseconds</b> = as a TimeSpan in milliseconds + <li><b>Ticks</b> = as a TimeSpan in ticks + </ul> + +<li>The comparison constraints (<b>GreaterThan</b>, <b>LessThan</b>, etc.), + <b>RangeConstraint</b> and <b>CollectionOrderedConstraint</b> may now be used + with objects that implement <b>IComparable<T></b>. + +<li>The syntax used for specifying that a collection is ordered has changed. + <b>Is.Ordered</b> is now a property. The property name to use for ordering + is specified using <b>Is.Ordered.By(name)</b>. + +<li>The following constraints now accept a <b>Using</b> modifier to indicate + that a user-specified comparer should be used: + <ul><b> + <li>EqualConstraint + <li>GreaterThanConstraint + <li>GreaterThanOrEqualConstraint + <li>LessThanConstraint + <li>LessThanOrEqualConstraint + <li>RangeConstraint + <li>CollectionOrderedConstraint + </b></ul> + The provided comparer may be any of the following: + <ul><b> + <li>IComparer + <li>IComparer<T> + <li>Comparison<T> + </b></ul> + In addition, <b>EqualConstraint</b> may use: + <ul><b> + <li>IEqualityComparer + <li>IEqualityComparer<T> + </b></ul> +</ul> + +<h3>NUnit 2.5 Beta 2 Release - Version 2.5.0.9015 - January 15, 2009</h3> + +<h4>Framework</h4> + +<ul> +<li>NUnit now includes an implementation of <b>Theories</b>, similar to what + is found in JUnit. Support for Theories is provided by the + <b>Theory</b>, <b>Datapoint</b> and <b>Datapoints</b> attributes and by + the <b>Assume.That</b> method. For more information and further links, + see the <a href="theory.html">TheoryAttribute</a> + documentation page. +<li>AssertionHelper has been updated so that the Expect overloads now + include the signatures newly introduced for Assert.That. +<li>The code for Assert is now generated. This is in addition to the files + that were generated in beta-1. +<li><b>AfterConstraint</b> has been renamed to <b>DelayedConstraint</b>. +</ul> + +<h4>Console</h4> + +<ul> +<li>The console runner now supports a <b>/framework</b> option, which + allows running the tests under a different version of the CLR. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Gui is now able to display the source code for test or production + code from the stack trace, provided the assemblies contain source code + information and the source code is available. Contributed by Irénée Hottier. +<li>Reloading the tests after changing settings in a way that modifies + the shape of the tree is now handled correctly. +<li>The Settings Dialog now opens to the page that was last viewed. +</ul> + +<h3>NUnit 2.5 Beta 1 Release - Version 2.5.0.8332 - November 27, 2008</h3> + +<h4>General</h4> + +<ul> +<li>Most of the code for elements of the constraint + syntax is now generated. This allows us to more rapidly deploy new + constraints with their corresponding syntax. The file <b>SyntaxElements.txt</b> + contains the specifications used in generating the code. At this time, + we are including both this file and the generated files with the NUnit source, + so that those working in other areas of the code don't have to regenerate + them each time they make changes. +<li>The nunit.core.extensions assembly has been removed from the build. Features + that were previously in that assembly are now in the nunit.core assembly. +<li>All third-party addins have been removed from the build and must be + downloaded separately from their own sites. An index of such + addins is maintained on the NUnit site. +</ul> + +<h4>Framework</h4> +<ul> +<li>New attributes are provided to control use of threads by tests. All of + the following may be used on methods, classes or assemblies: + <ul> + <li><b>RequiresThreadAttribute</b> forces creation of a new thread and + may optionally indicate the desired ApartmentState for the thread. + <li><b>RequiresSTAAttribute</b> causes the test to run in the STA. A + new thread is created only if the parent is not in the STA. On + methods, the .NET-provided STAThreadAttribute may also be used. + <li><b>RequiresMTAAttribute</b> causes the test to run in the MTA. A + new thread is created only if the parent is not in the MTA. On + methods, the .NET-provided MTAThreadAttribute may also be used. + <li><b>TimeoutAttribute</b> is used to set the timeout for tests. When + used on classes or assemblies, the timeout value is used as the + default timeout for all subordinate test cases. Test cases with + a timeout value run on a separate thread and return a failure + message if the timeout is exceeded. + </ul> +<li>The <b>MaxTimeAttribute</b> specifies a miximum elapsed time for a + test case. If the test takes longer, it is reported as a failure. + This attribute was previously available as an extension. + <br><br> + <b>Note:</b> Unlike <b>TimeoutAttribute</b>, <b>MaxTimeAttribute</b> + does not cause the test to be cancelled, but merely times it. +<li><b>RepeatAttribute</b> causes a test case to be executed multiple + times. This attribute was previously available as an extension. +<li><b>PairwiseAttribute</b> now works, generating all pairs of each + argument value. [In earlier betas, it was unimpemented and simply + generated all combinations.] +<li><b>PropertyAttribute</b> has been modified internally to use a dictionary + of name/value pairs rather than just a single name and value. This feature + is not exposed for direct use, but may be accessed by derived attributes + that want to apply multiple named values to the test. For a simple + example of usage, see the code for <b>RequiredThreadAttribute</b>. +<li>The presence of <b>TestCaseSourceAttribute</b> on a method is now + sufficient to identify it as a test. As with <b>TestCaseAttribute</b>, + use of <b>TestAttribute</b> is optional. +<li><b>Assert.That</b> has been extended to allow a delegate or a reference + as the argument. By default, these are evaluated before being used by + the constraint supplied but some constraints may delay evaluation. The + new <b>AfterConstraint</b> is an example. +<li>An additional overload of <b>Assert.Throws</b> allows passing a + constraint or constraint expression as the first argument. +<li>The syntax for AttributeConstraints has been enhanced so that further + tests may be applied to properties of the attribute rather than just + checking for its existence. +<li><b>AfterConstraint</b> allows delaying the application of a constraint + until a certain time has passed. In it's simplest form, it replaces + use of a Sleep in the code but it also supports polling, which may + allow use of a longer maximum time while still keeping the tests as + fast as possible. The <b>After</b> modifier is permitted on any + constraint, but the delay applies to the entire expression up to the + point where <b>After</b> appears. + <br><br> + <b>Note:</b> Use of After with a simple value makes no sense, since + the value will be extracted at the point of call. It's intended use + is with delegates and references. If a delegate is used with polling, + it may be called multiple times so only methods without side effects + should be used in this way. +</ul> + +<h4>Core</h4> + +<ul> +<li>NUnit now supports running tests in a separate process or in + multiple processes per assembly. In addition, tests run in + a separate process may use a different runtime version + from that under which NUnit is running. + <br><br> + <b>Note:</b> In the Beta release, execution of tests under Mono + from a copy of NUnit that is running under .NET is not yet supported. +</ul> + +<h4>Console</h4> + +<ul> +<li>The new <b>/process:xxxxx</b> command line option is used to run + tests in a separate process or in multiple processes per assembly. +<li>A new commandline option, <b>/timeout:nnnn</b> allows you to specify a + default timeout value, which is applied to each test case in the run without + a Timeout specified. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Assembly Info display now uses a scrolling text box and has + been enhanced to show information about the Process and AppDomain + in which the test is running and the runtime version under that + is being used. +<li>The Project Editor now allows setting the ProcessModel and + DomainUsage for a project to control how that project is + loaded and run. It also supports setting a target runtime + framework for each configuration. If the target runtime is + different from the runtime under which NUnit is running, the + tests will be run automatically in a separate process under + the target runtime. +<li>The Project Editor no longer reloads the tests as each + individual change is made. Tests are reloaded after the + editor is closed and only if changes have been made to + the overall project configuration or to the active + configuration. +<li>The "Options" dialog is now called "Settings." +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The implementation of constraints has been changed so that it is no + longer necessary to create an additional "Modifier" class when a + custom constraint takes modifiers. If you simply implement each modifier + as a property or method returning the object itself, it will be + usable in the full range of constraint expressions. + <br><br> + <b>Note:</b> Although you can readily create custom constraints, + this release of NUnit still lacks the ability to create new syntactic + elements without rebuilding the framework. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Loading a single assembly and then adding another assembly using + the Add Assembly menu item was not working correctly. +<li>Reloading tests after settings changes was failing when the + new settings changed the shape of the tree in such a way + that the new tests didn't match the old ones correctly. +<li>The Reload Project menu item was followed by a prompt asking + if the current project state should be saved first and making + the reload work in an unexpected way if you answered yes. +<li>A class without a TestFixture attribute, containing only + TestCase methods, without any Tests, was not recognized as + a test fixture. +<li>Assert.DoesNotThrow was failing to display a user message. +<li>Xml documentation for Assert.IsNotEmpty and Assert.AreEqual + was incorrect. +<li>CollectionAssert.AreEqual and EqualConstraint were not + working with IEnumerables that were not also Collections. +<li>PlatformAttribute now distinguishes correctly between + Vista and Windows 2008 Server. +</ul> + +<h3>NUnit 2.5 Alpha 4 Release - Version 2.5.0.8528 - September 14, 2008</h3> + +<h4>Framework</h4> +<ul> +<li>Use of the TestFixtureAttribute is now optional in designating + classes that contain tests. +<li>More than one method may now be marked with the <b>SetUp</b>, <b>TearDown</b>, + <b>TestFixtureSetUp</b> and <b>TestFixtureTearDown</b> attributes. Setups + in a base class are executed before those in a derived class and teardowns + are executed in the reverse order. If there are multiple setups or teardowns + defined at the same level, the order is unspecified so this practice is + not generally recommended. +<li>The <b>FactoryAttribute</b> and <b>TestCaseFactoryAttribute</b> introduced + in alhpa-3 have been removed. The new <b>TestCaseSourceAttribute</b> allows + specification of the name of the source of test cases and - optionally - the + type providing the source if it is not the same as the type that contains the + test. Only one source may be specified per attribute but the attribute may be + applied more than once to indicate multiple sources. +<li>It is now possibe to specify Categories and Properties on test cases + defined using the TestCaseData class. +<li>Named fields, properties or methods may be used to provide values for + individual method parameters using the new <b>ValueSourceAttribute</b>. +<li>New constraints and corresponding syntactic constructs are provided: + <ul> + <li><b>Is.InRange</b> tests that a value lies within a specified range. + <li><b>Has.Attribute()</b> tests for the presence of a specified attribute + on a type. + <li><b>Is.AssignableTo</b> allows reversing the operands of AssignableFrom + for increased clarity in the code and in any error messages when the + actual value is of the derived type. + <li><b>Throws.Exception</b> allows testing the exception thrown by a + delegate in place and provides the ability to make arbitrary tests + on the caught exception. <b>Throws.TypeOf()</b> and <b>Throws.InstanceOf()</b> + are provided as shorthand for the commonly used <b>Throws.Exception.TypeOf()</b> + and <b>Throws.Exception.InstanceOf</b>. + <li><b>Throws.Nothing</b> provides for testing that a delegate does + not throw. While it doesn't do much, it serves the purpose of + converting an unexpected error into a test failure. + </ul> +<li>The parsing of constraint expressions written using the fluent interface + has been reorganized internally, with the following benefits: + <ul> + <li>Meaningless sequences like "...Null.Null..." or "...And.Or..." + will no longer compile - the NUnit tests actually verify this + by attempting to compile them. + <li>Syntax modifiers like <b>Within</b> and <b>IgnoreCase</b> are + now only accepted - and shown by intellisense - on constraints that + actually make use of them. + <li>New <b>And</b> and <b>Or</b> infix operators are provided. + <li>The <b>With</b> provides some ability to group constraints. + </ul> + + <p><p><b>Note:</b> Operators are evaluated in the following order: + <ol> + <li>Postfix modifiers (highest) + <li>Not Operator + <li>And operator (see below) + <li>Or operator (see below) + <li>With operator + <li>Some, None and All operators + <li>And operator when followed directly by Some, None or All + <li>Or operator when followed directly by Some, None or All + <li>Overloaded operator & + <li>Overloaded operator | (lowest) + </ol> + Operators of equal precedence associate left to right. + +<li>The "syntax helper" classes, <b>Is</b>, <b>Has</b>, <b>Text</b> and + <b>List</b> have been moved to the NUnit.Framework namespace, since they + seem to have entered the mainstream. +<li>NUnit 2.5 is able to recognize, load and run NUnitLite tests. +<li>PropertyConstraint now works with Types when testing for the + existence of a named property. +</ul> + +<h4>Core</h4> +<ul> +<li>Experimental support is provided for running tests in a separate process. + Currently, this is only exposed in the Gui runner. +<li>NUnit recognizes a special attribute on + the config element of the nunit project file, <b>runtimeFramework</b>, + which may be set to "net-1.1" or "net-2.0." This causes use of the + appropriate runner if tests are run in a separate process. + <p><p> + <b>Note:</b> Both of the above features are experimental and + somewhat fragile. Results are expected to vary for different + installations and we ask that problems be reported. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Addin Dialog now shows an error message for any addin that + fails to load. (from 2.4.8) +<li>The TestLoader settings dialog provides an option for running tests + in a separate process. +<li>The Assembly Info display now shows two runtime versions for each + test assembly: the one for which it was built and the one under + which it is currently loaded. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The <b>RequiredAddinAttribute</b> is now only permitted at the assembly level. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>The Gui output panes were failing to use a fixed font. (from 2.4.8) +</ul> + +<h3>NUnit 2.5 Alpha 3 Release - Version 2.5.0.8189 - July 7, 2008</h3> + +<h4>General</h4> + +<ul> +<li>NUnit now uses a new version numbering scheme. The first three + dot-separated values represent the release level, as before, while + the fourth is a build number tied to the date of the release. This + alpha release, for example, is numbered 2.5.0.8189. +<li>The NUnit source now includes a VS2008 project, in addition to + the existing VS2005 and VS2003 projects +</ul> + +<h4>Framework</h4> + +<ul> +<li><b>DataSourceAttribute</b> has been replaced with <b>FactoryAttribute</b>. + The new attribute may refer to any field, method or property that + provides test cases consistent with the signature of the method on which + it appears. The naming of this attribute is still a bit unsatisfactory + and it may change in the final release. +<li>The new <b>TestCaseFactoryAttribute</b> class may be used to mark a + field, method or property that provides test cases. It specifies the + argument types of the test cases that will be provided and is used + to identify the cases to be used when the name of a factory is not + specified. +<li>Data may be specified for individual arguments of a parameterized test + using the new attributes: <b>ValuesAttribute</b>, <b>RangeAttribute</b> + and <b>RandomAttribute</b>. By default, test cases are created using + every possible combination of the items provided. Attributes on the + test method may specify how data is combined. This release includes + <b>SequentialAttribute</b>, <b>CombinatorialAttribute</b> (the default) and + <b>PairwiseAttribute</b>. However, Pairwise combination is not yet + implemented, so that attribute is currently ignored. +<li><b>TestFixture</b> classes may now be generic. They must be marked with + or or more instances of <b>TextFixtureAttribute</b> using the new + constructor that takes an array of Types. NUnit will instantiate + the fixture multiple times, using the type arguments provided. +<li>Parameterized test methods may now be generic. NUnit will deduce + the correct implementation to use based on the types of the + parameters provided. +<li>The new <b>RequiredAddinAttribute</b> may be used to mark tests, + fixtures or assemblies, indicating the name of any addin that is + required to run the tests. If the addin is not present, the test, + fixture or assembly is marked NotRunnable. +<li>A new assertion and corresponding constraint <b>IsOrdered</b> + has been added. (contributed by Simone Busoli) +<li><b>PlatformAttribute</b> has been extended to accept the new keywords + <b>NT6</b>, <b>Vista</b> and <b>Win2008Server</b>. + <br><br> + <b>Note:</b> In the current alpha release, NUnit is unable to + distintuish between Vista and Windows 2008 Server. Either + of them will match all the above values. +</ul> + +<h4>Gui</h4> + +<ul> +<li>Properties with a collection for a value are now displayed +displayed as a comma-separated list in the properties window. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The <b>IParameterProvider</b> interface has been replaced with + <b>ITestCaseProvider</b>. The ParameterProviders extension point + has been renamed to TestCaseProviders. +<li>A new extension point, <b>DataPointProviders</b>, has been + added to support extensions that provide data for individual + test parameters. Extensions must implement the <b>IDataPointProvider</b> + interface. +<li>A simpler method of providing new data point extensions based + on attributes applied to the parameter itself is also available. + Such attributes may be derived from <b>ValuesAttribute</b> and + do not require any special addin in order to work. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>NUnit tests of AssertThrows were not working on systems using + non-English cultures. +<li>Domains were not unloading correctly in some circumstances. Unloading + is now done on a separate thread. +<li>An NUnitSettings.xml file of zero length was causing a crash. (from 2.4.8) +<li>Invoking the gui with /exclude:XXX, where XXX is a non-existent + category, was causing all tests to be excluded. (from 2.4.8) +<li>Categories were not working properly on repeated tests. (from 2.4.8) +<li>A serious memory leak was fixed in the NUnit test runners. (from 2.4.8) +<li>Static SetUp and TearDown methods were not being called in a SetUpFixture. +<li>The current directory used when executing addins that load tests was + not correctly set. +</ul> + +<h3>NUnit 2.5 Alpha 2 Release - May 7, 2008</h3> + +<p><b>Note:</b> Since this is an alpha level release, the +features are not complete and some features present in +this release may be removed or changed in future releases. + +<h4>General</h4> + +<ul> +<li>This release includes pNUnit, an extended NUnit runner for distributed + parallel tests. The pNUnit program was developed at Codice Software + for use in testing the Plastic SCM and has been contributed to NUnit. + For more info about using pNUnit see the + <a href="http://www.codicesoftware.com/opdownloads2/oppnunit.aspx">pNUnit site</a>. +<li>The install now offers Typical, Complete and Custom options. Selecting + Typical gets you the NUnit framework, core, console runner and Gui. + To install pNUnit, any of the bundled addins or the NUnit tests, + select Complete or Custom. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The RowTestExtension, which was merged into the nunit extension dlls + in Alpha-1, is now provided as a separate addin. This is the general + approach we plan to take with regard to any bundled addins, since it + permits the creator of an addin to provide updates separately from + the NUnit release. +<li>This release includes the CSUnitAddin extension, which allows the running of + CSUnit tests under NUnit. The csunit.dll must be available in order to + run the tests. +</ul> + +<h3>NUnit 2.5 Alpha 1 Release - April 18, 2008</h3> + +<h4>General</h4> + +<ul> +<li>There are no longer separate distributed packages for .NET 1.1 an 2.0. + Both the binary zip and msi packages contain subdirectories for .NET + 1.1 and 2.0. In the case of the msi, the user may elect to install either + or both of them. +<li>The Visual Studio solutions and projects are now in a directory tree that + is parallel to the source tree. This eliminates problems where the VS2003 + and VS2005 builds were interfering with one another and makes room for + adding VS2008. +<li>NUnit is now built using NAnt 0.86 beta 1 +<li>The windows installer is now created using WiX 2.0.5085 +</ul> + +<h4>Framework</h4> + +<ul> +<li>Two new attributes have been added to support passing arguments + to test methods: + <ul> + <li><b>TestCaseAttribute</b> allows the programmer to + specify the arguments and a number of optional parameters inline. + <li><b>DataSourceAttribute</b> identifies a static property that + will provide the arguments and other parameters. + </ul> + +<li>Two new constraints have been added to permit testing of + application-created paths, without requiring that they exist in + the file system. The following syntax is supported: + <ul> + <li><b>Is.SamePath(string)</b> + <li><b>Is.SamePathOrUnder(string)</b> + </ul> + +<li>The DirectoryAssert class has been added, providing the following Methods: + <ul> + <li><b>AreEqual(DirectoryInfo, DirectoryInfo)</b> + <li><b>AreEqual(string, string)</b> + <li><b>AreNotEqual(DirectoryInfo, DirectoryInfo)</b> + <li><b>AreNotEqual(string, string)</b> + <li><b>IsEmpty(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsEmpty(string, string)</b> + <li><b>IsNotEmpty(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsNotEmpty(string, string)</b> + <li><b>IsWithin(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsWithin(string, string)</b> + <li><b>IsNotWithin(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsNotWithin(string, string)</b> + </ul> + +<li>The method <b>Assert.Throws(Type expectedException, TestSnippet code)</b> + has been added to provide more control over tests of expected exceptions. + <b>TestSnippet</b> is a delegate, which may of course be supplied + anonymously under .NET 2.0. If the correct exception type is thrown, + the actual exception is returned from the method, allowing further + verification to be performed. + +<li>The <b>Assert.DoesNotThrow</b> method may be used to verify that a + delegate does not throw an exception. + +<li>The <b>Assert.Pass</b> method allows early termination of a test with a + successful result. + +<li>The <b>Assert.Inconclusive</b> method allows returning + the new Inconclusive result state. + +<li>NUnit now includes added funtionality in the .NET 2.0 build of + the framework. The following additional features are supported: + <ul> + <li>All Asserts and Constraints work with nullable types. + <li>Some Asserts allow an alternate generic syntax for convenience: + <ul> + <li><b>Assert.IsInstanceOf<T>(object actual);</b> + <li><b>Assert.IsNotInstanceOf<T>(object actual);</b> + <li><b>Assert.IsAssignableFrom<T>(object actual);</b> + <li><b>Assert.IsNotAssignableFrom<T>(object actual);</b> + <li><b>Assert.Throws<T>(TypeSnippet code);</b> + </ul> + </ul> + +<li>The following obsolete interfaces, classes and methods have been removed: +<ul> + <li>The <b>IAsserter</b> interface + <li>The <b>AbstractAsserter</b> class + <li>The <b>Assertion</b> class + <li>The <b>AssertionFailureMessage</b> class + <li>The old <b>NUnit.Framework.TestCase</b> class used for inheriting test classes + <li>The <b>Assert.DoAssert()</b> method + <li>Two <b>ExpectedExceptionAttribute(Type, string)</b> constructor + <li>Two <b>ExpectedExceptionAttribute(string, string)</b> constructor +</ul> + +<li>The syntactic constructs in the <b>SyntaxHelpers</b> namespace have been + moved to the <b>NUnit.Framework.Syntax.CSharp</b> namespace. The old + namespace may still be used for existing classes, but will not be + supported after the 2.5 release. + +</ul> + +<h4>Core</h4> + +<ul> +<li>NUnit now allows use of static methods as tests and for SetUp, TearDown, + TestFixtureSetUp and TestFixtureTearDown. +<li>Failures and Errors are now distinquished internally and in summary reports. + Methods that are not run because they are invalid are also reported separately. +</ul> + +<h4>Console</h4> + +<ul> +<li>The summary report now displays Errors, Failures, Inconclusive, Ignored and Skipped tests + separately. More detailed information on non-runnable tests and setup failures + is provided. +<li>The console summary report is no longer created using a stylesheet, which + renders the <b>/transform</b> option meaningless. The option has been removed. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The default gui display now uses a single tab for all text output. For + users upgrading from an earlier release, the current settings are + honored. If you wish to change to the new default, use the Restore Defaults + button on the Text Output settings dialog. + +<li>The final test run display shows a more detailed summary: passed tests, + errors, failures, inconclusive, non-runnable, skipped and ignored. + +<li>The status bar now displays errors and failures separately in. + +<li>The tree display shows non-runnable tests in red and inconclusive tests + in orange. Inconclusive tests are temporarily listed + on the Tests Not Run tab for this alpha release. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>A new extension point <b>ParameterProviders</b> allows addins to + provide data for parameterized tests. + +<li>The following extensions are included in the nunit.core.extensions + and nunit.framework.extensions assemblies: + <ul> + <li>The MaxTime extension, which was previously a sample. + <li>The RowTest extension, which remains an alternative to NUnit's + native TestCase syntax. + <li>The XmlConstraint extension, which allows comparing two xml files + </ul> +</ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="pnunit.html">PNUnit</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<ul> +<li id="current"><a href="releaseDetail.html">Pre-Release Details</a></li> +</ul> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/releaseNotes.html b/tools/NUnit/doc/releaseNotes.html new file mode 100644 index 0000000..e5ee928 --- /dev/null +++ b/tools/NUnit/doc/releaseNotes.html @@ -0,0 +1,1188 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ReleaseNotes</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h2>Release Notes</h2> + +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5.5 - Version 2.5.5.10112 - April 22, 2010</h3> + +<h4>Features</h4> + +<ul> +<li>The Runtime Version dropdown on the <b>Project Editor</b> dialog +now includes only major and minor version numbers like 2.0 or 4.0. +When loading the tests, these versions are resolved to the highest +version of the particular runtime available on your system. You may +still enter a complete version number in the text box if desired. +<li>The <b>DatapointsAttribute</b> may now be specified on properties +and methods as well as fields. For parameters of type T, the attribute +now supports members of Type <b>IEnumerable<T></b> in addition +to arrays of the parameter Type. +<li>Timeouts are now suppressed when running under a debugger. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>FileNotFoundException when test assembly is built for x64 platform. +<li>Config files not found with /domain:Multiple. +<li>SetCultureAttribute ignored on parameterized test methods. +<li>NUnit not recognizing .NET 4.0 RC or Final Release. +<li>TestFixtureTearDown in static class not executed +<li>Failing tests in sample files AssertSyntaxTests.cs and AssertSyntaxTests.vb. +<li>Invalid XML character in TestResult.xml when a test case string argument +uses certain control or unicode characters. +</ul> +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5.4 - Version 2.5.4.10098 - April 8, 2010</h3> + +<h4>Features</h4> + +<ul> +<li>NUnit now defaults to running an assembly under the runtime version for +which it was built. If that version is not available, a higher version may be +used. See the <a href="runtimeSelection.html">Runtime Selection</a> +page for details. +<li><b>ProjectEditor</b> now provides a 'Default' selection for the runtime +version to be used. +<li>The XML result file format has been enhanced to provide additional information +needed to identify and report on theories and also includes extended result states +such as Inconclusive, Invalid, Error and Cancelled. +<li>The <b>EmptyConstraint</b> (Is.Empty) may now be used with a <b>DirectoryInfo</b> +to test whether the directory is empty. +<li>Datapoints for <b>boolean</b> and <b>enum</b> arguments are now generated +automatically for theories. +<li>The cache path for shadow copying is now saved in the NUnit settings file +rather than in the config files. The settings dialog may be used to change it +if necessary. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>NUnit crashing when a message contains ']]>' +<li>Replace compile-time exclusion of code from Mono with run-time test +<li>Message associated with Assert.Inconclusive() not shown in XML +<li>Category on test case clashes with category on the test method +<li>Console crash when specifying /domain:Single with multiple assemblies +<li>Incorrect relative path causing problems in saving projects +<li>Message associated with Assert.Pass() not shown in XML +<li>Tests with ExpectedException compiled against NUnit 2.4 always pass under 2.5 +<li>Datapoints with a null value were not being passed correctly to theories +<li>Error in XML output with FSharp.Net +<li>Documentation refers to files missing from Windows install +<li>Parameterized test fixtures with null parameters not handled correctly +<li>Theories now work as designed, failing when no data satisfies the assumptions +<li>Target framework of net-3.5 was causing console to crash +<li>Mono stack traces are now parsed correctly in the Gui +<li>Test failures under .NET 1.1 +<li>Thread CurentPrincipal set in TestFixtureSetUp not maintained between tests +</ul> +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5.3 - Version 2.5.3.9345 - December 11, 2009</h3> + +<p><b>Note:</b> This is the first release of NUnit on Launchpad. + +<h4>Features</h4> + +<ul> +<li>Test execution under .NET 4.0 is now supported. It may be selected + in the Gui runner or using the console runner /framework option. + NUnit test projects may specify .NET 4.0 as the required framework + to be used for loading the the project. PlatformAttribute allows + testing for .NET 4.0. +<li>The distribution now includes nunit-agent-x86.exe, which is used + for running tests in a separate process under nunit-x86.exe + or nunit-console-x86.exe when the target framework is .NET 2.0 + or greater. +<li>Static methods Contains.Substring() and Contains.Item() have been + added to the NUnit syntax for compatibility with NUnitLite. +<li>Non-public test fixtures are now allowed in all cases, + whether the TestFixtureAttribute is present or not. +<li>Abstract classes may now be marked with TestFixtureAttribute + to indicate that derived classes are to be treated as + test fixtures. The abstract class is no longer marked as invalid. +<li>Fixtures without tests are no longer shown as non-runnable but + are simply executed. If the fixture setup or teardown does not cause + an error, they are reported as inconclusive. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Reloading tests in the Gui no longer uses the default runtime if + a different runtime was previously selected. +<li>Thread principal is now saved before each test and restored afterward + eliminating failures under .NET 4.0. +<li>Assume.That() overload with a message no longer results in test failure. +<li>An expected Result of null is now handled correctly on parameterized tests. +<li>Duplicate caching of metadata has been eliminated, resolving a + load performance problem when many methods are inherited from + a base class. +<li>The names of nested generic and non-generic classes are now displayed + correctly. +<li>Assert.Catch<T> now correctly returns exception type T rather than + System.Exception. +<li>ValueSourceAttribute now works correctly when used with an external type. +<li>The /domain=None option on nunit-console once again works correctly. +<li>Parameterized test fixture names are now displayed with the actual + arguments used so that failures may be associated with the correct + instantiation of the fixture. +<li>Test labels for generics are now displayed correctly by the console + runner and in the Gui text output tab. +<li>Generic fixtures without type attributes provided are now shown + as non-runnable rather than causing a runtime error. (1) +<li>Use of an unknown file type in the console command line no longer causes + an error. (2) +<li>A number of tests that ran incorrectly under Linux have been fixed. +<li>A number of tests failing under .NET 4.0 have been fixed. +</ul> + +<h4>Notes</h4> + +<ol> +<li>As a side effect of this fix, TestFixtureAttribute on a base class is + overridden by a TestFixtureAttribute on the derived class. +<li>This was originally reported as "crash when using /option in linux." +</ol> +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5.2 - Version 2.5.2.9222 - August 10, 2009</h3> + +<p><b>Note:</b> This is the last release of NUnit using source code + maintained on Sourceforge. The CVS repository there will be kept, + but no longer updated. After this release, the source is being + maintained on Launchpad at http://launchpad.net/nunit-2.5. + +<h4>Framework</h4> + +<ul> +<li>The new <b>SetUICultureAttribute</b> allows setting CurrentUICulture + for the duration of a test method, fixture or assembly. +<li>The <b>TestFixture</b>, <b>TestCase</b> and <b>TestCaseData</b> attributes + have been enhanced to allow ignoring an individual fixture instance or + test case. Two new named parameters are provided: + <ul> + <li><b>Ignore</b> may be set to true to ignore an item. + <li><b>IgnoreReason</b> may be set to specify the reason for ignoring + the item. If IgnoreReason is set to a non-empty string, then setting + Ignore is optional. + </ul> +<li><b>Assert.Catch</b> has been added with several overloads. It differs + from <b>Assert.Throws</b> in accepting exceptions derived from the one + that is specified. Like <b>Assert.Throws</b>, it returns the exception + thrown when it succeeds so that further tests can be made on it. +<li>The <b>Throws</b> syntax has a number of new additions: + <ul> + <li><b>ThrowsTargetInvocationException</b>, <b>ThrowsArgumentException</b> + and <b>Throws.InvalidOperationException</b> provide a shorter syntax + for testing for these common exception types. + <li><b>Throws.InnerException</b> applies any constraints to the InnerException + of the exception that was thrown rather than to the exception itself. + <li><b>InnerException</b> can also be used in constraint expressions - see + the documentation for an example. + </ul> +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Data from a TestCaseSource in a separate class from the tests + is now handled correctly. +<li>Arguments specified using TestCaseData are now used correctly. +<li>Comparing the a stream to itself no longer causes an error. +<li>TimeoutAttribute is now permitted on an assembly as documented. +<li>Clear All and Clear Failures buttons are now displayed correctly + depending on whether Checkboxes are displayed in the Gui. +<li>The console runner option descriptions have been revised to + more clearly indicate what each option does. +<li>Running special tests that do not use the nunit.framework assembly + no longer causes a null reference exception. +<li>Console Runner option descriptions have been edited for accuracy. +<li>Gui TreeView now updates correctly when the order of tests has changed. +<li>An exception in TearDown now displays the actual exception + at the top of the stack rather than a TargetInvocationException. +</ul> +<style><!-- +li { padding-bottom: .5em; } +ul ul li { padding-bottom: 0; } +dt { font-weight: bold } +--></style> + +<h3>NUnit 2.5.1 - Version 2.5.1.9189 - July 8, 2009</h3> + +<h4>Framework</h4> + +<ul> +<li>A new <b>TestResult</b> state has been defined for tests cancelled by the + user. Results with <b>ResultState.Cancelled</b> are reported as a type of + failure and no longer generate an ApplicationException. +<li>Parameterized test fixtures with <b>TestCaseSource</b> or <b>ValueSource</b> + data are now constructed using the appropriate parameterized constructor + when test cases are being created. This avoids the need for a default + constructor and permits use of member data initialized from + the fixture parameters in creating the test data. +<li>The <b>TestCaseData</b> class now supports use of a string or other + array type as the sole argument value, without the need to nest + that array in an object array. +<li>Abstract classes marked with <b>TestFixtureAttribute</b> are no longer + reported as ignored or non-runnable. + <br><br> + <b>Note:</b> This was changed in 2.5 but was omitted from the release notes. +<li>The methods in the <b>Text</b> class are now marked as obsolete. For string + constraints, use one of the following at the start of an expression: + <ul> + <li><b>Is.StringContaining</b> + <li><b>Is.StringStarting</b> + <li><b>Is.StringEnding</b> + <li><b>Is.StringMatching</b> + </ul> + Within an expression (afer Not, Some, All, And, Or, etc.) you may use + <ul> + <li><b>Contains</b> or <b>ContainsSubstring</b> + <li><b>StartsWith</b> + <li><b>EndsWith</b> + <li><b>Matches</b> + </ul> +<li><b>ThrowsConstraint</b> now has a constructor taking an <b>ActualValueDelegate</b> + in addition to the constructor that takes a <b>TestDelegate</b>. This allows + simpler use of Lambda expressions under C# 3.0, but requires users of pre-3.0 + compilers to disambiguate their delegates by use of an explicit return + expression. +</ul> + +<h4>Core</h4> + +<ul> +<li>Individual test cases under a parameterized test are + no longer sorted by name within the test group but are + run (and shown in the Gui) in the order in which the + data is retrieved. + <br><br> + <b>Note:</b> Since the order of retrieval of custom + attributes is not guaranteed by the CLR, the order + of test cases will not necessarily match the textual + ordering of attributes in the source code. The order + of tests will vary across different compilers and + CLR versions as well. +<li>The XML test result file now contains a count of + inconclusive results. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The default icons in the Gui tree have been updated. +<li>Alternative icons placed by the user in the directory containing + nunit.uikit.dll may now be in PNG format. Icons are now recognized + for Skipped and Inconclusive status in addition to Success, Failure + and Ignored. +<li>A new setting option allows the user to disable checking for the + existence of files in the Recent Files list before listing them. This + prevents NUnit from appearing to freeze when the file is on a network + path that is no longer connected. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The <b>ITestCaseProvider2</b> and <b>IDatapointProvider2</b> interfaces + extend <b>ITestCaseProvider</b> and <b>IDatapointProvider</b> + with methods that include the fixture for which the test case is being + built. Providers may implement either the old or the new interface, + but the new interface is required if the data source is contained in + the test fixture itself so that the fixture may be constructed with + the proper parameters in the case of a parameterized fixture. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Lambda in Throws constraint was not compiling correctly. +<li>Null reference exception is no longer thrown when adding an assembly to a + new project that has not yet been saved. +<li>Dispose is now called on disposable types created while loading test case + parameters. +<li>Installations that copy NUnit to a single folder (no lib or framework folders) + now work correctly. +<li>Test Assemblies menu item is no longer enabled when no test was loaded +<li>The Text Output tab of the Settings dialog no longer causes an exception + when invoked from the mini-gui. +<li>Errors in various copyright statements were fixed and the year updated to 2009. +<li>Control characters in test arguments are now escaped in the display. +<li>Additional control characters are now escaped in error messages. +<li>Miscellaneous typographic corrections were made to the documentation. +</ul> +<h3>NUnit 2.5 Final Release - Version 2.5.0.9122 - May 2, 2009</h3> + +<h4>Framework</h4> + +<ul> +<li>A new syntax element, <b>Matches(Constraint)</b>, allows use of +custom constraints, predicates or lambda expressions in constraint expressions. + +<li>The <b>MessageMatch</b> enum used with <b>ExpectedExceptionAttribute</b> +has been extended with a new value <b>StartsWith</b>, indicating that the +exception message must start with the string provided. + +<li><b>TestCaseAttribute</b> now supports a <b>MessageMatch</b> +property. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The File menu now allows selecting an alternate runtime, +such as Mono, on a machine with multiple CLR implementations +installed. This feature is still considered experimental and +may change in the future. + +<li>The combo box in the Project Editor allowing selection of +a particular runtime type such as Mono for loading the test +has been re-enabled. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Provided a workaround to a Mono 2.4 bug in handling remote +references to an interface, where the provider is running under +MS .NET and the implementation is explicit. + +<li>Fixed a problem with the display of line numbers from a German +language stack trace, with lines terminating in a period. + +<li> The Console Runner display now shows the settings for ProcessModel, +DomainUsage and RuntimeFramework actually provided, before resolution +of any defaults. + +<li> Removed references in the docs to pages that no longer exist. +</ul> + +<h3>NUnit 2.5 Release Candidate - Version 2.5.0.9117 - April 27, 2009</h3> + +<h4>General</h4> + +<ul> +<li>The installation now uses a 'lib' subdirectory to hold dlls. + +<li>The build script target names have been changed to make more sense. +In particular, 'package' now builds the default package and +targets not intended to be called directly are no longer listed +as 'Main Targets' by the -projecthelp option. +</ul> + +<h4>Framework</h4> + +<ul> +<li>The following Constraints now use the NUnit definition +of equality in comparing items, which may lead to changed behavior +of some tests. + <ul><b> + <li>UniqueItemsConstraint + <li>CollectionContainsConstraint + <li>CollectionEquivalentConstraint + <li>CollectionSubsetConstraint + </b></ul> +The constraints listed now accept the <b>IgnoreCase</b> and <b>Using</b> +modifiers, which work exactly as they do with <b>EqualConstraint</b> +</ul> + +<h4>Core</h4> + +<ul> +<li>Caching is now used to reduce the time required to load tests. +</ul> + +<h4>Gui</h4> + +<ul> +<li>A new submenu under <b>File</b> allows selecting a runtime version +under which to reload the tests. Reloading in this way does not affect +any runtime version setting in the project file. + +<li>The project editor now provides a combo box listing known versions +of the runtime. Other versions may still be entered in the edit box. +Cross-CLR execution (for example, running Mono from .NET) has +been disabled in the Gui, since it isn't yet implemented. + +<li>The new stack trace display now follows the NUnit Font settings. +The stack display uses the general gui font, while the source code +display uses the fixed font. + +<li>The separate settings for Recent Files under .NET 1.1 +and .NET 2.0 have been combined, since the Gui now runs exclusively +under .NET 2.0. + +<li>The time required to restore the visual state of the tree after +reloading has been substantially reduced, especially for large numbers +of tests. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Use of a long assembly name for the ApplicationName of the AppDomain +was causing excessively long paths in the shadow cache. + +<li>The <b>Using</b> modifier of <b>EqualConstraint</b> now works as +expected for string operands. + +<li><b>TestCaseAttribute.ExpectedExceptionMessage</b> is no longer ignored. + +<li>The max number of files setting was not being saved when modified +in the Gui Settings dialog. + +<li>As a temporary fix, the pnunit.tests.dll has been moved to the +same directory as pnunit-agent.exe and pnunit-launcher.exe, since +pnunit tests don't allow for setting an appbase separate from the +location of the test assembly. +</ul> + +<h3>NUnit 2.5 Beta 3 Release - Version 2.5.0.9096 - April 6, 2009</h3> + +<h4>General</h4> + +<ul> +<li>The Gui is now built against .NET 2.0 only. Tests may still +be run under .NET 1.x by running in a separate process. + +<li>The Visual Studio 2003 solution has been removed. Framework +and other components may still be built under .NET 1.x through +the NAnt script. + +<li>The nunit.framework.extensions assembly has been removed +from the build. +</ul> + +<h4>Framework</h4> + +<ul> +<li><b>EqualConstraint</b> has been enhanced with + several new modifiers, which may be used immediately after + the Within(...) modifier to indicate how a numeric tolerance value + should be interpreted. + <ul> + <li><b>Ulps</b> = as units in the last place (floating point only) + <li><b>Percent</b> = as a percentage of expected value + <li><b>Days</b> = as a TimeSpan in days + <li><b>Hours</b> = as a TimeSpan in hours + <li><b>Minutes</b> = as a TimeSpan in minutes + <li><b>Seconds</b> = as a TimeSpan in seconds + <li><b>Milliseconds</b> = as a TimeSpan in milliseconds + <li><b>Ticks</b> = as a TimeSpan in ticks + </ul> + +<li>The comparison constraints (<b>GreaterThan</b>, <b>LessThan</b>, etc.), + <b>RangeConstraint</b> and <b>CollectionOrderedConstraint</b> may now be used + with objects that implement <b>IComparable<T></b>. + +<li>The syntax used for specifying that a collection is ordered has changed. + <b>Is.Ordered</b> is now a property. The property name to use for ordering + is specified using <b>Is.Ordered.By(name)</b>. + +<li>The following constraints now accept a <b>Using</b> modifier to indicate + that a user-specified comparer should be used: + <ul><b> + <li>EqualConstraint + <li>GreaterThanConstraint + <li>GreaterThanOrEqualConstraint + <li>LessThanConstraint + <li>LessThanOrEqualConstraint + <li>RangeConstraint + <li>CollectionOrderedConstraint + </b></ul> + The provided comparer may be any of the following: + <ul><b> + <li>IComparer + <li>IComparer<T> + <li>Comparison<T> + </b></ul> + In addition, <b>EqualConstraint</b> may use: + <ul><b> + <li>IEqualityComparer + <li>IEqualityComparer<T> + </b></ul> +</ul> + +<h3>NUnit 2.5 Beta 2 Release - Version 2.5.0.9015 - January 15, 2009</h3> + +<h4>Framework</h4> + +<ul> +<li>NUnit now includes an implementation of <b>Theories</b>, similar to what + is found in JUnit. Support for Theories is provided by the + <b>Theory</b>, <b>Datapoint</b> and <b>Datapoints</b> attributes and by + the <b>Assume.That</b> method. For more information and further links, + see the <a href="theory.html">TheoryAttribute</a> + documentation page. +<li>AssertionHelper has been updated so that the Expect overloads now + include the signatures newly introduced for Assert.That. +<li>The code for Assert is now generated. This is in addition to the files + that were generated in beta-1. +<li><b>AfterConstraint</b> has been renamed to <b>DelayedConstraint</b>. +</ul> + +<h4>Console</h4> + +<ul> +<li>The console runner now supports a <b>/framework</b> option, which + allows running the tests under a different version of the CLR. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Gui is now able to display the source code for test or production + code from the stack trace, provided the assemblies contain source code + information and the source code is available. Contributed by Irénée Hottier. +<li>Reloading the tests after changing settings in a way that modifies + the shape of the tree is now handled correctly. +<li>The Settings Dialog now opens to the page that was last viewed. +</ul> + +<h3>NUnit 2.5 Beta 1 Release - Version 2.5.0.8332 - November 27, 2008</h3> + +<h4>General</h4> + +<ul> +<li>Most of the code for elements of the constraint + syntax is now generated. This allows us to more rapidly deploy new + constraints with their corresponding syntax. The file <b>SyntaxElements.txt</b> + contains the specifications used in generating the code. At this time, + we are including both this file and the generated files with the NUnit source, + so that those working in other areas of the code don't have to regenerate + them each time they make changes. +<li>The nunit.core.extensions assembly has been removed from the build. Features + that were previously in that assembly are now in the nunit.core assembly. +<li>All third-party addins have been removed from the build and must be + downloaded separately from their own sites. An index of such + addins is maintained on the NUnit site. +</ul> + +<h4>Framework</h4> +<ul> +<li>New attributes are provided to control use of threads by tests. All of + the following may be used on methods, classes or assemblies: + <ul> + <li><b>RequiresThreadAttribute</b> forces creation of a new thread and + may optionally indicate the desired ApartmentState for the thread. + <li><b>RequiresSTAAttribute</b> causes the test to run in the STA. A + new thread is created only if the parent is not in the STA. On + methods, the .NET-provided STAThreadAttribute may also be used. + <li><b>RequiresMTAAttribute</b> causes the test to run in the MTA. A + new thread is created only if the parent is not in the MTA. On + methods, the .NET-provided MTAThreadAttribute may also be used. + <li><b>TimeoutAttribute</b> is used to set the timeout for tests. When + used on classes or assemblies, the timeout value is used as the + default timeout for all subordinate test cases. Test cases with + a timeout value run on a separate thread and return a failure + message if the timeout is exceeded. + </ul> +<li>The <b>MaxTimeAttribute</b> specifies a miximum elapsed time for a + test case. If the test takes longer, it is reported as a failure. + This attribute was previously available as an extension. + <br><br> + <b>Note:</b> Unlike <b>TimeoutAttribute</b>, <b>MaxTimeAttribute</b> + does not cause the test to be cancelled, but merely times it. +<li><b>RepeatAttribute</b> causes a test case to be executed multiple + times. This attribute was previously available as an extension. +<li><b>PairwiseAttribute</b> now works, generating all pairs of each + argument value. [In earlier betas, it was unimpemented and simply + generated all combinations.] +<li><b>PropertyAttribute</b> has been modified internally to use a dictionary + of name/value pairs rather than just a single name and value. This feature + is not exposed for direct use, but may be accessed by derived attributes + that want to apply multiple named values to the test. For a simple + example of usage, see the code for <b>RequiredThreadAttribute</b>. +<li>The presence of <b>TestCaseSourceAttribute</b> on a method is now + sufficient to identify it as a test. As with <b>TestCaseAttribute</b>, + use of <b>TestAttribute</b> is optional. +<li><b>Assert.That</b> has been extended to allow a delegate or a reference + as the argument. By default, these are evaluated before being used by + the constraint supplied but some constraints may delay evaluation. The + new <b>AfterConstraint</b> is an example. +<li>An additional overload of <b>Assert.Throws</b> allows passing a + constraint or constraint expression as the first argument. +<li>The syntax for AttributeConstraints has been enhanced so that further + tests may be applied to properties of the attribute rather than just + checking for its existence. +<li><b>AfterConstraint</b> allows delaying the application of a constraint + until a certain time has passed. In it's simplest form, it replaces + use of a Sleep in the code but it also supports polling, which may + allow use of a longer maximum time while still keeping the tests as + fast as possible. The <b>After</b> modifier is permitted on any + constraint, but the delay applies to the entire expression up to the + point where <b>After</b> appears. + <br><br> + <b>Note:</b> Use of After with a simple value makes no sense, since + the value will be extracted at the point of call. It's intended use + is with delegates and references. If a delegate is used with polling, + it may be called multiple times so only methods without side effects + should be used in this way. +</ul> + +<h4>Core</h4> + +<ul> +<li>NUnit now supports running tests in a separate process or in + multiple processes per assembly. In addition, tests run in + a separate process may use a different runtime version + from that under which NUnit is running. + <br><br> + <b>Note:</b> In the Beta release, execution of tests under Mono + from a copy of NUnit that is running under .NET is not yet supported. +</ul> + +<h4>Console</h4> + +<ul> +<li>The new <b>/process:xxxxx</b> command line option is used to run + tests in a separate process or in multiple processes per assembly. +<li>A new commandline option, <b>/timeout:nnnn</b> allows you to specify a + default timeout value, which is applied to each test case in the run without + a Timeout specified. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Assembly Info display now uses a scrolling text box and has + been enhanced to show information about the Process and AppDomain + in which the test is running and the runtime version under that + is being used. +<li>The Project Editor now allows setting the ProcessModel and + DomainUsage for a project to control how that project is + loaded and run. It also supports setting a target runtime + framework for each configuration. If the target runtime is + different from the runtime under which NUnit is running, the + tests will be run automatically in a separate process under + the target runtime. +<li>The Project Editor no longer reloads the tests as each + individual change is made. Tests are reloaded after the + editor is closed and only if changes have been made to + the overall project configuration or to the active + configuration. +<li>The "Options" dialog is now called "Settings." +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The implementation of constraints has been changed so that it is no + longer necessary to create an additional "Modifier" class when a + custom constraint takes modifiers. If you simply implement each modifier + as a property or method returning the object itself, it will be + usable in the full range of constraint expressions. + <br><br> + <b>Note:</b> Although you can readily create custom constraints, + this release of NUnit still lacks the ability to create new syntactic + elements without rebuilding the framework. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>Loading a single assembly and then adding another assembly using + the Add Assembly menu item was not working correctly. +<li>Reloading tests after settings changes was failing when the + new settings changed the shape of the tree in such a way + that the new tests didn't match the old ones correctly. +<li>The Reload Project menu item was followed by a prompt asking + if the current project state should be saved first and making + the reload work in an unexpected way if you answered yes. +<li>A class without a TestFixture attribute, containing only + TestCase methods, without any Tests, was not recognized as + a test fixture. +<li>Assert.DoesNotThrow was failing to display a user message. +<li>Xml documentation for Assert.IsNotEmpty and Assert.AreEqual + was incorrect. +<li>CollectionAssert.AreEqual and EqualConstraint were not + working with IEnumerables that were not also Collections. +<li>PlatformAttribute now distinguishes correctly between + Vista and Windows 2008 Server. +</ul> + +<h3>NUnit 2.5 Alpha 4 Release - Version 2.5.0.8528 - September 14, 2008</h3> + +<h4>Framework</h4> +<ul> +<li>Use of the TestFixtureAttribute is now optional in designating + classes that contain tests. +<li>More than one method may now be marked with the <b>SetUp</b>, <b>TearDown</b>, + <b>TestFixtureSetUp</b> and <b>TestFixtureTearDown</b> attributes. Setups + in a base class are executed before those in a derived class and teardowns + are executed in the reverse order. If there are multiple setups or teardowns + defined at the same level, the order is unspecified so this practice is + not generally recommended. +<li>The <b>FactoryAttribute</b> and <b>TestCaseFactoryAttribute</b> introduced + in alhpa-3 have been removed. The new <b>TestCaseSourceAttribute</b> allows + specification of the name of the source of test cases and - optionally - the + type providing the source if it is not the same as the type that contains the + test. Only one source may be specified per attribute but the attribute may be + applied more than once to indicate multiple sources. +<li>It is now possibe to specify Categories and Properties on test cases + defined using the TestCaseData class. +<li>Named fields, properties or methods may be used to provide values for + individual method parameters using the new <b>ValueSourceAttribute</b>. +<li>New constraints and corresponding syntactic constructs are provided: + <ul> + <li><b>Is.InRange</b> tests that a value lies within a specified range. + <li><b>Has.Attribute()</b> tests for the presence of a specified attribute + on a type. + <li><b>Is.AssignableTo</b> allows reversing the operands of AssignableFrom + for increased clarity in the code and in any error messages when the + actual value is of the derived type. + <li><b>Throws.Exception</b> allows testing the exception thrown by a + delegate in place and provides the ability to make arbitrary tests + on the caught exception. <b>Throws.TypeOf()</b> and <b>Throws.InstanceOf()</b> + are provided as shorthand for the commonly used <b>Throws.Exception.TypeOf()</b> + and <b>Throws.Exception.InstanceOf</b>. + <li><b>Throws.Nothing</b> provides for testing that a delegate does + not throw. While it doesn't do much, it serves the purpose of + converting an unexpected error into a test failure. + </ul> +<li>The parsing of constraint expressions written using the fluent interface + has been reorganized internally, with the following benefits: + <ul> + <li>Meaningless sequences like "...Null.Null..." or "...And.Or..." + will no longer compile - the NUnit tests actually verify this + by attempting to compile them. + <li>Syntax modifiers like <b>Within</b> and <b>IgnoreCase</b> are + now only accepted - and shown by intellisense - on constraints that + actually make use of them. + <li>New <b>And</b> and <b>Or</b> infix operators are provided. + <li>The <b>With</b> provides some ability to group constraints. + </ul> + + <p><p><b>Note:</b> Operators are evaluated in the following order: + <ol> + <li>Postfix modifiers (highest) + <li>Not Operator + <li>And operator (see below) + <li>Or operator (see below) + <li>With operator + <li>Some, None and All operators + <li>And operator when followed directly by Some, None or All + <li>Or operator when followed directly by Some, None or All + <li>Overloaded operator & + <li>Overloaded operator | (lowest) + </ol> + Operators of equal precedence associate left to right. + +<li>The "syntax helper" classes, <b>Is</b>, <b>Has</b>, <b>Text</b> and + <b>List</b> have been moved to the NUnit.Framework namespace, since they + seem to have entered the mainstream. +<li>NUnit 2.5 is able to recognize, load and run NUnitLite tests. +<li>PropertyConstraint now works with Types when testing for the + existence of a named property. +</ul> + +<h4>Core</h4> +<ul> +<li>Experimental support is provided for running tests in a separate process. + Currently, this is only exposed in the Gui runner. +<li>NUnit recognizes a special attribute on + the config element of the nunit project file, <b>runtimeFramework</b>, + which may be set to "net-1.1" or "net-2.0." This causes use of the + appropriate runner if tests are run in a separate process. + <p><p> + <b>Note:</b> Both of the above features are experimental and + somewhat fragile. Results are expected to vary for different + installations and we ask that problems be reported. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The Addin Dialog now shows an error message for any addin that + fails to load. (from 2.4.8) +<li>The TestLoader settings dialog provides an option for running tests + in a separate process. +<li>The Assembly Info display now shows two runtime versions for each + test assembly: the one for which it was built and the one under + which it is currently loaded. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The <b>RequiredAddinAttribute</b> is now only permitted at the assembly level. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>The Gui output panes were failing to use a fixed font. (from 2.4.8) +</ul> + +<h3>NUnit 2.5 Alpha 3 Release - Version 2.5.0.8189 - July 7, 2008</h3> + +<h4>General</h4> + +<ul> +<li>NUnit now uses a new version numbering scheme. The first three + dot-separated values represent the release level, as before, while + the fourth is a build number tied to the date of the release. This + alpha release, for example, is numbered 2.5.0.8189. +<li>The NUnit source now includes a VS2008 project, in addition to + the existing VS2005 and VS2003 projects +</ul> + +<h4>Framework</h4> + +<ul> +<li><b>DataSourceAttribute</b> has been replaced with <b>FactoryAttribute</b>. + The new attribute may refer to any field, method or property that + provides test cases consistent with the signature of the method on which + it appears. The naming of this attribute is still a bit unsatisfactory + and it may change in the final release. +<li>The new <b>TestCaseFactoryAttribute</b> class may be used to mark a + field, method or property that provides test cases. It specifies the + argument types of the test cases that will be provided and is used + to identify the cases to be used when the name of a factory is not + specified. +<li>Data may be specified for individual arguments of a parameterized test + using the new attributes: <b>ValuesAttribute</b>, <b>RangeAttribute</b> + and <b>RandomAttribute</b>. By default, test cases are created using + every possible combination of the items provided. Attributes on the + test method may specify how data is combined. This release includes + <b>SequentialAttribute</b>, <b>CombinatorialAttribute</b> (the default) and + <b>PairwiseAttribute</b>. However, Pairwise combination is not yet + implemented, so that attribute is currently ignored. +<li><b>TestFixture</b> classes may now be generic. They must be marked with + or or more instances of <b>TextFixtureAttribute</b> using the new + constructor that takes an array of Types. NUnit will instantiate + the fixture multiple times, using the type arguments provided. +<li>Parameterized test methods may now be generic. NUnit will deduce + the correct implementation to use based on the types of the + parameters provided. +<li>The new <b>RequiredAddinAttribute</b> may be used to mark tests, + fixtures or assemblies, indicating the name of any addin that is + required to run the tests. If the addin is not present, the test, + fixture or assembly is marked NotRunnable. +<li>A new assertion and corresponding constraint <b>IsOrdered</b> + has been added. (contributed by Simone Busoli) +<li><b>PlatformAttribute</b> has been extended to accept the new keywords + <b>NT6</b>, <b>Vista</b> and <b>Win2008Server</b>. + <br><br> + <b>Note:</b> In the current alpha release, NUnit is unable to + distintuish between Vista and Windows 2008 Server. Either + of them will match all the above values. +</ul> + +<h4>Gui</h4> + +<ul> +<li>Properties with a collection for a value are now displayed +displayed as a comma-separated list in the properties window. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The <b>IParameterProvider</b> interface has been replaced with + <b>ITestCaseProvider</b>. The ParameterProviders extension point + has been renamed to TestCaseProviders. +<li>A new extension point, <b>DataPointProviders</b>, has been + added to support extensions that provide data for individual + test parameters. Extensions must implement the <b>IDataPointProvider</b> + interface. +<li>A simpler method of providing new data point extensions based + on attributes applied to the parameter itself is also available. + Such attributes may be derived from <b>ValuesAttribute</b> and + do not require any special addin in order to work. +</ul> + +<h4>Bug Fixes</h4> + +<ul> +<li>NUnit tests of AssertThrows were not working on systems using + non-English cultures. +<li>Domains were not unloading correctly in some circumstances. Unloading + is now done on a separate thread. +<li>An NUnitSettings.xml file of zero length was causing a crash. (from 2.4.8) +<li>Invoking the gui with /exclude:XXX, where XXX is a non-existent + category, was causing all tests to be excluded. (from 2.4.8) +<li>Categories were not working properly on repeated tests. (from 2.4.8) +<li>A serious memory leak was fixed in the NUnit test runners. (from 2.4.8) +<li>Static SetUp and TearDown methods were not being called in a SetUpFixture. +<li>The current directory used when executing addins that load tests was + not correctly set. +</ul> + +<h3>NUnit 2.5 Alpha 2 Release - May 7, 2008</h3> + +<p><b>Note:</b> Since this is an alpha level release, the +features are not complete and some features present in +this release may be removed or changed in future releases. + +<h4>General</h4> + +<ul> +<li>This release includes pNUnit, an extended NUnit runner for distributed + parallel tests. The pNUnit program was developed at Codice Software + for use in testing the Plastic SCM and has been contributed to NUnit. + For more info about using pNUnit see the + <a href="http://www.codicesoftware.com/opdownloads2/oppnunit.aspx">pNUnit site</a>. +<li>The install now offers Typical, Complete and Custom options. Selecting + Typical gets you the NUnit framework, core, console runner and Gui. + To install pNUnit, any of the bundled addins or the NUnit tests, + select Complete or Custom. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>The RowTestExtension, which was merged into the nunit extension dlls + in Alpha-1, is now provided as a separate addin. This is the general + approach we plan to take with regard to any bundled addins, since it + permits the creator of an addin to provide updates separately from + the NUnit release. +<li>This release includes the CSUnitAddin extension, which allows the running of + CSUnit tests under NUnit. The csunit.dll must be available in order to + run the tests. +</ul> + +<h3>NUnit 2.5 Alpha 1 Release - April 18, 2008</h3> + +<h4>General</h4> + +<ul> +<li>There are no longer separate distributed packages for .NET 1.1 an 2.0. + Both the binary zip and msi packages contain subdirectories for .NET + 1.1 and 2.0. In the case of the msi, the user may elect to install either + or both of them. +<li>The Visual Studio solutions and projects are now in a directory tree that + is parallel to the source tree. This eliminates problems where the VS2003 + and VS2005 builds were interfering with one another and makes room for + adding VS2008. +<li>NUnit is now built using NAnt 0.86 beta 1 +<li>The windows installer is now created using WiX 2.0.5085 +</ul> + +<h4>Framework</h4> + +<ul> +<li>Two new attributes have been added to support passing arguments + to test methods: + <ul> + <li><b>TestCaseAttribute</b> allows the programmer to + specify the arguments and a number of optional parameters inline. + <li><b>DataSourceAttribute</b> identifies a static property that + will provide the arguments and other parameters. + </ul> + +<li>Two new constraints have been added to permit testing of + application-created paths, without requiring that they exist in + the file system. The following syntax is supported: + <ul> + <li><b>Is.SamePath(string)</b> + <li><b>Is.SamePathOrUnder(string)</b> + </ul> + +<li>The DirectoryAssert class has been added, providing the following Methods: + <ul> + <li><b>AreEqual(DirectoryInfo, DirectoryInfo)</b> + <li><b>AreEqual(string, string)</b> + <li><b>AreNotEqual(DirectoryInfo, DirectoryInfo)</b> + <li><b>AreNotEqual(string, string)</b> + <li><b>IsEmpty(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsEmpty(string, string)</b> + <li><b>IsNotEmpty(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsNotEmpty(string, string)</b> + <li><b>IsWithin(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsWithin(string, string)</b> + <li><b>IsNotWithin(DirectoryInfo, DirectoryInfo)</b> + <li><b>IsNotWithin(string, string)</b> + </ul> + +<li>The method <b>Assert.Throws(Type expectedException, TestSnippet code)</b> + has been added to provide more control over tests of expected exceptions. + <b>TestSnippet</b> is a delegate, which may of course be supplied + anonymously under .NET 2.0. If the correct exception type is thrown, + the actual exception is returned from the method, allowing further + verification to be performed. + +<li>The <b>Assert.DoesNotThrow</b> method may be used to verify that a + delegate does not throw an exception. + +<li>The <b>Assert.Pass</b> method allows early termination of a test with a + successful result. + +<li>The <b>Assert.Inconclusive</b> method allows returning + the new Inconclusive result state. + +<li>NUnit now includes added funtionality in the .NET 2.0 build of + the framework. The following additional features are supported: + <ul> + <li>All Asserts and Constraints work with nullable types. + <li>Some Asserts allow an alternate generic syntax for convenience: + <ul> + <li><b>Assert.IsInstanceOf<T>(object actual);</b> + <li><b>Assert.IsNotInstanceOf<T>(object actual);</b> + <li><b>Assert.IsAssignableFrom<T>(object actual);</b> + <li><b>Assert.IsNotAssignableFrom<T>(object actual);</b> + <li><b>Assert.Throws<T>(TypeSnippet code);</b> + </ul> + </ul> + +<li>The following obsolete interfaces, classes and methods have been removed: +<ul> + <li>The <b>IAsserter</b> interface + <li>The <b>AbstractAsserter</b> class + <li>The <b>Assertion</b> class + <li>The <b>AssertionFailureMessage</b> class + <li>The old <b>NUnit.Framework.TestCase</b> class used for inheriting test classes + <li>The <b>Assert.DoAssert()</b> method + <li>Two <b>ExpectedExceptionAttribute(Type, string)</b> constructor + <li>Two <b>ExpectedExceptionAttribute(string, string)</b> constructor +</ul> + +<li>The syntactic constructs in the <b>SyntaxHelpers</b> namespace have been + moved to the <b>NUnit.Framework.Syntax.CSharp</b> namespace. The old + namespace may still be used for existing classes, but will not be + supported after the 2.5 release. + +</ul> + +<h4>Core</h4> + +<ul> +<li>NUnit now allows use of static methods as tests and for SetUp, TearDown, + TestFixtureSetUp and TestFixtureTearDown. +<li>Failures and Errors are now distinquished internally and in summary reports. + Methods that are not run because they are invalid are also reported separately. +</ul> + +<h4>Console</h4> + +<ul> +<li>The summary report now displays Errors, Failures, Inconclusive, Ignored and Skipped tests + separately. More detailed information on non-runnable tests and setup failures + is provided. +<li>The console summary report is no longer created using a stylesheet, which + renders the <b>/transform</b> option meaningless. The option has been removed. +</ul> + +<h4>Gui</h4> + +<ul> +<li>The default gui display now uses a single tab for all text output. For + users upgrading from an earlier release, the current settings are + honored. If you wish to change to the new default, use the Restore Defaults + button on the Text Output settings dialog. + +<li>The final test run display shows a more detailed summary: passed tests, + errors, failures, inconclusive, non-runnable, skipped and ignored. + +<li>The status bar now displays errors and failures separately in. + +<li>The tree display shows non-runnable tests in red and inconclusive tests + in orange. Inconclusive tests are temporarily listed + on the Tests Not Run tab for this alpha release. +</ul> + +<h4>Extensibility</h4> + +<ul> +<li>A new extension point <b>ParameterProviders</b> allows addins to + provide data for parameterized tests. + +<li>The following extensions are included in the nunit.core.extensions + and nunit.framework.extensions assemblies: + <ul> + <li>The MaxTime extension, which was previously a sample. + <li>The RowTest extension, which remains an alternative to NUnit's + native TestCase syntax. + <li>The XmlConstraint extension, which allows comparing two xml files + </ul> +</ul> + + +<h3>Earlier Releases</h3> + +<ul> +<li>Release Notes for <a href="http://www.nunit.org/?p=releaseNotes&r=2.4.8">NUnit 2.4 through 2.4.8</a> +<li>Release Notes for <a href="http://www.nunit.org/?p=releaseNotes&r=2.2.10">NUnit 2.0 through 2.2.10</a> +</ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li id="current"><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/repeat.html b/tools/NUnit/doc/repeat.html new file mode 100644 index 0000000..ffeb8f1 --- /dev/null +++ b/tools/NUnit/doc/repeat.html @@ -0,0 +1,99 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Repeat</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RepeatAttribute (NUnit 2.5)</h3> + +<p><b>RepeatAttribute</b> is used on a test case to specify that it should be + executed multiple times. If any repetition fails, the remaining ones are + not run and a failure is reported. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li id="current"><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/requiredAddin.html b/tools/NUnit/doc/requiredAddin.html new file mode 100644 index 0000000..600995b --- /dev/null +++ b/tools/NUnit/doc/requiredAddin.html @@ -0,0 +1,148 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RequiredAddin</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RequiredAddinAttribute (NUnit 2.5)</h3> + +<p>The RequiredAddin attribute is used to indicate that an + assembly requires a particular addin in order to function correctly. If + that addin is not installed, the entire assembly is marked as non-runnable. + +<p><b>Note:</b> In the Alpha-3 release, this attribute may be applied to +classes or methods as well. This is of limited utility, for two reasons: +<ol> +<li>If the method or class is not recognized as a test, due to the addin +being missing, then NUnit will never process it. +<li>If the method or class is handled by some a different addin, that +addin may not recognize the attribute. +</ol> +<p>The attribute will be limited to assemblies only in the next release. + +<h4>Example</h4> + +<In the + +<div class="code"><pre> +[assembly: RequiredAddin("MyTestFixtureAddin")] +[assembly: RequiredAddin("MyTestAddin")] +[assembly: RequiredAddin("MyDecoratorAddin")] + +... + +namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [MyTestFixture] + public class MyTests + { + [MyTest] + public void SomeTest() + { + ... + } + } + + [TestFixture, MyDecorator] + public class MoreTests + { + [Test, MyDecorator] + public void AnotherTest() + { + ... + } + } +} +</pre> +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li id="current"><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/requiresMTA.html b/tools/NUnit/doc/requiresMTA.html new file mode 100644 index 0000000..5ebe94a --- /dev/null +++ b/tools/NUnit/doc/requiresMTA.html @@ -0,0 +1,147 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RequiresMTA</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RequiresMTAAttribute (NUnit 2.5)</h3> + +<p>The <b>RequiresMTAAttribute</b> is used on a test method, class or assembly + to specify that the tests should be run in the multi-threaded apartment. + It causes creation of a new thread if the parent test is not already running + in the MTA. + +<p><b>Note:</b> On test methods, you may also use the <b>MTAThreadAttribute</b>. + Although the runtime only recognizes this attribute on the entrypoint of + an executable assembly, many users have expected it to work on tests, so + we treat it as a synonym. + +<h4>Examples</h4> + +<div class="code"> + +<pre> + +// An MTA thread will be created and used to run +// all the tests in the assembly +[assembly:RequiresMTA] + +... + +// TestFixture requiring a separate thread +[TestFixture, RequiresMTA] +public class FixtureRequiringMTA +{ + // An MTA thread will be created and all + // tests in the fixture will run on it + // unless the containing assembly is + // already running on an MTA Thread +} + +[TestFixture] +public class AnotherFixture +{ + [Test, RequiresMTA] + public void TestRequiringMTA() + { + // A separate thread will be created for this test + // unless the containing fixture is already running + // in the MTA. + } +} + +</pre> + +</div> + +<h4>See also...</h4> +<ul> +<li><a href="requiresThread.html">RequiresThreadAttribute</a><li><a href="requiresSTA.html">RequiresSTAAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li id="current"><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/requiresSTA.html b/tools/NUnit/doc/requiresSTA.html new file mode 100644 index 0000000..0be81b0 --- /dev/null +++ b/tools/NUnit/doc/requiresSTA.html @@ -0,0 +1,148 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RequiresSTA</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RequiresSTAAttribute (NUnit 2.5)</h3> + +<p>The <b>RequiresSTAAttribute</b> is used on a test method, class or assembly + to specify that the tests should be run in the Single-threaded apartment. + It causes creation of a new thread if the parent test is not already running + in the STA. + +<p><b>Note:</b> On test methods, you may also use the <b>STAThreadAttribute</b>. + Although the runtime only recognizes this attribute on the entrypoint of + an executable assembly, many users have expected it to work on tests, so + we treat it as a synonym. + +<h4>Examples</h4> + +<div class="code"> + +<pre> + +// An STA thread will be created and used to run +// all the tests in the assembly +[assembly:RequiresSTA] + +... + +// TestFixture requiring a separate thread +[TestFixture, RequiresSTA] +public class FixtureRequiringSTA +{ + // An STA thread will be created and all + // tests in the fixture will run on it + // unless the containing assembly is + // already running on an STA Thread +} + +[TestFixture] +public class AnotherFixture +{ + [Test, RequiresSTA] + public void TestRequiringSTA() + { + // A separate thread will be created for this test + // unless the containing fixture is already running + // in the STA. + } +} + +</pre> + +</div> + +<h4>See also...</h4> +<ul> +<li><a href="requiresThread.html">RequiresThreadAttribute</a><li><a href="requiresMTA.html">RequiresMTAAttribute</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li id="current"><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/requiresThread.html b/tools/NUnit/doc/requiresThread.html new file mode 100644 index 0000000..84f5a72 --- /dev/null +++ b/tools/NUnit/doc/requiresThread.html @@ -0,0 +1,148 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RequiresThread</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>RequiresThreadAttribute (NUnit 2.5)</h3> + +<p>The <b>RequiresThreadAttribute</b> is used to indicate that a test method, + class or assembly should be run on a separate thread. Optionally, the + desired apartment for the thread may be specified in the constructor. + +<p><b>Note:</b> This attribute, used with or without an ApartmentState + argument will <b>always</b> result in creation of a new thread. To + create a thread only if the current ApartmentState is not appropriate, + use <b>RequiresSTAAttribute</b> or <b>RequiresMTAAttribute</b>. + +<h4>Examples</h4> + +<div class="code"> + +<pre> + +// A thread will be created and used to run +// all the tests in the assembly +[assembly:RequiresThread] + +... + +// TestFixture requiring a separate thread +[TestFixture, RequiresThread] +public class FixtureOnThread +{ + // A separate thread will be created and all + // tests in the fixture will run on it. +} + +[TestFixture] +public class AnotherFixture +{ + [Test, RequiresThread] + public void TestRequiringThread() + { + // A separate thread will be created for this test + } + + [Test, RequiresThread(ApartmentState.STA)] + public void TestRequiringSTAThread() + { + // A separate STA thread will be created for tnis test. + } +} + +</pre> + +</div> + +<h4>See also...</h4> +<ul> +<li><a href="requiresSTA.html">RequiresSTAAttribute</a><li><a href="requiresMTA.html">RequiresMTAAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li id="current"><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/runningTests.html b/tools/NUnit/doc/runningTests.html new file mode 100644 index 0000000..5cd27c3 --- /dev/null +++ b/tools/NUnit/doc/runningTests.html @@ -0,0 +1,100 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RunningTests</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Running Tests</h2> + +<p>Nunit provides three different runners, which may be used to load and +run your tests. + +<ul> +<li>The <a href="nunit-console.html">console runner</a>, + nunit-console.exe, is used for batch execution. +<li>The <a href="nunit-gui.html">gui runner</a>, nunit.exe, + provides interactive loading and running of tests. +<li>The <a href="pnunit.html">pNUnit runner</a>, + pnunit-launcher.exe, is used to run parallel, distributed tests under the + control of pNUnit. +</ul> + +<h3>Third-Party Runners</h3> + +<p>Various third-party applications are available for loading and running + NUnit tests. Some of these actually use NUnit to load the tests, while + others provide their own emulation and may not work in the same way + that NUnit does. + +<p>Because the status of such projects may change from time to time, we don't + discuss them individually here. For the latest information, consult the + manufacturer of any third-party software or ask other users on our + <a href="http://groups.google.com/group/nunit-discuss">discussion list</a>. + +<h3>Additional Information</h3> + +<p>For additional general information on how tests are loaded and run, see + +<ul> +<li><a href="runtimeSelection.html">Runtime Selection</a><li><a href="assemblyIsolation.html">Assembly Isolation</a><li><a href="configFiles.html">Configuration Files</a><li><a href="multiAssembly.html">Multiple Assemblies</a><li><a href="vsSupport.html">Visual Studio Support</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li id="current"><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/runtimeSelection.html b/tools/NUnit/doc/runtimeSelection.html new file mode 100644 index 0000000..3a55ad5 --- /dev/null +++ b/tools/NUnit/doc/runtimeSelection.html @@ -0,0 +1,117 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - RuntimeSelection</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>Runtime Selection</h3> + +<p>Before loading an assembly, NUnit must determine what runtime to use. By default +(see below for exceptions) the following rules are used: + +<ol> +<li><p>If the assembly was built for the same runtime under which NUnit is currently +running, then that runtime is used. + +<li><p>If the assembly was built for a different runtime version and that version +is available, NUnit uses it, running out of process if necessary. + +<li><p>If the assembly was built for a different runtime version, which is not +available, then the result depends on whether the build version is earlier or +later than the current version. If earlier, the test will be run using the +same runtime version under which NUnit is running. If later, then it is not +possible to load the test and NUnit gives an error message. + +<li><p>If multiple assemblies are being run at the same time, NUnit first +determines the runtime under which each assembly was built. The highest version +is then selected for the entire group, and rules 1 through 3 are applied. +</ol> + +<h3>Overriding the Defaults</h3> + +<p>The default runtime framework may be overridden using command line arguments, + menu items in the Gui or settings in an NUnit project file. Provided that the + requested framework is available, it will be used. If it isn't available, + NUnit will issue an error message. + +<p><b>Note:</b> To use version 1.x runtimes, you must have NUnit's support + for those runtimes installed, in addition to the runtime itself. This + support is an option of the NUnit installation. + +<h4>Command Line Options</h4> + +<p>The <b>/framework</b> option of console runner allows you to specify + the framework type and version to be used for a test run. See + <a href="consoleCommandLine.html">NUnit-Console Command Line Options</a> for more information. + +<h4>Gui Menu Selection</h4> + +<p>The main menu provides <b>File | Select Runtime</b> sub-items allowing you + to reload the tests under a specific runtime. See + <a href="mainMenu.html">Main Menu</a> for more info. + +<h4>Project Settings</h4> + +<p>The NUnit project format supports specification of a specific runtime to + be used with a project at the configuration level. See + <a href="projectEditor.html">Project Editor</a> for more information. +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li id="current"><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/sameasConstraint.html b/tools/NUnit/doc/sameasConstraint.html new file mode 100644 index 0000000..c09a2d1 --- /dev/null +++ b/tools/NUnit/doc/sameasConstraint.html @@ -0,0 +1,99 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - SameasConstraint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Same As Constraint (NUnit 2.4)</h2> + +<p>A SameAsConstraint is used to test whether the object passed + as an actual value has the same identity as the object supplied + in its constructor. + +<h4>Constructor</h4> + +<div class="code"><pre> +SameAsConstraint( object expected ) +</pre></div> + +<h4>Syntax</h4> + +<div class="code"><pre> +Is.SameAs( object expected ) +</pre></div> + +<h4>Examples of Use</h4> + +<div class="code"><pre> +Exception ex1 = new Exception(); +Exception ex2 = ex1; +Assert.That( ex2, Is.SameAs( ex1 ) ); + +Exception ex3 = new Exception(); +Assert.That( ex3, Is.Not.SameAs( ex1 ) ); +</pre></div> +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li id="current"><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/samples.html b/tools/NUnit/doc/samples.html new file mode 100644 index 0000000..d36c29a --- /dev/null +++ b/tools/NUnit/doc/samples.html @@ -0,0 +1,124 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Samples</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<style><!-- +dt { font-weight: bold; } +--></style> +<h2>Samples</h2> + +NUnit 2.5 samples continue to be organized by language, with an additional +folder for Extensibility examples. The 'money-port' example has been +removed. + +<h3>C# Samples</h3> +<dl> + <dt>Failures + <dd>This sample written in C# demonstrates 4 failing unit tests and one test + that is not run. + <dt>Money + <dd>This is a C# version of the money example which is found in most xUnit + implementations. Thanks to Kent Beck. +</dl> + +<h3>J# Samples</h3> +<dl> + <dt>Failures + <dd>This has three failing tests and one ignored test written in J#. +</dl> + +<h3>VB.NET Samples</h3> +<dl> + <dt>Failures + <dd>This sample written in VB.NET demonstrates 4 failing unit tests and + one test that is not run. + <dt>Money + <dd>This is a VB.NET version of the money example which is found in most xUnit + implementations. Thanks to Kent Beck. +</dl> + +<h3>Managed C++ Samples</h3> +<dl> + <dt>Failures + <dd>This is the same example as the others with four failing unit + tests and one ignored test. NOTE: The results are as expected when + compiled in Debug mode. In Release mode the divide by zero test succeeds. +</dl> + +<h3>C++/CLI Samples</h3> +<dl> + <dt>Failures + <dd>This is the same example as the others with four failing unit + tests and one ignored test. +</dl> + +<h3>Extensibility Examples</h3> +<dl> + <dt>Minimal + <dd>The smallest possible Addin: it does nothing but is + recognized by NUnit and listed in the Addins dialog. + <dt>SampleSuiteExtension + <dd>A "toy" SuiteBuilder. It recognizes a special attribute + and identifies tests right in the suite extension. This example + uses separate objects for the addin and the suite builder. + <dt>SampleFixtureExtension + <dd>A slightly more involved SuiteBuilder. It recognizes + a special attribute and registers a test case builder to + identify its tests. It inherits from NUnitTestFixture and + so gets all the features of that class as well for free. + This example uses the same object to implement both the + addin and the suite builder. +</dl> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li id="current"><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/sequential.html b/tools/NUnit/doc/sequential.html new file mode 100644 index 0000000..4cd751c --- /dev/null +++ b/tools/NUnit/doc/sequential.html @@ -0,0 +1,127 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Sequential</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>SequentialAttribute (NUnit 2.5)</h3> + +<p>The <b>SequentialAttribute</b> is used on a test to specify that NUnit should + generate test cases by selecting individual data items provided + for the parameters of the test, without generating additional + combinations. + +<p><b>Note:</b> If parameter data is provided by multiple attributes, +the order in which NUnit uses the data items is not guaranteed. However, +it can be expected to remain constant for a given runtime and operating +system. + +<h4>Example</h4> + +<p>The following test will be executed three times, as follows: +<pre> + MyTest(1, "A") + MyTest(2, "B") + MyTest(3, null) +</pre> +<div class="code"><pre> +[Test, Sequential] +public void MyTest( + [Values(1,2,3) int x, + [Values("A","B"] string s) +{ + ... +} +</pre></div> + +<h4>See also...</h4> +<ul> +<li><a href="combinatorial.html">CombinatorialAttribute</a><li><a href="pairwise.html">PairwiseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li id="current"><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/setCulture.html b/tools/NUnit/doc/setCulture.html new file mode 100644 index 0000000..92a827a --- /dev/null +++ b/tools/NUnit/doc/setCulture.html @@ -0,0 +1,191 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - SetCulture</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<style><!-- +div.code { width: 34em } +--></style> + +<h3>SetCultureAttribute (NUnit 2.4.2)</h3> +<p>The SetCulture attribute is used to set the current Culture for the duration +of a test. It may be specified at the level of a test or a fixture. The culture +remains set until the test or fixture completes and is then reset to its original +value. If you wish to use the current culture setting to decide whether to run +a test, use the Culture attribute instead of this one.</p> + +<p>Only one culture may be specified. Running a test under +multiple cultures is a planned future enhancement. At this time, you can +achieve the same result by factoring out your test code into a private method +that is called by each individual test method.</p> + +<h4>Examples:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + [SetCulture("fr-FR")] + public class FrenchCultureTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture(), SetCulture("fr-FR")> + Public Class FrenchCultureTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + [SetCulture("fr-FR")] + public __gc class FrenchCultureTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +/** @attribute NUnit.Framework.SetCulture("fr-FR") */ +public class FrenchCultureTests +{ + // ... +} +</pre> +</div> + +<h4>See also...</h4> +<ul> +<li><a href="culture.html">CultureAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li id="current"><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/settingsDialog.html b/tools/NUnit/doc/settingsDialog.html new file mode 100644 index 0000000..6ebc04a --- /dev/null +++ b/tools/NUnit/doc/settingsDialog.html @@ -0,0 +1,309 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - SettingsDialog</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Settings Dialog</h2> + +<p>The Settings Dialog is displayed using the Tools | Settings menu item and allows the user to +control some aspects of NUnit’s operation. Beginning with NUnit 2.4.4, a tree-based dialog +replaced the older tabbed format.</p> + +<hr><h3>Gui Settings - General</h3><hr> + +<div class="screenshot-right"> + <img src="img/generalSettings.jpg"></div> + +<h3>Gui Display</h3> + +<h4>Full Gui</h4> +<p>Displays the complete gui - as in prior versions of NUnit. This includes the + test result tabs and the progress bar.</p> + +<h4>Mini Gui</h4> +<p>Switches the display to the mini-gui, which consists of the tree display + only.</p> +<h3>Recent Files</h3> + +<p>The <b>Display ... files in list</b> TextBox allows the user to choose the number +of entries to display in the recent files list. + +<p>Normally, NUnit checks that project files still exist before +displaying them in the recent files list. This can cause long delays if the +file is on a network connection that is no longer available. Unchecking +<b>Check that files exist before listing</b> will avoid this delay, so +long as the missing file is not actually selected. + +<p>If <b>Load most recent project at startup</b> is checked, the GUI will load the +last file opened unless it is run with a specific filename or with the +<code>/noload</code> parameter.</p> + +<hr style="clear: both"><h3>Gui Settings - Tree Display</h3><hr> + +<div class="screenshot-right"> + <img src="img/treeDisplaySettings.jpg"></div> + +<h3>Tree View</h3> + +<p>The list box allows selecting the degree of expansion of the tree when tests are loaded:</p> +<blockquote> +<p><b>Auto</b> – selects a setting based on the space available for the tree display.</p> +<p><b>Expand</b> – expands all tests</p> +<p><b>Collapse</b> – collapses all tests</p> +<p><b>Hide Tests</b> – expands all suites except for the fixtures themselves.</p> +</blockquote> + +<p>If <b>Clear results when reloading</b> is checked, an automatic or manual reload will reinitialize all +test nodes in the tree (grey display) – if it is not checked, result information for tests that do +not seem to have changed will be retained.</p> + +<p>If <b>Save visual state of each project</b> is checked, NUnit saves the state of the tree +and restores it when the project is next opened. The information saved includes which +branches of the tree are expanded, the selected node, any checked nodes and any +category selection. + +<p>If <b>Show Checkboxes</b> is checked, the tree includes checkboxes, which may + be used to select multiple tests for running. This setting is also available + in the <b>View | Tree</b> menu.</p> + +<h3>Test Structure</h3> + +<p>If <b>Automatic Namespace suites</b> is selected, tests will be + shown in a hierarchical listing based on namespaces. This is the + standard display as used in versions prior to NUnit 2.4. + +<p>If <b>Flat list of TestFixtures</b> is selected, tests will be + shown as a sequential list of fixtures. + +<hr style="clear: both"><h3>Gui Settings - Test Results</h3><hr> + +<div class="screenshot-right"> + <img src="img/testResultSettings.jpg"></div> + +<h3>Errors Tab</h3> + +<p>Check <b>Display Errors and Failures Tab</b> to display the +<b>Errors and Failures</b> tab, which shows information about failing tests. + +<p>Check <b>Enable Failure ToolTips</b> to display the tip window over the +Errors and Failures display and the stack trace. Clear it if you prefer not +to see the tip window.</p> + +<p>Check <b>Enable Word Wrap</b> to turn on word wrapping +in the Errors and Failures display. While you can select this item and the +preceding one at the same time, they do not interact well, so you will +normally choose one or the other.</p> + +<h3>Not Run Tab</h3> + +<p>Check <b>Display Tests Not Run Tab</b> to display the +<b>Tests Not Run</b> tab, which shows information about tests that were +skipped or ignored. + +<hr style="clear: both"><h3>Gui Settings - Text Output</h3><hr> + +<div class="screenshot-right"> + <img src="img/textOutputSettings.jpg"></div> + +<h3>Select Tab</h3> + +<p>The <b>Select Tab</b> dropdown list is used to select one of the output tabs, for which +settings are to be viewed or changed. It also contains entries that allow +you to add a new tab or edit the list of tabs. + +<p>The <b>Restore Defaults</b> button is used to restore the default +setting, which is a single tab labeled "Text Output." The default tab +displays all types of output and includes a label for each test that +displays text. + +<p>The <b>Title</b> text box is used to modify the title displayed +for the selected output tab. + +<p><b>Enabled</b> is checked by default. If you uncheck it, +the selected tab will be removed from the tab control. This allows you to temporarily +suppress output to a tab without actually removing its definition. + +<h3>Content</h3> + +<p>The four check boxes enable or disable a particular type of output +on the selected output window. For each type, the display captures +output produced while your test is running - either by the test +itself or by the program you are testing. + +<h4>Standard Output</h4> +<p>Captures all output written to Console.Out. + +<h4>Error Output</h4> +<p>Captures all output written to Console.Error. + +<h4>Trace Output</h4> +<p>Captures all output written to Trace or Debug. + +<h4>Log Output</h4> +<p>Captures output written to a log4net log. NUnit captures +all output at the Error level or above unless another level +is specified for the DefaultLogThreshold setting in the +configuration file for the test assembly or project. + +<h3>Test Labels</h3> + +<p>Check <b>Display TestCase Labels</b> to precede text in the output window +with the name of the test that produced it.</p> + +<p>Check <b>Suppress label if no output is displayed</b> to eliminate display +of labels for tests that produce no output in the window. + + +<hr style="clear: both"><h3>Test Loader Settings - Assembly Isolation</h3><hr> + +<div class="screenshot-right"> + <img src="img/testLoadSettings.jpg"></div> + +<h3>Default Process Model</h3> + +<p>These settings determine NUnit's default use of operating system +processes and may be overridden by settings in the NUnit project. + +<p>If <b>Run tests directly in the NUnit process</b> is selected, +all tests are run in a test domain in the same process as NUnit. +This is the way previous versions of NUnit ran tests and is the +default setting. + +<p>If <b>Run tests in a single separate process</b> is selected, +a separate process is used for all tests. + +<p>If <b>Run tests in a separate process per Assembly </b> is selected, +a separate process is used for each test assembly. + +<h3>Default Domain Usage</h3> + +<p>If <b>Use a separate AppDomain per Assembly</b> is selected, each assembly + in a multiple-assembly test run will be loaded in a separate AppDomain. + This setting is not available when <b>Run tests in a separate process + per Assembly</b> is selected above. + +<p>If <b>Use a single AppDomain for all tests</b> is selected, all assemblies in + a multiple-assembly test run will use the same AppDomain. This was + the standard behavior of NUnit prior to version 2.4 and is the + default setting. + +<p>If <b>Merge tests across assemblies</b> is checked, the display of tests + will not be divided across assemblies. If automatic namespace suites are + used, they will be merged across all assemblies. This option is only + available when tests are run in the same appdomain. + +<hr style="clear: both"><h3>Test Loader Settings - Assembly Reload</h3><hr> + +<div class="screenshot-right"> + <img src="img/assemblyReloadSettings.jpg"></div> + +<h3>Assembly Reload</h3> + +<p>If <b>Reload before each test run</b> is checked, a reload will occur whenever the run button is +pressed whether the assemblies appear to have changed or not.</p> + +<p>If <b>Reload when test assembly changes</b> is checked, assemblies are watched for any change and +an automatic reload is initiated. This item is disabled on Windows 98 or ME.</p> + +<p>If <b>Re-run last tests run</b> is checked, tests are re-run whenever a Reload + takes place.</p> + +<hr style="clear: both"><h3>Test Loader Settings - Advanced</h3><hr> + +<div class="screenshot-right"> + <img src="img/advancedSettings.jpg"></div> + +<h3>Shadow Copy</h3> + +<p>NUnit normally uses .Net shadow-copying in order to allow you to edit +and recompile assemblies while it is running. Uncheck this box to disable +shadow-copy only if you have a particular problem that requires it.</p> + +<p><b>Note:</b> If you are tempted to disable shadow copy in order to access +files in the same directory as your assembly, you should be aware that there +are alternatives. Consider using the Assembly.Codebase property rather than +Assembly.Location. + + +<hr style="clear: both"><h3>IDE Support Settings - Visual Studio</h3><hr> + +<div class="screenshot-right"> + <img src="img/visualStudioSettings.jpg"></div> + +<h3>Visual Studio</h3> + +<p>If <b>Enable Visual Studio Support</b> is checked, the user will be able to open Visual Studio projects +and solutions and add Visual Studio projects to existing test projects.</p> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li id="current"><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/setup.html b/tools/NUnit/doc/setup.html new file mode 100644 index 0000000..dded6ef --- /dev/null +++ b/tools/NUnit/doc/setup.html @@ -0,0 +1,239 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Setup</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>SetUpAttribute (NUnit 2.0 / 2.5)</h3> + +<p>This attribute is used inside a TestFixture to provide a common set of + functions that are performed just before each test method is called. + +<p><b>Before NUnit 2.5</b>, a TestFixture could have only one SetUp method + and it was required to be an instance method. + +<p><b>Beginning with NUnit 2.5</b>, SetUp methods may be either static or + instance methods and you may define more than one of them in a fixture. + Normally, multiple SetUp methods are only defined at different levels + of an inheritance hierarchy, as explained below. + +<p>If a SetUp method fails or throws an exception, the test is not executed + and a failure or error is reported. + + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [SetUp] public void Init() + { /* ... */ } + + [TearDown] public void Cleanup() + { /* ... */ } + + [Test] public void Add() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <SetUp()> Public Sub Init() + ' ... + End Sub + + <TearDown()> Public Sub Cleanup() + ' ... + End Sub + + <Test()> Public Sub Add() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [SetUp] void Init(); + [TearDown] void Cleanup(); + + [Test] void Add(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.SetUp() */ + public void Init() + { /* ... */ } + + /** @attribute NUnit.Framework.TearDown() */ + public void Cleanup() + { /* ... */ } + + /** @attribute NUnit.Framework.Test() */ + public void Add() + { /* ... */ } +} +</pre> + +</div> + +<h3>Inheritance</h3> + +<p>The SetUp attribute is inherited from any base class. Therefore, if a base + class has defined a SetUp method, that method will be called + before each test method in the derived class. + +<p>Before NUnit 2.5, you were permitted only one SetUp method. If you wanted to + have some SetUp functionality in the base class and add more in the derived + class you needed to call the base class method yourself. + +<p>With NUnit 2.5, you can achieve the same result by defining a SetUp method + in the base class and another in the derived class. NUnit will call base + class SetUp methods before those in the derived classes. + +<p><b>Note:</b> Although it is possible to define multiple SetUp methods + in the same class, you should rarely do so. Unlike methods defined in + separate classes in the inheritance hierarchy, the order in which they + are executed is not guaranteed. + +<h4>See also...</h4> +<ul> +<li><a href="teardown.html">TearDownAttribute</a><li><a href="fixtureSetup.html">TestFixtureSetUpAttribute</a><li><a href="fixtureTeardown.html">TestFixtureTearDownAttribute</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li id="current"><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/setupFixture.html b/tools/NUnit/doc/setupFixture.html new file mode 100644 index 0000000..005c73f --- /dev/null +++ b/tools/NUnit/doc/setupFixture.html @@ -0,0 +1,216 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - SetupFixture</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>SetUpFixtureAttribute (NUnit 2.4)</h3> + +<p>This is the attribute that marks a class that contains the one-time + setup or teardown methods for all the test fixtures under a given + namespace. The class may contain at most one method marked with the + SetUpAttribute and one method marked with the TearDownAttribute.</p> + +<p>There are a few restrictions on a class that is used as a setup fixture. + <ul> + <li> + It must be a publicly exported type or NUnit will not see it.</li> + <li> + It must have a default constructor or NUnit will not be able to construct it.</li> + </ul> +</p> + +<p>The SetUp method in a SetUpFixture is executed once before any of the fixtures +contained in its namespace. The TearDown method is executed once after all the +fixtures have completed execution. In the examples below, the method RunBeforeAnyTests() +is called before any tests or setup methods in the NUnit.Tests namespace. The method +RunAfterAnyTests() is called after all the tests in the namespace as well as their +individual or fixture teardowns have completed exection.</p> + +<p>Only one SetUpFixture should be created in a given namespace. A SetUpFixture +outside of any namespace provides SetUp and TearDown for the entire assembly. + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [SetUpFixture] + public class MySetUpClass + { + [SetUp] + RunBeforeAnyTests() + { + // ... + } + + [TearDown] + RunAfterAnyTests() + { + // ... + } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class MySetUpClass + <SetUp()> Public Sub RunBeforeAnyTests() + ' ... + End Sub + + <TearDown()> Public Sub RunAfterAnyTests() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class MySetUpClass + { + [SetUp] public void RunBeforeAnyTests(); + [TearDown] public void RunAfterAnyTests(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class MySetUpClass +{ + /** @attribute NUnit.Framework.SetUp() */ + public void RunBeforeAnyTests() + { /* ... */ } + + /** @attribute NUnit.Framework.TearDown() */ + public void RunAfterAnyTests() + { /* ... */ } +} +</pre> + +</div> +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li id="current"><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/stringAssert.html b/tools/NUnit/doc/stringAssert.html new file mode 100644 index 0000000..0506e41 --- /dev/null +++ b/tools/NUnit/doc/stringAssert.html @@ -0,0 +1,105 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - StringAssert</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>StringAssert (NUnit 2.2.3)</h2> +<p>The StringAssert class provides a number of methods that are useful +when examining string values.</p> + +<div class="code" style="width: 36em"> +<pre>StringAssert.Contains( string expected, string actual ); +StringAssert.Contains( string expected, string actual, + string message ); +StringAssert.Contains( string expected, string actual, + string message, params object[] args ); + +StringAssert.StartsWith( string expected, string actual ); +StringAssert.StartsWith( string expected, string actual, + string message ); +StringAssert.StartsWith( string expected, string actual, + string message, params object[] args ); + +StringAssert.EndsWith( string expected, string actual ); +StringAssert.EndsWith( string expected, string actual, + string message ); +StringAssert.EndsWith( string expected, string actual, + string message, params object[] args ); + +StringAssert.AreEqualIgnoringCase( string expected, string actual ); +StringAssert.AreEqualIgnoringCase( string expected, string actual, + string message ); +StringAssert.AreEqualIgnoringCase( string expected, string actual, + string message params object[] args ); + +StringAssert.IsMatch( string regexPattern, string actual ); +StringAssert.IsMatch( string regexPattern, string actual, + string message ); +StringAssert.IsMatch( string regexPattern, string actual, + string message, params object[] args );</pre> +</div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li id="current"><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/stringConstraints.html b/tools/NUnit/doc/stringConstraints.html new file mode 100644 index 0000000..96693fa --- /dev/null +++ b/tools/NUnit/doc/stringConstraints.html @@ -0,0 +1,242 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - StringConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>String Constraints (NUnit 2.4)</h2> + +<p>String constraints perform tests that are specific to strings. + Attempting to test a non-string value with a string constraint + is an error and gives an exception. + +<p>The <b>Text</b> prefix is deprecated beginning with NUnit 2.5.1 + and will be removed in NUnit 3.0. + +<h3>SubstringConstraint</h3> + +<h4>Action</h4> +<p>Tests for a substring. + +<h4>Constructor</h4> +<div class="code"><pre> +SubstringConstraint(string expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.StringContaining(string expected) +Contains.Substring(string expected) +ContainsSubstring(string expected) +Contains(string expected) +[Obsolete] Text.Contains(string expected) +[Obsolete] Text.DoesNotContain(string expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +string phrase = "Make your tests fail before passing!" + +Assert.That( phrase, Is.StringContaining( "tests fail" ) ); +Assert.That( phrase, Contains.Substring( "tests fail" ) ); +Assert.That( phrase, Is.Not.StringContaining( "tests pass" ) ); +Assert.That( phrase, Is.StringContaining( "make" ).IgnoreCase ); +Expect (phrase, Contains.Substring( "make" ).IgnoreCase ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>ContainsSubstring</b> and <b>Contains</b> may appear only in the + body of a constraint expression or when the inherited syntax is used. +<li><b>Contains</b> is not actually a string constraint but is converted + to one when a string is being tested. +</ol> + +<h3>StartsWithConstraint</h3> + +<h4>Action</h4> +<p>Tests for an initial string. + +<h4>Constructor</h4> +<div class="code"><pre> +StartsWithConstraint(string expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.StringStarting(string expected) +StartsWith(string expected) +[Obsolete] Text.StartsWith(string expected) +[Obsolete] Text.DoesNotStartWith(string expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +string phrase = "Make your tests fail before passing!" + +Assert.That( phrase, Is.StringStarting( "Make" ) ); +Assert.That( phrase, Is.Not.StringStarting( "Break" ) ); +Assert.That( phrase, Has.Length.GreaterThan(10) + .And.Not.StartsWith( "Break" ) ); +Expect( phrase, StartsWith( "Make" ) ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>StartsWith</b> may appear only in the body of a constraint + expression or when the inherited syntax is used. +</ol> + +<h3>EndsWithConstraint</h3> + +<h4>Action</h4> +<p>Tests for an ending string. + +<h4>Constructor</h4> +<div class="code"><pre> +EndsWithConstraint(string expected) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.StringEnding(string expected) +EndsWith(string expected) +[Obsolete] Text.EndsWith(string expected) +[Obsolete] Text.DoesNotEndWith(string expected) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +string phrase = "Make your tests fail before passing!" + +Assert.That( phrase, Is.StringEnding( "!" ) ); +Assert.That( phrase, Is.StringEnding( "PASSING!" ).IgnoreCase ); +Expect( phrase, EndsWith( "!" ) ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>EndsWith</b> may appear only in the body of a constraint + expression or when the inherited syntax is used. +</ol> + +<h3>RegexConstraint</h3> + +<h4>Action</h4> +<p>Tests that a pattern is matched. + +<h4>Constructor</h4> +<div class="code"><pre> +RegexConstraint(string pattern) +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Is.StringMatching(string pattern) +Matches(string pattern) +[Obsolete] Text.Matches(string pattern) +[Obsolete] Text.DoesNotMatch(string pattern) +</pre></div> + +<h4>Modifiers</h4> +<div class="code"><pre> +...IgnoreCase +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +string phrase = "Make your tests fail before passing!" + +Assert.That( phrase, Is.StringMatching( "Make.*tests.*pass" ) ); +Assert.That( phrase, Is.Not.StringMatching( "your.*passing.*tests" ) ); +Assert.That( phrase, Has.Length.GreaterThan(10) + .And.Not.Matches( "your.*passing.*tests" ) ); +Expect( phrase, Matches( "Make.*pass" ) ); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>Matches</b> may appear only in the body of a constraint + expression or when the inherited syntax is used. +</ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li id="current"><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/suite.html b/tools/NUnit/doc/suite.html new file mode 100644 index 0000000..7f8f686 --- /dev/null +++ b/tools/NUnit/doc/suite.html @@ -0,0 +1,238 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Suite</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<div style="float:right"><b>Update: August 22, 2007</b></div> +<h3>SuiteAttribute (NUnit 2.0/2.4.4)</h3> + +<p>The Suite Attribute is used to define subsets of test to be run from the + command-line, using the <b>/fixture</b> option. It was introduced in NUnit + 2.0 to replace the older approach of inheriting from the TestSuite class.</p> + +<p>Originally, the NUnit developers believed that the need for the Suite + mechanism would diminish because of the dynamic creation of suites based + on namespaces. It was provided for backwards compatibility.</p> + +<p>That has not proven to be true. Suites are still used today by many people, + so we are making an effort to revive them in terms of usability. + +<p>The Suite mechanism depends on a static property marked with the </b>SuiteAttribute</b>. + In the clasic implementation, supported by all releases since 2.0, that property + returns a TestSuite, populated with the tests that are to be executed. + +<h4>Old Approach</h4> + +<div class="code"> + +<pre>namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + using NUnit.Core; + + public class AllTests + { + [Suite] + public static TestSuite Suite + { + get + { + TestSuite suite = new TestSuite("All Tests"); + suite.Add(new OneTestCase()); + suite.Add(new Assemblies.AssemblyTests()); + suite.Add(new AssertionTest()); + return suite; + } + } + } +} +</pre> + +</div> + +<p>This approach has a serious problem: it requires a reference to the nunit.core assembly, + which is not normally referenced by user tests. This means that the tests + cannot be ported across versions of NUnit without recompilation. In some cases, + introducing more than one version of the core assembly can prevent NUnit + from running correctly. + +<p>Beginning with NUnit 2.4.4, a new approach is available. The property marked + with the <b>SuiteAttribute</b> may simply return a collection containing test + fixture objects or Types. + If a Type is provided, NUnit creates an object of that type for use + as a fixture. Any other object is assumed to be a pre-created fixture object. + This allows objects with parameterized constructors or settable + properties to be used as fixtures. + +<p>Test suites created through use of the <b>SuiteAttribute</b> may contain <b>TestFixtureSetUp</b> and + <b>TestFixtureTearDown</b> methods, to perform one-time setup and teardown + for the tests included in the suite. + +<h4>New Approach - Fixture Objects</h4> + +<div class="code"> + +<pre>namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + private class AllTests + { + [Suite] + public static IEnumerable Suite + { + get + { + ArrayList suite = new ArrayList(); + suite.Add(new OneTestCase()); + suite.Add(new AssemblyTests()); + suite.Add(new NoNamespaceTestFixture()); + return suite; + } + } + } +} +</pre> + +</div> + +<h4>New Approach - Fixture Types</h4> + +<div class="code"> + +<pre>namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + private class AllTests + { + [Suite] + public static IEnumerable Suite + { + get + { + ArrayList suite = new ArrayList(); + suite.Add(typeof(OneTestCase)); + suite.Add(typeof(AssemblyTests)); + suite.Add(typeof(NoNamespaceTestFixture)); + return suite; + } + } + } +} +</pre> + +</div> + +<h4>Limitations</h4> + +NUnit support for user-defined Suites currently has two limitations: + +<ol> + <li>It is not possible to include individual test cases directly + in a Suite using the new approach. Anyone wanting to do so will + need to use the old approach and create an object derive from + NUnit.Core.TestCase. This is not recommended, since it requires + a reference to the core assembly. + + <li>Suites are currently not displayed in the Gui or run automatically + by either runner when they are encountered. The historical purpose of + the Suite mechanism was to provide a way of aggregating tests at the + top level of each run. Hence, they are only supported when used with + the /fixture option on the console or gui command line. +</ol> + +Approaches to removing these limitations are being investigated as part +of the planning for future NUnit releases. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li id="current"><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/suiteBuilders.html b/tools/NUnit/doc/suiteBuilders.html new file mode 100644 index 0000000..c6b81cc --- /dev/null +++ b/tools/NUnit/doc/suiteBuilders.html @@ -0,0 +1,101 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - SuiteBuilders</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>SuiteBuilders (NUnit 2.4)</h3> + +<h4>Purpose</h4> +<p>A SuiteBuilder is an addin used to build a test fixture from a type. NUnit itself +uses a SuiteBuilder to recognize and build TestFixtures. + +<h4>Extension Point</h4> +<p>An addin may use the host to access this extension point by name: + +<pre> + IExtensionPoint suiteBuilders = host.GetExtensionPoint( "SuiteBuilders" );</pre> + +<h4>Interface</h4> +<p>The extension object passed to Install must implement the ISuiteBuilder interface: + +<pre> + public interface ISuiteBuilder + { + bool CanBuildFrom( Type type ); + Test BuildFrom( Type type ); + } +</pre> + +<p>CanBuildFrom should return true if the specified Type is one from which +the builder is able to create a fixture. This usually involve examining +the Type and its attriutes. + +<p>The BuildFrom method should return a test fixture completely populated +with its contained test cases. Return null if it is not possible to +build a fixture using the provided Type. + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li id="current"><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/teardown.html b/tools/NUnit/doc/teardown.html new file mode 100644 index 0000000..d59dbac --- /dev/null +++ b/tools/NUnit/doc/teardown.html @@ -0,0 +1,239 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Teardown</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TearDownAttribute (NUnit 2.0 / 2.5)</h3> + +<p>This attribute is used inside a TestFixture to provide a common set of + functions that are performed after each test method is run. + +<p><b>Before NUnit 2.5</b>, a TestFixture could have only one TearDown method + and it was required to be an instance method. + +<p><b>Beginning with NUnit 2.5</b>, TearDown methods may be either static or + instance methods and you may define more than one of them in a fixture. + Normally, multiple TearDown methods are only defined at different levels + of an inheritance hierarchy, as explained below. + +<p>So long as any SetUp method runs without error, the TearDown method is + guaranteed to run. It will not run if a SetUp method fails or throws an + exception.</p> + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [SetUp] public void Init() + { /* ... */ } + + [TearDown] public void Cleanup() + { /* ... */ } + + [Test] public void Add() + { /* ... */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <SetUp()> Public Sub Init() + ' ... + End Sub + + <TearDown()> Public Sub Cleanup() + ' ... + End Sub + + <Test()> Public Sub Add() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [SetUp] void Init(); + [TearDown] void Cleanup(); + + [Test] void Add(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.SetUp() */ + public void Init() + { /* ... */ } + + /** @attribute NUnit.Framework.TearDown() */ + public void Cleanup() + { /* ... */ } + + /** @attribute NUnit.Framework.Test() */ + public void Add() + { /* ... */ } +} +</pre> + +</div> + +<h3>Inheritance</h3> + +<p>The TearDown attribute is inherited from any base class. Therefore, if a base + class has defined a TearDown method, that method will be called + after each test method in the derived class. + +<p>Before NUnit 2.5, you were permitted only one TearDown method. If you wanted to + have some TearDown functionality in the base class and add more in the derived + class you needed to call the base class method yourself. + +<p>With NUnit 2.5, you can achieve the same result by defining a TearDown method + in the base class and another in the derived class. NUnit will call base + class TearDown methods after those in the derived classes. + +<p><b>Note:</b> Although it is possible to define multiple TearDown methods + in the same class, you should rarely do so. Unlike methods defined in + separate classes in the inheritance hierarchy, the order in which they + are executed is not guaranteed. + +<h4>See also...</h4> +<ul> +<li><a href="setup.html">SetUpAttribute</a><li><a href="fixtureSetup.html">TestFixtureSetUpAttribute</a><li><a href="fixtureTeardown.html">TestFixtureTearDownAttribute</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li id="current"><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/test.html b/tools/NUnit/doc/test.html new file mode 100644 index 0000000..fe17e3f --- /dev/null +++ b/tools/NUnit/doc/test.html @@ -0,0 +1,215 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Test</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestAttribute (NUnit 2.0 / 2.5)</h3> + +<p>The Test attribute is one way of marking a method inside a TestFixture class + as a test. For backwards compatibility with previous versions of Nunit a + test method may also be found if the first 4 letters are "test" + regardless of case. This option is available by setting a value in + the config file for the test.</p> + +<p>Prior to NUnit 2.5, the signature for a test method was: + <pre> public void MethodName()</pre></p> + +<p>Beginning with NUnit 2.5, static methods may be used as tests: + <pre> public static void MethodName()</pre></p> + +<p>In addition, with 2.5, test methods may have arguments and return + values, provided that NUnit is told what values to use for the + arguments and how to handle the return value. For more information + on these capabilities, see + <a href="parameterizedTests.html">Parameterized Tests</a> as well as some of the related attributes + listed at the end of this page. + +<p>Parameterized test methods may also be generic, provided that + NUnit is able to deduce the proper argument types from the + types of the data arguments supplied. + +<p>If the programmer marks a test method that does not have the correct signature + it will be considered as not runnable and be indicated as such by the console + or gui runner. In the Gui, such tests are marked in red.</p> + +<p>In the examples on this page, NUnit would have no way of knowing what values + to supply as arguments, so methods without parameters are used. + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + [Test] public void Add() + { /* ... */ } + + public void TestSubtract() + { /* backwards compatibility */ } + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + <Test()> Public Sub Add() + ' ... + End Sub + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + [Test] void Add(); + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + /** @attribute NUnit.Framework.Test() */ + public void Add() + { /* ... */ } +} +</pre> +</div> + +<h4>See also...</h4> + +<ul> +<li><a href="parameterizedTests.html">Parameterized Tests</a><li><a href="testCase.html">TestCaseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li id="current"><a href="test.html">Test</a></li> +<ul> +<li><a href="parameterizedTests.html">Parameterized Tests</a></li> +</ul> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testCase.html b/tools/NUnit/doc/testCase.html new file mode 100644 index 0000000..c6a7a06 --- /dev/null +++ b/tools/NUnit/doc/testCase.html @@ -0,0 +1,180 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestCase</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestCaseAttribute (NUnit 2.5)</h3> + +<p><b>TestCaseAttribute</b> serves the dual purpose of marking a method with + parameters as a test method and providing inline data to be used when + invoking that method. Here is an example of a test being run three + times, with three different sets of data: + +<div class="code"> +<pre>[TestCase(12,3,4)] +[TestCase(12,2,6)] +[TestCase(12,4,3)] +public void DivideTest(int n, int d, int q) +{ + Assert.AreEqual( q, n / d ); +} +</pre> +</div> + +<p><b>Note:</b> Because arguments to .NET attributes are limited in terms of the +Types that may be used, NUnit will make some attempt to convert the supplied +values using <b>Convert.ChangeType()</b> before supplying it to the test. + +<p><b>TestCaseAttribute</b> may appear one or more times on a test method, +which may also carry other attributes providing test data, such as the +<a href="factories.html">FactoriesAttribute</a>. +The method may optionally be marked with the +<a href="test.html">TestAttribute</a> as well. + +<p>By using the named parameter <b>Result</b> this test set may be simplified +further: + +<div class="code"> +<pre>[TestCase(12,3, Result=4)] +[TestCase(12,2, Result=6)] +[TestCase(12,4, Result=3)] +public int DivideTest(int n, int d) +{ + return( n / d ); +} +</pre> +</div> + +<p>In the above example, NUnit checks that the return +value of the method is equal to the expected result provided on the attribut + +<p><b>TestCaseAttribute</b> supports a number of additional +named parameters, which may be used as follows: + +<dl> +<dt><b>Description</b> +<dd>Sets the description property of the test +<dt><b>ExpectedException</b> +<dd>Specifies a the Type of an exception that should be thrown by this invocation +<dt><b>ExpectedExceptionName</b> +<dd>Specifies a the FullName of an exception that should be thrown by this invocation +<dt><b>ExpectedMessage</b> +<dd>Specifies the message text of the expected exception +<dt><b>MatchType</b> +<dd>A <b>MessageMatch</b> enum value indicating how to test the expected message +(See <a href="exception.html">ExpectedExceptionAttribute</a>) +<dt><b>Result</b> +<dd>The expected result to be returned from the method, which must have +a compatible return type. +<dt><b>TestName</b> +<dd>Provides a name for the test. If not specified, a name is generated based on +the method name and the arguments provided. +<dt><b>Ignore</b> +<dd>Set to true in order to ignore the individual test case. +<dt><b>IgnoreReason</b> +<dd>Specifies the reason for ignoring this test case. If set to a non-empty + string, then Ignore is assumed to be true. +</dl> + +<h3>Order of Execution</h3> + +<p>In NUnit 2.5, individual test cases are sorted alphabetically and executed in + that order. With NUnit 2.5.1, the individual cases are not sorted, but are + executed in the order in which NUnit discovers them. This order does <b>not</b> + follow the lexical order of the attributes and will often vary between different + compilers or different versions of the CLR. + +<p>As a result, when <b>TestCaseAttribute</b> appears multiple times on a method + or when other data-providing attributes are used in combination with + <b>TestCaseAttribute</b>, the order of the test cases is undefined. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li id="current"><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testCaseSource.html b/tools/NUnit/doc/testCaseSource.html new file mode 100644 index 0000000..1ba7d41 --- /dev/null +++ b/tools/NUnit/doc/testCaseSource.html @@ -0,0 +1,318 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestCaseSource</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestCaseSourceAttribute (NUnit 2.5)</h3> + +<p><b>TestCaseSourceAttribute</b> is used on a parameterized test method to +identify the property, method or field that will provide the required +arguments. The attribute has two public constructors. + +<div class="code"> +<pre> +TestCaseSourceAttribute(Type sourceType, string sourceName); +TestCaseSourceAttribute(string sourceName); +</pre> +</div> + +<p>If <b>sourceType</b> is specified, it represents the class that provides +the test cases. It must have a default constructor. + +<p>If <b>sourceType</b> is not specified, the class containing the test +method is used. NUnit will construct it using either the default constructor +or - if arguments are provided - the appropriate constructor for those +arguments. + +<p>The <b>sourceName</b> argument represents the name of the source used +to provide test cases. It has the following characteristics: +<ul> +<li>It may be a field, property or method. +<li>It may be either an instance or a static member. +<li>It must return an IEnumerable or a type that implements IEnumerable. +<li>The individual items returned by the enumerator must be compatible + with the signature of the method on which the attribute appears. + The rules for this are described in the next section. +</ul> + +<h3>Constructing Test Cases</h3> + +<p>In constructing tests, NUnit uses each item test case returned by +the enumerator as follows: +<ol> +<li><p>If it is an <b>object[]</b>, it is used directly to provide +the arguments for the method, as in this example, which returns +arguments from a named static field. + +<div class="code"> +<pre>[Test, TestCaseSource("DivideCases")] +public void DivideTest(int n, int d, int q) +{ + Assert.AreEqual( q, n / d ); +} + +static object[] DivideCases = +{ + new object[] { 12, 3, 4 }, + new object[] { 12, 2, 6 }, + new object[] { 12, 4, 3 } +}; +</pre></div> + +<li><p>If it is an array of some other type, NUnit can use it provided +that the arguments to the method are all of that type. For example, +the above code could be modified to make the three nested arrays +of type int[]. + +<li><p>If it is a single value type - like numerics or DateTime - it +is used directly as the sole argument to the method. The method must, +of course take a single argument of the same type for this to work. +This eliminates a bit of syntax on the part of the programmer, as in +this example: + +<div class="code"><pre> +static int[] EvenNumbers = new int[] { 2, 4, 6, 8 }; + +[Test, TestCaseSource("EvenNumbers")] +public void TestMethod(int num) +{ + Assert.IsTrue( num % 2 == 0 ); +} +</pre></div> + +<p><b>Note:</b> Any user-defined struct intended to hold the arguments +will be passed directly to the test method, since a struct is a value type. +If you intend your user type to be used as described in the following item, +you must define it as a class. + +<li><p>If it is any other type of object, it is examined using reflection +and any public fields or properties with the following names are used: + <p><dl> + <dt><b>Arguments</b> + <dd>An <b>object[]</b> representing the arguments to the method + <dt><b>Categories</b> + <dd>An IList of categories to be applied to the test case. + <dt><b>Description</b> + <dd>Sets the description property of the test + <dt><b>ExpectedException</b> + <dd>Specifies a the Type of an exception that should be thrown by this invocation + <dt><b>ExpectedExceptionName</b> + <dd>Specifies a the FullName of an exception that should be thrown by this invocation + <dt><b>Properties</b> + <dd>An IDictionary of properties to be applied to the test case. + Note that the values provided must be compatible with PropertiesAttribute. + In particular, use of custom types or enums will cause problems. + <dt><b>Result</b> + <dd>The expected result to be returned from the method, which must have + a compatible return type. + <dt><b>TestName</b> + <dd>Provides a name for the test. If not specified, a name is generated based on + the method name and the arguments provided + <dt><b>Ignored</b> + <dd>If true, the test case is ignored. + <dt><b>IgnoreReason</b> + <dd>Specifies the reason for ignoring this test case. If set to a non-empty + string, then the test is ignored. + </dl> + +<h3>TestCaseData Class</h3> + +<p>Although any object with the required fields or properties may be used, + NUnit provides the <b>TestCaseData</b> class for this purpose. The following + example returns <b>TestCaseData</b> instances from a data source in + a separately defined class. + +<div class="code"> +<pre>[TestFixture] +public class MyTests +{ + [Test,TestCaseSource(typeof(MyFactoryClass),"TestCases")] + public int DivideTest(int n, int d) + { + return n/d; + } + + ... +} + +public class MyFactoryClass +{ + public static IEnumerable TestCases + { + get + { + yield return new TestCaseData( 12, 3 ).Returns( 4 ); + yield return new TestCaseData( 12, 2 ).Returns( 6 ); + yield return new TestCaseData( 12, 4 ).Returns( 3 ); + yield return new TestCaseData( 0, 0 ) + .Throws(typeof(DivideByZeroException)) + .SetName("DivideByZero") + .SetDescription("An exception is expected"); + } + } +} +</div> + +<p>This example uses the fluent interface supported by <b>TestCaseData</b> +to make the program more readable. The last yield statement above is equivalent to + +<div class="code"><pre> + TestCaseData data = new TestCaseData(0,0); + data.ExpectedException = typeof(DivideByZeroException; + data.TestName = "DivideByZero"; + data.Description = "An exception is expected"; + yield return data; +</pre> +</div> + +<p><b>TestCaseData</b> supports the following properties +and methods, which may be appended to an instance in any order. + +<p> +<dl> + <dt><b>.Returns</b> + <dd>The expected result to be returned from the method, which must have + a compatible return type. + <dt><b>.SetCategory(string)</b> + <dd>Applies a category to the test + <dt><b>.SetProperty(string, string)</b> + <dt><b>.SetProperty(string, int)</b> + <dt><b>.SetProperty(string, double)</b> + <dd>Applies a named property and value to the test + <dt><b>.SetDescription(string)</b> + <dd>Sets the description property of the test + <dt><b>.SetName(string)</b> + <dd>Provides a name for the test. If not specified, a name is generated based on + the method name and the arguments provided + <dt><b>.Throws(Type)</b> + <dt><b>.Throws(string)</b> + <dd>Specifies a the Type or FullName of an exception that should be thrown by this invocation + <dt><b>.Ignore()</b> + <dd>Causes the test case to be ignored. + <dt><b>.Ignore(string)</b> + <dd>Causes the test case to be ignored with a reason specified. +</dl> + +<h3>Order of Execution</h3> + +<p>In NUnit 2.5, individual test cases are sorted alphabetically and executed in + that order. With NUnit 2.5.1, the individual cases are not sorted, but are + executed in the order in which NUnit discovers them. This order does <b>not</b> + follow the lexical order of the attributes and will often vary between different + compilers or different versions of the CLR. + +<p>As a result, when <b>TestCaseSourceAttribute</b> appears multiple times on a + method or when other data-providing attributes are used in combination with + <b>TestCaseSourceAttribute</b>, the order of the test cases is undefined. + +<p>However, when a single <b>TestCaseSourceAttribute</b> is used by itself, + the order of the tests follows exactly the order in which the test cases + are returned from the source. + +<h3>Note on Object Construction</h3> + +<p>NUnit locates the test cases at the time the tests are loaded, creates +instances of each class with non-static sources and builds a list of +tests to be executed. Each source object is only created once at this +time and is destroyed after all tests are loaded. + +<p>If the data source is in the test fixture itself, the object is created +using the appropriate constructor for the fixture parameters provided on +the <b>TestFixtureAttribute</b> or +the default constructor if no parameters were specified. Since this object +is destroyed before the tests are run, no communication is possible between +these two phases - or between different runs - except through the parameters +themselves. + + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li id="current"><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testDecorators.html b/tools/NUnit/doc/testDecorators.html new file mode 100644 index 0000000..e599364 --- /dev/null +++ b/tools/NUnit/doc/testDecorators.html @@ -0,0 +1,112 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestDecorators</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>TestDecorators (NUnit 2.4)</h3> + +<h4>Purpose</h4> +<p>TestDecorators are able to modify a test after it has been constructed. + +<h4>Extension Point</h4> +<p>Addins use the host to access this extension point by name: + +<pre> + IExtensionPoint testDecorators = host.GetExtensionPoint( "TestDecorators" );</pre> + +<h4>Interface</h4> +<p>The extension object passed to Install must implement the ITestDecorator interface: + +<pre> + public interface ITestDecorator + { + Test Decorate( Test test, MemberInfo member ); + } +</pre> + +<p>The Decorate method may do several things, depending on what it needs +to accomplish: +<ol> + <li>Return test unmodified + <li>Modify properties of the test object and return it + <li>Replace test with another object, either discarding the + original or aggregating it in the new test. +</ol> + +<p>Depending on what the decorator does, it may need to run +ahead of other decorators or after them. Decorators should +be installed using the Install method overload that takes +a priority. The priorities range from 1 to 9 and decorators +with lower priority values are installed first. The following +standard values are defined for use if desired: +<ul> +<li>DecoratorPriority.Default = 0 +<li>DecoratorPriority.First = 1 +<li>DecoratorPriority.Normal = 5 +<li>DecoratorPriority.Last = 9 +</ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li id="current"><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testFixture.html b/tools/NUnit/doc/testFixture.html new file mode 100644 index 0000000..04d44cf --- /dev/null +++ b/tools/NUnit/doc/testFixture.html @@ -0,0 +1,413 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestFixture</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>TestFixtureAttribute (NUnit 2.0 / 2.5)</h3> + +<p>This is the attribute that marks a class that contains tests and, optionally, + setup or teardown methods. NUnit 2.5 introduces parameterized and generic + test fixtures - see below.</p> + +<p>Most restrictions on a class that is used as a test fixture have now been + eliminated. As of NUnit 2.5.3, a test fixture class: + <ul> + <li>May be public, protected, private or internal. + <li>May be a static class in .NET 2.0 or later. + <li>May be generic, so long as any type parameters are provided or + can be inferred from the actual arguments. + <li>May not be abstract - although the attribute may be applied to an + abstract class intended to serve as a base class for test fixtures. + <li>If no arguments are provided with the TestFixtureAttribute, the class + must have a default constructor. + <li>If arguments are provided, they must match one of the constructors. + </ul> +</p> + +<p>If any of these restrictions are violated, the class is not runnable + as a test and will display as an error.</p> + +<p>It is advisable that the constructor not have any side effects, + since NUnit may construct the object multiple times in the course of a session.</li> + +<p>Beginning with NUnit 2.5, the <b>TestFixture</b> attribute is optional + for non-parameterized, non-generic fixtures. So long as the class contains + at least one method marked with the <b>Test</b>, <b>TestCase</b> or + <b>TestCaseSource</b> attribute, it will be treated as a test fixture. + +<h4>Example:</h4> + +<div class="code"> + +<div class="langFilter"> + <a href="javascript:Show('DD1')" onmouseover="Show('DD1')"><img src="img/langFilter.gif" width="14" height="14" alt="Language Filter"></a> + <div id="DD1" class="dropdown" style="display: none;" onclick="Hide('DD1')"> + <a href="javascript:ShowCS()">C#</a><br> + <a href="javascript:ShowVB()">VB</a><br> + <a href="javascript:ShowMC()">C++</a><br> + <a href="javascript:ShowJS()">J#</a><br> + </div> +</div> + +<pre class="cs">namespace NUnit.Tests +{ + using System; + using NUnit.Framework; + + [TestFixture] + public class SuccessTests + { + // ... + } +} +</pre> + +<pre class="vb">Imports System +Imports Nunit.Framework + +Namespace Nunit.Tests + + <TestFixture()> Public Class SuccessTests + ' ... + End Class +End Namespace +</pre> + +<pre class="mc">#using <Nunit.Framework.dll> +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitTests +{ + [TestFixture] + public __gc class SuccessTests + { + // ... + }; +} + +#include "cppsample.h" + +namespace NUnitTests { + // ... +} +</pre> + +<pre class="js">package NUnit.Tests; + +import System.*; +import NUnit.Framework.TestFixture; + + +/** @attribute NUnit.Framework.TestFixture() */ +public class SuccessTests +{ + // ... +} +</pre> + +</div> + +<h3>Inheritance</h3> + +<p>The <b>TestFixtureAttribute</b> may be applied to a base class and is +inherited by any derived classes. This includes any abstract base class, +so the well-known Abstract Fixture pattern may be implemented if desired. + +<p>In order to facilitate use of generic and/or parameterized classes, +where the derived class may require a different number of arguments (or +type arguments) from the base class, any <b>TestFixture</b> attribute on a +derived class causes those on the base classes to be ignored. This allows +use of code like the following: + +<div class="code"> +<pre>[TestFixture] +public class AbstractFixtureBase +{ + ... +} + +[TestFixture(typeof(string))] +public class DerivedFixture<T> : AbstractFixtureBase +{ + ... +} +</pre> +</div> + +<h3>Parameterized Test Fixtures (NUnit 2.5)</h3> + +<p>Beginning with NUnit 2.5, test fixtures may take constructor arguments. + Argument values are specified as arguments to the <b>TestFixture</b> + attribute. NUnit will construct a separate instance of the fixture + for each set of arguments. + +<p>Individual fixture instances in a set of parameterized fixtures may be ignored. + Set the <b>Ignore</b> named parameter of the attribute to true or set + <b>IgnoreReason</b> to a non-empty string. + +<h4>Example</h4> + +<p>The following test fixture would be instantiated by NUnit three times, + passing in each set of arguments to the appropriate constructor. Note + that there are three different constructors, matching the data types + provided as arguments. + +<div class="code"><pre> +[TestFixture("hello", "hello", "goodbye")] +[TestFixture("zip", "zip")] +[TestFixture(42, 42, 99)] +public class ParameterizedTestFixture +{ + private string eq1; + private string eq2; + private string neq; + + public ParameterizedTestFixture(string eq1, string eq2, string neq) + { + this.eq1 = eq1; + this.eq2 = eq2; + this.neq = neq; + } + + public ParameterizedTestFixture(string eq1, string eq2) + : this(eq1, eq2, null) { } + + public ParameterizedTestFixture(int eq1, int eq2, int neq) + { + this.eq1 = eq1.ToString(); + this.eq2 = eq2.ToString(); + this.neq = neq.ToString(); + } + + [Test] + public void TestEquality() + { + Assert.AreEqual(eq1, eq2); + if (eq1 != null && eq2 != null) + Assert.AreEqual(eq1.GetHashCode(), eq2.GetHashCode()); + } + + [Test] + public void TestInequality() + { + Assert.AreNotEqual(eq1, neq); + if (eq1 != null && neq != null) + Assert.AreNotEqual(eq1.GetHashCode(), neq.GetHashCode()); + } +} +</pre></div> + +<h3>Generic Test Fixtures (NUnit 2.5)</h3> + +<p>Beginning with NUnit 2.5, you may also use a generic class as a test fixture. + In order for NUnit to instantiate the fixture, you must either specify the + types to be used as arguments to <b>TestFixtureAttribute</b> or use the + named parameter <b>TypeArgs=</b> to specify them. NUnit will construct a + separate instance of the fixture for each <b>TestFixtureAttribute</b> + you provide. + +<h4>Example</h4> + +<p>The following test fixture would be instantiated by NUnit twice, + once using an ArrayList and once using a List<int>. + +<div class="code"><pre> +[TestFixture(typeof(ArrayList))] +[TestFixture(typeof(List<int>))] +public class IList_Tests<TList> where TList : IList, new() +{ + private IList list; + + [SetUp] + public void CreateList() + { + this.list = new TList(); + } + + [Test] + public void CanAddToList() + { + list.Add(1); list.Add(2); list.Add(3); + Assert.AreEqual(3, list.Count); + } +}</pre></div> + +<h3>Generic Test Fixtures with Parameters (NUnit 2.5)</h3> + +<p>If a Generic fixture, uses constructor arguments, there are three + approaches to telling NUnit which arguments are type parameters + and which are normal constructor parameters. + <ol> + <li>Specify both sets of parameters as arguments to the <b>TestFixtureAttribute</b>. + Leading <b>System.Type</b> arguments are used as type parameters, while + any remaining arguments are used to construct the instance. In the + following example, this leads to some obvious duplication... + +<div class="code"><pre> +[TestFixture(typeof(double), typeof(int), 100.0, 42)] +[TestFixture(typeof(int) typeof(double), 42, 100.0)] +public class SpecifyBothSetsOfArgs<T1, T2> +{ + T1 t1; + T2 t2; + + public SpecifyBothSetsOfArgs(T1 t1, T2 t2) + { + this.t1 = t1; + this.t2 = t2; + } + + [TestCase(5, 7)] + public void TestMyArgTypes(T1 t1, T2 t2) + { + Assert.That(t1, Is.TypeOf<T1>()); + Assert.That(t2, Is.TypeOf<T2>()); + } +}</pre></div> + + <li>Specify normal parameters as arguments to <b>TestFixtureAttribute</b> + and use the named parameter <b>TypeArgs=</b> to specify the type + arguments. Again, for this example, the type info is duplicated, but + it is at least more cleanly separated from the normal arguments... + +<div class="code" style="width: 40em"><pre> +[TestFixture(100.0, 42, TypeArgs=new Type[] {typeof(double), typeof(int) } )] +[TestFixture(42, 100.0, TypeArgs=new Type[] {typeof(int), typeof(double) } )] +public class SpecifyTypeArgsSeparately<T1, T2> +{ + T1 t1; + T2 t2; + + public SpecifyTypeArgsSeparately(T1 t1, T2 t2) + { + this.t1 = t1; + this.t2 = t2; + } + + [TestCase(5, 7)] + public void TestMyArgTypes(T1 t1, T2 t2) + { + Assert.That(t1, Is.TypeOf<T1>()); + Assert.That(t2, Is.TypeOf<T2>()); + } +}</pre></div> + + <li>In some cases, when the constructor makes use of all the type parameters + NUnit may simply be able to deduce them from the arguments provided. + That's the case here and the following is the preferred way to + write this example... + +<div class="code"><pre> +[TestFixture(100.0, 42)] +[TestFixture(42, 100.0)] +public class DeduceTypeArgsFromArgs<T1, T2> +{ + T1 t1; + T2 t2; + + public DeduceTypeArgsFromArgs(T1 t1, T2 t2) + { + this.t1 = t1; + this.t2 = t2; + } + + [TestCase(5, 7)] + public void TestMyArgTypes(T1 t1, T2 t2) + { + Assert.That(t1, Is.TypeOf<T1>()); + Assert.That(t2, Is.TypeOf<T2>()); + } +}</pre></div> + </ol> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li id="current"><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testProperties.html b/tools/NUnit/doc/testProperties.html new file mode 100644 index 0000000..b289fd9 --- /dev/null +++ b/tools/NUnit/doc/testProperties.html @@ -0,0 +1,86 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestProperties</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Test Properties Dialog</h2> + +<p>The test properties dialog is displayed using either the View | Properties menu item on the main +menu or the Properties item on the context menu. It shows information about the test and – if it +has been run – about the results. The dialog contains a “pin” button in the upper right corner, +which causes it to remain open as the user clicks on different tests.</p> + +<div class="screenshot-left"> + <img src="img/testProperties.jpg"></div> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<ul> +<li><a href="guiCommandLine.html">Command-Line</a></li> +<li><a href="mainMenu.html">Main Menu</a></li> +<li><a href="contextMenu.html">Context Menu</a></li> +<li><a href="settingsDialog.html">Settings Dialog</a></li> +<li><a href="addinsDialog.html">Addins Dialog</a></li> +<li id="current"><a href="testProperties.html">Test Properties</a></li> +<li><a href="configEditor.html">Configuration Editor</a></li> +<li><a href="projectEditor.html">Project Editor</a></li> +</ul> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testcaseBuilders.html b/tools/NUnit/doc/testcaseBuilders.html new file mode 100644 index 0000000..10d933a --- /dev/null +++ b/tools/NUnit/doc/testcaseBuilders.html @@ -0,0 +1,112 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestcaseBuilders</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>TestCaseBuilders (NUnit 2.4)</h3> + +<h4>Purpose</h4> +<p>TestCaseBuilders create Tests based on a MethodInfo. NUnit uses several +TestCaseBuilders internally to create various kinds of TestMethods. + +<h4>Extension Point</h4> +Addins use the host to access this extension point by name: + +<pre> + IExtensionPoint testCaseBuilders = host.GetExtensionPoint( "TestCaseBuilders" );</pre> + +<h4>Interfaces</h4> +<p>The extension object passed to Install must implement either the ITestCaseBuilder +or the ITestCaseBuilder2 interface: + +<pre> + public interface ITestCaseBuilder + { + bool CanBuildFrom( MethodInfo method ); + Test BuildFrom( MethodInfo method ); + } + + public interface ITestCaseBuilder2 : ITestCaseBuilder + { + bool CanBuildFrom( MethodInfo method, Test suite ); + Test BuildFrom( MethodInfo method, Test suite ); + } +</pre> + +<p>NUnit will call ITestCaseBuilder2 if it is available. Otherwise +ITestCaseBuilder will be used. + +<p>The CanBuildFrom method should return true if the addin can build +a test from the MethodInfo provided. Some TestCaseBuilder addins are only +intended to apply to methods within a specific type of fixture. The +suite argument of the ITestCaseBuilder2 interface may be used to make +this determination. + +<p>The BuildFrom method should return a test constructed over the MethodInfo +provided as an argument or null if the method cannot be used. + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li id="current"><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/testcaseProviders.html b/tools/NUnit/doc/testcaseProviders.html new file mode 100644 index 0000000..60c8cda --- /dev/null +++ b/tools/NUnit/doc/testcaseProviders.html @@ -0,0 +1,140 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TestcaseProviders</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>TestCaseProviders (NUnit 2.5)</h3> + +<h4>Purpose</h4> +<p>TestCaseProviders are used with parameterized tests to provide the +specific test cases that will be used in calling the test. + +<h4>Extension Point</h4> +<p>Addins use the host to access this extension point by name: + +<pre> + IExtensionPoint listeners = host.GetExtensionPoint( "ParameterProviders" );</pre> + +<h4>Interface</h4> +<p>The extension object passed to Install must implement either the + <b>ITestCaseProvider</b> or the <b>ITestCaseProvider2</b> interface: + +<pre> + public interface ITestCaseProvider + { + bool HasTestCasesFor( MethodInfo method ); + IEnumerable GetTestCasesFor( MethodInfo method ); + } + + public interface ITestCaseProvider2 : ITestCaseProvider + { + bool HasTestCasesFor( MethodInfo method, Test suite ); + IEnumerable GetTestCasesFor( MethodInfo method, Test suite ); + } +</pre> + +<p>NUnit will call <b>ITestCaseProvider2</b> if it is available. Otherwise + <b>ITestCaseProvider</b> will be used. + +<p><b>HasTestCasesFor</b> should return true if the provider is able to supply test cases + for the specified method. If a provider only wants to be used on certain types + of tests, it can examine the provided MethodInfo and the suite for which the + test is being constructed and return true or false based on what it finds. + +<p>The GetParametersFor method should return a list of individual test cases. + Each test case may be expressed as a ParameterSet, as an array of arguments + or as a custom object containing one or more of the following properties: + + <ul> + <li>Arguments + <li>RunState + <li>NotRunReason + <li>ExpectedExceptionType + <li>ExpectedExceptionName + <li>ExpectedExceptionMessage + <li>Result + <li>Description + <li>TestName + </ul> + +<p>The ParameterSet class provides all these properties and may be used +to avoid the overhead of reflecting on the properties. + +<h4>Notes:</h4> + +<ol> +<li>Most providers will delegate one of the interface implementations + to the other if they implement both. +<li>TestCaseProviders that use data from the fixture class should use + <b>ITestCaseProvider2</b> interface so that they are able to access any + arguments supplied for constructing the fixture object. +<li>Providers that acquire data from outside the fixture will usually + be able to work with <b>ITestCaseProvider</b> alone. +<li>The <b>ITestCaseProvider2</b> interface was added in the NUnit 2.5.1 release. +</ol> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<ul> +<li><a href="customConstraints.html">Custom Constraints</a></li> +<li><a href="nunitAddins.html">NUnit Addins</a></li> +<ul> +<li><a href="suiteBuilders.html">SuiteBuilders</a></li> +<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li> +<li><a href="testDecorators.html">TestDecorators</a></li> +<li id="current"><a href="testcaseProviders.html">TestcaseProviders</a></li> +<li><a href="datapointProviders.html">DatapointProviders</a></li> +<li><a href="eventListeners.html">EventListeners</a></li> +</ul> +<li><a href="extensionTips.html">Tips for Extenders</a></li> +</ul> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/theory.html b/tools/NUnit/doc/theory.html new file mode 100644 index 0000000..831c5a6 --- /dev/null +++ b/tools/NUnit/doc/theory.html @@ -0,0 +1,191 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Theory</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>TheoryAttribute (NUnit 2.5) (Experimental)</h3> + +<p>A Theory is a special type of test, used to verify a general + statement about the system under development. Normal tests are + <em>example-based</em>. That is, the developer supplies one or + more examples of inputs and expected outputs either within the + code of the test or - in the case of + <a href="parameterizedTests.html">Parameterized Tests</a> + - as arguments to the test method. A theory, on the other hand, + makes a general statement that all of its assertions will pass + for all arguments satisfying certain assumptions. + +<p>Theories are implemented in NUnit + as methods within a <b>TestFixture</b>, which are annotated + with the <b>TheoryAttribute</b>. Theory methods must always have + arguments and therefore appears quite similar to + <a href="parameterizedTests.html">Parameterized Tests</a> at first glance. However, a Theory incorporates additional data sources + for its arguments and allows special processing for assumptions + about that data. The key difference, though, is that theories + make general statements and are more than just a set of examples. + +<h4>Data for Theories</h4> + +<p>The primary source of data for a <b>Theory</b> is the + <a href="datapoint.html"><b>Datapoint</b> or <b>Datapoints</b> attribute</a>. + NUnit will use any fields of the required types, which are annotated + with one of these attributes, to provide data for each parameter + of the Theory. NUnit assembles the values for individual arguments + combinatorially to provide test cases for the theory. + +<p>In addition to the Datapoint and Datapoints attributes, it + is possible to use any of the approaches for supplying data + that are recognized on normal parameterized tests. We suggest + that this capability not be overused, since it runs counter + to the distinction between a test based on examples and a + theory. However, it may be useful in order to guarantee that + a specific test case is included. + +<h4>Assumptions</h4> + +<p>The theory itself is responsible for ensuring that all data supplied + meets its assumptions. It does this by use of the + <b>Assume.That(...)</b> construct, which works just like + <b>Assert.That(...)</b> but does not cause a failure. If + the assumption is not satisfied for a particular test case, that case + returns an Inconclusive result, rather than a Success or Failure. + +<p>The overall result of executing a Theory over a set of test cases is + determined as follows: + + <ul> + <li>If the assumptions are violated for <b>all</b> test cases, then the + Theory itself is marked as a failure. + + <li>If any Assertion fails, the Theory itself fails. + + <li>If at least <b>some</b> cases pass the stated assumptions, and + there are <b>no</b> assertion failures or exceptions, then the + Theory passes. + </ul> + +<h4>Example:</h4> + +<p>In the following example, the theory SquareRootDefinition + verifies that the implementation of square root satisies + the following definition: + +<p style="margin: 2em"><i> +"Given a non-negative number, the square root of that number + is always non-negative and, when multiplied by itself, gives + the original number."</i> + +<div class="code" style="width: 36em"> +<pre> +public class SqrtTests +{ + [Datapoints] + public double[] values = new double[] { 0.0, 1.0, -1.0, 42.0 }; + + [Theory] + public void SquareRootDefinition(double num) + { + Assume.That(num >= 0.0); + + double sqrt = Math.Sqrt(num); + + Assert.That(sqrt >= 0.0); + Assert.That(sqrt * sqrt, Is.EqualTo(num).Within(0.000001)); + } +} +</pre> +</div> + +<h4>See also...</h4> + +<ul> +<li><a href="datapoint.html">Datapoint(s)Attribute</a><li><a href="parameterizedTests.html">Parameterized Tests</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li id="current"><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/throwsConstraint.html b/tools/NUnit/doc/throwsConstraint.html new file mode 100644 index 0000000..52cc0f6 --- /dev/null +++ b/tools/NUnit/doc/throwsConstraint.html @@ -0,0 +1,156 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ThrowsConstraint</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Throws Constraint (NUnit 2.5)</h2> + +<p><b>ThrowsConstraint</b> is used to test that some code, represented as a delegate, +throws a particular exception. It may be used alone, to merely test the type +of constraint, or with an additional constraint to be applied to the exception +specified as an argument. + +p>The related <b>ThrowsNothingConstraint</b> simply asserts that the delegate +does not throw an exception. + +<h4>Constructors</h4> +<div class="code"><pre> +ThrowsConstraint(Type expectedType) +ThrowsConstraint<T>() +ThrowsConstraint(Type expectedType, Constraint constraint) +ThrowsConstraint<T>(Constraint constraint) +ThrowsNothingConstraint() +</pre></div> + +<h4>Syntax</h4> +<div class="code"><pre> +Throws.Exception +Throws.TargetInvocationException +Throws.ArgumentException +Throws.InvalidOperationException +Throws.TypeOf(Type expectedType) +Throws.TypeOf<T>() +Throws.InstanceOf(Type expectedType) +Throws.InstanceOf<T>() +Throws.Nothing +Throws.InnerException +</pre></div> + +<h4>Examples of Use</h4> +<div class="code"><pre> +// .NET 1.1 +Assert.That( new TestDelegate(SomeMethod), + Throws.TypeOf(typeof(ArgumentException))); +Assert.That( new TestDelegate(SomeMethod), + Throws.Exception.TypeOf(typeof(ArgumentException))); +Assert.That( new TestDelegate(SomeMethod), + Throws.TypeOf(typeof(ArgumentException)) + .With.Property("Parameter").EqualTo("myParam")); +Assert.That( new TestDelegate(SomeMethod), + Throws.ArgumentException ); +Assert.That( new TestDelegate(SomeMethod), + Throws.TargetInvocationException + .With.InnerException.TypeOf(ArgumentException)); + +// .NET 2.0 +Assert.That( SomeMethod, + Throws.TypeOf<ArgumentException>()); +Assert.That( SomeMethod, + Throws.Exception.TypeOf<ArgumentException>()); +Assert.That( SomeMethod, + Throws.TypeOf<ArgumentException>() + .With.Property("Parameter").EqualTo("myParam")); +Assert.That( SomeMethod, Throws.ArgumentException ); +Assert.That( SomeMethod, + Throws.TargetInvocationException + .With.InnerException.TypeOf<ArgumentException>()); +</pre></div> + +<h4>Notes</h4> +<ol> +<li><b>Throws.Exception</b> may be followed by further constraints, + which are applied to the exception itself as shown in the last two + examples above. It may also be used alone to verify that some + exception has been thrown, without regard to type. This is + not a recommended practice since you should normally know + what exception you are expecting. +<li><b>Throws.TypeOf</b> and <b>Throws.InstanceOf</b> are provided + as a shorter syntax for this common test. They work exactly like + the corresponding forms following <b>Throws.Exception</b>. +<li><b>Throws.TargetInvocationException/b>, <b>Throws.ArgumentException</b> + and <b>Throws.InvalidOperationException</b> provide a shortened form + for some common exceptions. +<li>Used alone, <b>Throws.InnerException</b> simply tests the InnerException + value of the thrown exception. More commonly, it will be used in + combination with a test for the type of the outer exception as shown + in the examples above. +</ol> + + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li id="current"><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/timeout.html b/tools/NUnit/doc/timeout.html new file mode 100644 index 0000000..2d0cb86 --- /dev/null +++ b/tools/NUnit/doc/timeout.html @@ -0,0 +1,123 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Timeout</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>TimeoutAttribute (NUnit 2.5)</h3> + +<p>The <b>TimeoutAttribute</b> is used to specify a timeout value in milliseconds + for a test case. If the test case runs longer than the time specified it + is immediately cancelled and reported as a failure, with a message + indicating that the timeout was exceeded. + +<p>The attribute may also be specified on a fixture or assembly, in which + case it indicates the default timeout for any subordinate test cases. + +<h4>Example</h4> + +<div class="code"><pre> +[Test, Timeout(2000)] +public void PotentiallyLongRunningTest() +{ + ... +} +</pre></div> + +<h4>Notes</h4> +<ol> +<li>Beginning with NUnit 2.5.5, timeouts are suppressed when running under a debugger.</li> +</ol> + +<h4>See Also...</h4> +<ul> +<li><a href="maxtime.html">MaxtimeAttribute</a></ul> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li id="current"><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/typeAsserts.html b/tools/NUnit/doc/typeAsserts.html new file mode 100644 index 0000000..d592f59 --- /dev/null +++ b/tools/NUnit/doc/typeAsserts.html @@ -0,0 +1,129 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TypeAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Type Asserts (NUnit 2.2.3 / 2.5)</h2> + +<p>These methods allow us to make assertions about the type of an object.</p> + +<div class="code" style="width: 36em" ><pre> + +Assert.IsInstanceOfType( Type expected, object actual ); +Assert.IsInstanceOfType( Type expected, object actual, + string message ); +Assert.IsInstanceOfType( Type expected, object actual, + string message, params object[] parms ); + +Assert.IsNotInstanceOfType( Type expected, object actual ); +Assert.IsNotInstanceOfType( Type expected, object actual, + string message ); +Assert.IsNotInstanceOfType( Type expected, object actual, + string message, params object[] parms ); + +Assert.IsAssignableFrom( Type expected, object actual ); +Assert.IsAssignableFrom( Type expected, object actual, + string message ); +Assert.IsAssignableFrom( Type expected, object actual, + string message, params object[] parms ); + +Assert.IsNotAssignableFrom( Type expected, object actual ); +Assert.IsNotAssignableFrom( Type expected, object actual, + string message ); +Assert.IsNotAssignableFrom( Type expected, object actual, + string message, params object[] parms ); + +</pre></div> + +Beginning with NUnit 2.5, generic equivalents are available +in .NET 2.0 NUnit packages. + +<div class="code" style="width: 36em" ><pre> + +Assert.IsInstanceOf<T>( object actual ); +Assert.IsInstanceOf<T>( object actual, string message ); +Assert.IsInstanceOf<T>( object actual, + string message, params object[] parms ); + +Assert.IsNotInstanceOf<T>( object actual ); +Assert.IsNotInstanceOf<T>( object actual, string message ); +Assert.IsNotInstanceOf<T>( object actual, + string message, params object[] parms ); + +Assert.IsAssignableFrom<T>( object actual ); +Assert.IsAssignableFrom<T>( object actual, string message ); +Assert.IsAssignableFrom<T>( object actual, + string message, params object[] parms ); + +Assert.IsNotAssignableFrom<T>( object actual ); +Assert.IsNotAssignableFrom<T>( object actual, string message ); +Assert.IsNotAssignableFrom<T>( object actual, + string message, params object[] parms ); + +</pre></div> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li id="current"><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/typeConstraints.html b/tools/NUnit/doc/typeConstraints.html new file mode 100644 index 0000000..c484471 --- /dev/null +++ b/tools/NUnit/doc/typeConstraints.html @@ -0,0 +1,101 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - TypeConstraints</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Type Constraints (NUnit 2.4)</h2> + +<p>Type constraints perform tests that are specific to Types. +The following type constraints are provided: + +<table class="constraints"> +<tr><th>Syntax Helper</th><th>Constructor</th><th>Operation</th></tr> +<tr><td>Is.TypeOf( Type )</td><td>ExactTypeConstraint( Type )</td></td><td>tests that an object is an exact Type</td></tr> +<tr><td>Is.InstanceOfType( Type )</td><td>InstanceOfTypeConstraint( Type )</td></td><td>tests that an object is an instance of a Type</td></tr> +<tr><td>Is.AssignableFrom( Type )</td><td>AssignableFromConstraint( Type )</td></td><td>tests that one type is assignable from another</td></tr> +</table> + +<h4>Examples of Use</h4> + +<div class="code"><pre> +Assert.That("Hello", Is.TypeOf(typeof(string))); +Assert.That("Hello", Is.Not.TypeOf(typeof(int))); + +Assert.That("Hello", Is.InstanceOfType(typeof(string))); +Assert.That(5, Is.Not.InstanceOfType(typeof(string))); + +Assert.That( "Hello", Is.AssignableFrom(typeof(string))); +Assert.That( 5, Is.Not.AssignableFrom(typeof(string))); + +// Using inheritance +Expect( 5, Not.InstanceOfType(typeof(string))); +Expect( "Hello", AssignableFrom(typeOf(string))); +</pre></div> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<ul> +<li><a href="equalConstraint.html">Equal Constraint</a></li> +<li><a href="sameasConstraint.html">SameAs Constraint</a></li> +<li><a href="conditionConstraints.html">Condition Constraints</a></li> +<li><a href="comparisonConstraints.html">Comparison Constrants</a></li> +<li><a href="pathConstraints.html">Path Constraints</a></li> +<li id="current"><a href="typeConstraints.html">Type Constraints</a></li> +<li><a href="stringConstraints.html">String Constraints</a></li> +<li><a href="collectionConstraints.html">Collection Constraints</a></li> +<li><a href="propertyConstraint.html">Property Constraint</a></li> +<li><a href="throwsConstraint.html">Throws Constraint</a></li> +<li><a href="compoundConstraints.html">Compound Constraints</a></li> +<li><a href="delayedConstraint.html">Delayed Constraint</a></li> +<li><a href="listMapper.html">List Mapper</a></li> +</ul> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/upgrade.html b/tools/NUnit/doc/upgrade.html new file mode 100644 index 0000000..e4efb32 --- /dev/null +++ b/tools/NUnit/doc/upgrade.html @@ -0,0 +1,98 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Upgrade</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>From NUnit 2.x</h2> + +<p>Beginning with version 2.2.1, old style test cases ("Test....") are no longer +recognized by default. We recommend that you convert such test cases to use the +<a href="test.html">TestAttribute</a>. Alternatively, you may +specify a setting in the test config file to allow use of old style test cases by +default.</p> + +<p>Beginning with NUnit 2.2.2, NUnit is able to run tests Built with older +versions of NUnit 2.x without recompilation. Note that you must have an +available copy of the nunit.framework assembly from the older version +in order for your tests to load correctly. + +<h2>From NUnit 1.x</h2> + +<p>NUnit 2.5 no longer supports inheriting from TestCase when defining a test. + If you need to run such tests, you may continue to do so using the + a 2.4.x or earlier version of the nunit.framework assembly. Of course, you + will not be able to use new features introduced in 2.5 if you follow this + course. + +<p>For a complete conversion to 2.5, you should modify and recompile your tests + using the new version of NUnit. + +<h3>Suite property</h3> +<p>The NUnit 1.x Suite property will not be found by the new program. These must be + changed to the "Suite" attribute for the test runners to find them. + Another alternative is that these suites are no longer needed due to the + automatic capability that is built in to the new version.</p> + +<h3>AssertionFailedError</h3> +<p>If you have written code expecting the exception AssertionFailedError, this must + be changed to AssertionException.</p> + + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<ul> +<li><a href="quickStart.html">Quick Start</a></li> +<li><a href="installation.html">Installation</a></li> +<ul> +<li id="current"><a href="upgrade.html">Upgrading</a></li> +</ul> +</ul> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/utilityAsserts.html b/tools/NUnit/doc/utilityAsserts.html new file mode 100644 index 0000000..4cb64f4 --- /dev/null +++ b/tools/NUnit/doc/utilityAsserts.html @@ -0,0 +1,125 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - UtilityAsserts</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Utility Methods</h2> +<p>Four utility methods, <b>Pass()</b>, <b>Fail()</b>, <b>Ignore()</b> and <b>Inconclusive()</b> are provided + in order to allow more direct control of the test process:</p> +<div class="code" style="width: 36em"><pre> +Assert.Pass(); +Assert.Pass( string message ); +Assert.Pass( string message, object[] parms ); + +Assert.Fail(); +Assert.Fail( string message ); +Assert.Fail( string message, object[] parms ); + +Assert.Ignore(); +Assert.Ignore( string message ); +Assert.Ignore( string message, object[] parms ); + +Assert.Inconclusive(); +Assert.Inconclusive( string message ); +Assert.Inconclusive( string message, object[] parms );</pre> +</div> +<p>The <b>Assert.Pass</b> method allows you to immediately end the test, recording + it as successful. Since it causes an exception to be thrown, it is more + efficient to simply allow the test to return. However, Assert.Pass allows + you to record a message in the test result and may also make the test + easier to read in some situations. Additionally, like the other methods + on this page, it can be invoked from a nested method call with the + result of immediately terminating test execution.</p> +<p>The <b>Assert.Fail</b> method provides you with the ability to generate a failure based + on tests that are not encapsulated by the other methods. It is also useful in + developing your own project-specific assertions.</p> +<p>Here's an example of its use to create a private assertion that tests whether a + string contains an expected value.</p> +<div class="code" style="width: 36em"> + <pre>public void AssertStringContains( string expected, string actual ) +{ + AssertStringContains( expected, actual, string.Empty ); +} + +public void AssertStringContains( string expected, string actual, + string message ) +{ + if ( actual.IndexOf( expected ) < 0 ) + Assert.Fail( message ); +}</pre> +</div> +<p>The <b>Assert.Ignore</b> method provides you with the ability to dynamically cause a + test or suite to be ignored at runtime. It may be called in a test, setup or + fixture setup method. We recommend that you use this only in isolated cases. + The category facility is provided for more extensive inclusion or exclusion of + tests or you may elect to simply divide tests run on different occasions into + different assemblies.</p> +<p>The <b>Assert.Inconclusive</b> method indicates that the test could not be + completed with the data available. It should be used in situations where + another run with different data might run to completion, with either a + success or failure outcome. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<ul> +<li><a href="equalityAsserts.html">Equality Asserts</a></li> +<li><a href="identityAsserts.html">Identity Asserts</a></li> +<li><a href="conditionAsserts.html">Condition Asserts</a></li> +<li><a href="comparisonAsserts.html">Comparison Asserts</a></li> +<li><a href="typeAsserts.html">Type Asserts</a></li> +<li><a href="exceptionAsserts.html">Exception Asserts</a></li> +<li id="current"><a href="utilityAsserts.html">Utility Methods</a></li> +<li><a href="stringAssert.html">String Assert</a></li> +<li><a href="collectionAssert.html">Collection Assert</a></li> +<li><a href="fileAssert.html">File Assert</a></li> +<li><a href="directoryAssert.html">Directory Assert</a></li> +</ul> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/valueSource.html b/tools/NUnit/doc/valueSource.html new file mode 100644 index 0000000..6c423c2 --- /dev/null +++ b/tools/NUnit/doc/valueSource.html @@ -0,0 +1,157 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - ValueSource</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE --> + +<h3>ValueSourceAttribute (NUnit 2.5)</h3> + +<p><b>ValueSourceAttribute</b> is used on individual parameters of a test method to +identify a named source for the argument values to be supplied. The attribute has +two public constructors. + +<div class="code"> +<pre> +ValueSourceAttribute(Type sourceType, string sourceName); +ValueSourceAttribute(string sourceName); +</pre> +</div> + +<p>If <b>sourceType</b> is specified, it represents the class that provides +the data. It must have a default constructor. + +<p>If <b>sourceType</b> is not specified, the class containing the test +method is used. NUnit will construct it using either the default constructor +or - if arguments are provided - the appropriate constructor for those +arguments. + +<p>The <b>sourceName</b>, represents the name of the source that will +provide the arguments. It should have the following characteristics: +<ul> +<li>It may be a field, a non-indexed property or a method taking no arguments. +<li>It may be either an instance or a static member. +<li>It must return an IEnumerable or a type that implements IEnumerable. +<li>The individual items returned from the enumerator must be compatible + with the type of the parameter on which the attribute appears. +</ul> + +<h3>Order of Execution</h3> + +<p>In NUnit 2.5, individual test cases are sorted alphabetically and executed in + that order. With NUnit 2.5.1, the individual cases are not sorted, but are + executed in the order in which NUnit discovers them. This order does <b>not</b> + follow the lexical order of the attributes and will often vary between different + compilers or different versions of the CLR. + +<p>As a result, when <b>ValueSourceAttribute</b> appears multiple times on a + parameter or when other data-providing attributes are used in combination with + <b>ValueSourceAttribute</b>, the order of the arguments is undefined. + +<p>However, when a single <b>ValueSourceAttribute</b> is used by itself, + the order of the arguments follows exactly the order in which the data + is returned from the source. + +<h3>Note on Object Construction</h3> + +<p>NUnit locates the test cases at the time the tests are loaded, creates +instances of each class with non-static sources and builds a list of +tests to be executed. Each source object is only created once at this +time and is destroyed after all tests are loaded. + +<p>If the data source is in the test fixture itself, the object is created +using the appropriate constructor for the fixture parameters provided on +the <b>TestFixtureAttribute</b>, or +the default constructor if no parameters were specified. Since this object +is destroyed before the tests are run, no communication is possible between +these two phases - or between different runs - except through the parameters +themselves. + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li><a href="values.html">Values</a></li> +<li id="current"><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/values.html b/tools/NUnit/doc/values.html new file mode 100644 index 0000000..d2586b9 --- /dev/null +++ b/tools/NUnit/doc/values.html @@ -0,0 +1,131 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - Values</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h3>ValuesAttribute (NUnit 2.5)</h3> + +<p>The <b>ValuesAttribute</b> is used to specify a set of values to be provided + for an individual parameter of a parameterized test method. Since + NUnit combines the data provided for each parameter into a set of + test cases, data must be provided for all parameters if it is + provided for any of them. + +<p>By default, NUnit creates test cases from all possible combinations + of the datapoints provided on parameters - the combinatorial approach. + This default may be modified by use of specific attributes on the + test method itself. + +<h4>Example</h4> + +<p>The following test will be executed six times, as follows: +<pre> + MyTest(1, "A") + MyTest(1, "B") + MyTest(2, "A") + MyTest(2, "B") + MyTest(3, "A") + MyTest(3, "B") +</pre> +<div class="code"><pre> +[Test] +public void MyTest( + [Values(1,2,3)] int x, + [Values("A","B")] string s) +{ + ... +} +</pre></div> + +<h4>See also...</h4> +<ul> +<li><a href="range.html">RangeAttribute</a><li><a href="random.html">RandomAttribute</a><li><a href="sequential.html">SequentialAttribute</a><li><a href="combinatorial.html">CombinatorialAttribute</a><li><a href="pairwise.html">PairwiseAttribute</a></ul> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<ul> +<li><a href="category.html">Category</a></li> +<li><a href="combinatorial.html">Combinatorial</a></li> +<li><a href="culture.html">Culture</a></li> +<li><a href="datapoint.html">Datapoint(s)</a></li> +<li><a href="description.html">Description</a></li> +<li><a href="exception.html">Exception</a></li> +<li><a href="explicit.html">Explicit</a></li> +<li><a href="ignore.html">Ignore</a></li> +<li><a href="maxtime.html">Maxtime</a></li> +<li><a href="pairwise.html">Pairwise</a></li> +<li><a href="platform.html">Platform</a></li> +<li><a href="property.html">Property</a></li> +<li><a href="random.html">Random</a></li> +<li><a href="range.html">Range</a></li> +<li><a href="repeat.html">Repeat</a></li> +<li><a href="requiredAddin.html">RequiredAddin</a></li> +<li><a href="requiresMTA.html">Requires MTA</a></li> +<li><a href="requiresSTA.html">Requires STA</a></li> +<li><a href="requiresThread.html">Requires Thread</a></li> +<li><a href="sequential.html">Sequential</a></li> +<li><a href="setCulture.html">SetCulture</a></li> +<li><a href="setup.html">Setup</a></li> +<li><a href="setupFixture.html">SetupFixture</a></li> +<li><a href="suite.html">Suite</a></li> +<li><a href="teardown.html">Teardown</a></li> +<li><a href="test.html">Test</a></li> +<li><a href="testCase.html">TestCase</a></li> +<li><a href="testCaseSource.html">TestCaseSource</a></li> +<li><a href="testFixture.html">TestFixture</a></li> +<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li> +<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li> +<li><a href="theory.html">Theory</a></li> +<li><a href="timeout.html">Timeout</a></li> +<li id="current"><a href="values.html">Values</a></li> +<li><a href="valueSource.html">ValueSource</a></li> +</ul> +<li><a href="runningTests.html">Running Tests</a></li> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/doc/vsSupport.html b/tools/NUnit/doc/vsSupport.html new file mode 100644 index 0000000..bb22ca4 --- /dev/null +++ b/tools/NUnit/doc/vsSupport.html @@ -0,0 +1,144 @@ +<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<!-- Standard Head Part --> +<head> +<title>NUnit - VsSupport</title> +<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> +<meta http-equiv="Content-Language" content="en-US"> +<link rel="stylesheet" type="text/css" href="nunit.css"> +<link rel="shortcut icon" href="favicon.ico"> +</head> +<!-- End Standard Head Part --> + +<body> + +<!-- Standard Header for NUnit.org --> +<div id="header"> + <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a> + <div id="nav"> + <a href="http://www.nunit.org">NUnit</a> + <a class="active" href="index.html">Documentation</a> + </div> +</div> +<!-- End of Header --> + +<div id="content"> + +<h2>Visual Studio Support</h2> + +<p>Visual Studio support in this release is a sort of “poor man’s integration.” We have implemented +a number of features while avoiding any that would require using an Addin or otherwise +interacting with the Visual Studio extensibility model.</p> + +<h3>Running From Within Visual Studio</h3> + +<p>The most convenient way to do this is to set up a custom tool entry specifying the path to +NUnit as the command. For a VS2003 C# project, you can use $(TargetPath) for the arguments and +$(TargetDir) for the initial directory. + +<p>With Visual Studio VS2005 this becomes a bit harder, because that release changed the +meaning of the 'Target' macros so they now point to the intermediate 'obj' directories rather +than the final output in one of the 'bin' directories. Here are some alternatives that +work in both versions: + +<ul> +<li><b>$(ProjectDir)$(ProjectFileName)</b> to open the VS Project rather than the assembly. + If you use this approach, be sure to rename your config file accordingly and put it + in the same directory as the VS project file. +<li><b>$(ProjectDir)bin/Debug/$(TargetName)$(TargetExt)</b> to run the assembly directly. + Note that this requires hard-coding part of the path, including the configuration. +</ul> + +<p>If you would like to debug your tests, use the Visual Studio +Debug | Processes… menu item to attach to NUnit after starting it and set breakpoints in +your test code as desired before running the tests.</p> + +<h3>Using Console Interface to Debug Applications</h3> + +<p>When the nunit-console program is run in debug mode under Visual Studio, it detects that it is +running in this mode and sends output to the Visual Studio output window. Output is formatted so +that double clicking any error or failure entries opens the appropriate test file at the location +where the failure was detected.</p> + +<h3>Opening Visual Studio Projects</h3> + +<p>When Visual Studio support is enabled, the File Open dialog displays the following supported +Visual Studio project types: C#, VB.Net, J# and C++. The project file is read and the +configurations and output assembly locations are identified. Since the project files do not contain +information about the most recently opened configuration, the output assembly for the first +configuration found (usually Debug) is loaded in the GUI. The tree shows the project as the toplevel +node with the assembly shown as its descendant.</p> + +<p>Beginning with NUnit 2.2.2, you may also open a Visual Studio project by dragging it to the gui tree control.</p> + +<p>When tests are run for a Visual studio project, they run just as if the output assembly had been +loaded with one exception. The default location for the config file is the directory containing the +project file and it’s default name is the same as the project file with an extension of .config. +For example, the following command would load the tests in the nunit.tests assembly using the +configuration file nunit.tests.dll.config located in the same directory as the dll. + <pre class="programtext"> nunit.exe nunit.tests.dll</pre> +On the other hand, the following command would load the tests using the configuration file +nunit.tests.config located in the same directory as the csproj file. + <pre class="programtext"> nunit.exe nunit.tests.csproj</pre> +The same consideration applies to running tests using the console runner.</p> + +<h3>Opening Visual Studio Solutions</h3> + +<p>When Visual Studio support is enabled, solution files may be opened as well. All the output +assemblies from contained projects of the types supported will be loaded in the tree. In the case +where all contained projects are located in the subdirectories beneath the solution, it will be +possible to load and run tests using this method directly.</p> + +<p>Beginning with NUnit 2.2.2, you may also open a Visual Studio solution by dragging it to the gui tree control.</p> + +<p>When a solution contains projects located elsewhere in the file system, it may not be possible to +run the tests – although the solution will generally load without problem. In this case, the Project +Editor should be use to modify and save the NUnit test project so that there is all referenced +assemblies are located in or beneath the application base directory.</p> + +<h3>Adding Visual Studio Projects to the Open Test Project</h3> + +<p>When Visual Studio support is enabled, the Project menu contains an active entry to add a VS +project to the loaded project. The output assembly will be added for each of the configurations +specified in the VS project.</p> + +</div> + +<!-- Submenu --> +<div id="subnav"> +<ul> +<li><a href="index.html">NUnit 2.5.5</a></li> +<ul> +<li><a href="getStarted.html">Getting Started</a></li> +<li><a href="assertions.html">Assertions</a></li> +<li><a href="constraintModel.html">Constraints</a></li> +<li><a href="attributes.html">Attributes</a></li> +<li><a href="runningTests.html">Running Tests</a></li> +<ul> +<li><a href="nunit-console.html">Console Runner</a></li> +<li><a href="nunit-gui.html">Gui Runner</a></li> +<li><a href="pnunit.html">PNUnit Runner</a></li> +<li><a href="runtimeSelection.html">Runtime Selection</a></li> +<li><a href="assemblyIsolation.html">Assembly Isolation</a></li> +<li><a href="configFiles.html">Configuration Files</a></li> +<li><a href="multiAssembly.html">Multiple Assemblies</a></li> +<li id="current"><a href="vsSupport.html">Visual Studio Support</a></li> +</ul> +<li><a href="extensibility.html">Extensibility</a></li> +<li><a href="releaseNotes.html">Release Notes</a></li> +<li><a href="samples.html">Samples</a></li> +<li><a href="license.html">License</a></li> +</ul> +</ul> +</div> +<!-- End of Submenu --> + + +<!-- Standard Footer for NUnit.org --> +<div id="footer"> + Copyright © 2009 Charlie Poole. All Rights Reserved. +</div> +<!-- End of Footer --> + +</body> +</html> diff --git a/tools/NUnit/fit-license.txt b/tools/NUnit/fit-license.txt new file mode 100644 index 0000000..af37532 --- /dev/null +++ b/tools/NUnit/fit-license.txt @@ -0,0 +1,342 @@ +
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
\ No newline at end of file diff --git a/tools/NUnit/license.txt b/tools/NUnit/license.txt new file mode 100644 index 0000000..66a5ebf --- /dev/null +++ b/tools/NUnit/license.txt @@ -0,0 +1,15 @@ +Copyright © 2002-2008 Charlie Poole +Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov +Copyright © 2000-2002 Philip A. Craig + +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required. + +Portions Copyright © 2002-2008 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig + +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. diff --git a/tools/NUnit/samples/Extensibility/Core/CoreExtensibility.sln b/tools/NUnit/samples/Extensibility/Core/CoreExtensibility.sln new file mode 100644 index 0000000..6e5ae57 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/CoreExtensibility.sln @@ -0,0 +1,53 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Minimal", "Minimal\Minimal.csproj", "{EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleFixtureExtension", "SampleFixtureExtension\SampleFixtureExtension.csproj", "{ED281A23-9579-4A70-B608-1B86DCDEB78C}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleFixtureExtensionTests", "SampleFixtureExtension\Tests\SampleFixtureExtensionTests.csproj", "{0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleSuiteExtension", "SampleSuiteExtension\SampleSuiteExtension.csproj", "{0C4269EE-3266-45DD-9062-E356C067FBEF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleSuiteExtensionTests", "SampleSuiteExtension\Tests\SampleSuiteExtensionTests.csproj", "{9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}.Debug.ActiveCfg = Debug|.NET + {EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}.Debug.Build.0 = Debug|.NET + {EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}.Release.ActiveCfg = Release|.NET + {EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}.Release.Build.0 = Release|.NET + {ED281A23-9579-4A70-B608-1B86DCDEB78C}.Debug.ActiveCfg = Debug|.NET + {ED281A23-9579-4A70-B608-1B86DCDEB78C}.Debug.Build.0 = Debug|.NET + {ED281A23-9579-4A70-B608-1B86DCDEB78C}.Release.ActiveCfg = Release|.NET + {ED281A23-9579-4A70-B608-1B86DCDEB78C}.Release.Build.0 = Release|.NET + {0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}.Debug.ActiveCfg = Debug|.NET + {0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}.Debug.Build.0 = Debug|.NET + {0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}.Release.ActiveCfg = Release|.NET + {0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}.Release.Build.0 = Release|.NET + {0C4269EE-3266-45DD-9062-E356C067FBEF}.Debug.ActiveCfg = Debug|.NET + {0C4269EE-3266-45DD-9062-E356C067FBEF}.Debug.Build.0 = Debug|.NET + {0C4269EE-3266-45DD-9062-E356C067FBEF}.Release.ActiveCfg = Release|.NET + {0C4269EE-3266-45DD-9062-E356C067FBEF}.Release.Build.0 = Release|.NET + {9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}.Debug.ActiveCfg = Debug|.NET + {9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}.Debug.Build.0 = Debug|.NET + {9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}.Release.ActiveCfg = Release|.NET + {9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.build b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.build new file mode 100644 index 0000000..f92d521 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.build @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<project name="Minimal" default="build" basedir="."> + + <include buildfile="../../../samples.common" /> + + <patternset id="source-files"> + <include name="Minimal.cs" /> + </patternset> + + <target name="packagex"> + <copy todir="${package.samples.dir}/Extensibility/Core/Minimal"> + <fileset basedir="."> + <include name="Minimal.csproj" /> + <include name="Minimal.build" /> + <include name="Readme.txt" /> + <patternset refid="source-files" /> + </fileset> + </copy> + </target> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.cs b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.cs new file mode 100644 index 0000000..17b4bdb --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.cs @@ -0,0 +1,36 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using NUnit.Core.Extensibility; + +namespace NUnit.Samples.Extensibility +{ + /// <summary> + /// This is the smallest possible Addin, which does nothing + /// but is recognized by NUnit and listed in the Addins dialog. + /// + /// The Addin class is marked by the NUnitAddin attribute and + /// implements IAddin, as required. Optional property syntax + /// is used here to override the default name of the addin and + /// to provide a description. Both are displayed by NUnit in the + /// Addin Dialog. + /// + /// The addin doesn't actually install anything, but simply + /// returns false in its Install method. + /// </summary> + [NUnitAddin(Name="Minimal Addin", Description="This Addin doesn't do anything")] + public class Minimal : IAddin + { + #region IAddin Members + public bool Install(IExtensionHost host) + { + // TODO: Add Minimal.Install implementation + return true; + } + #endregion + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.csproj b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.csproj new file mode 100644 index 0000000..f6677e1 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/Minimal/Minimal.csproj @@ -0,0 +1,89 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{EF428E5B-B3E7-4C2F-B005-98DE7D6E7CDB}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "Minimal" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "NUnit.Samples.Extensibility" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + /> + <Reference + Name = "nunit.core.interfaces" + AssemblyName = "nunit.core.interfaces" + HintPath = "..\..\..\..\solutions\vs2003\NUnitCore\interfaces\bin\Debug\nunit.core.interfaces.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "Minimal.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/AssemblyInfo.cs b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.build b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.build new file mode 100644 index 0000000..474d4aa --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.build @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<project name="SampleFixtureExtension" default="build" basedir="."> + + <include buildfile="../../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.cs" /> + <include name="SampleFixtureExtension.cs" /> + <include name="SampleFixtureExtensionAttribute.cs" /> + <include name="SampleFixtureExtensionBuilder.cs" /> + </patternset> + + <patternset id="test-files"> + <include name="AssemblyInfo.cs" /> + <include name="SampleFixtureExtensionTests.cs" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.cs b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.cs new file mode 100644 index 0000000..8359d2f --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.cs @@ -0,0 +1,44 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// SampleFixtureExtension extends NUnitTestFixture and adds a custom setup + /// before running TestFixtureSetUp and after running TestFixtureTearDown. + /// Because it inherits from NUnitTestFixture, a lot of work is done for it. + /// </summary> + class SampleFixtureExtension : NUnitTestFixture + { + public SampleFixtureExtension( Type fixtureType ) + : base( fixtureType ) + { + // NOTE: Since we are inheriting from NUnitTestFixture we don't + // have to do anything if we don't want to. All the attributes + // that are normally used with an NUnitTestFixture will be + // recognized. + // + // Just to have something to do, we override DoOneTimeSetUp and + // DoOneTimeTearDown below to do some special processing before + // and after the normal TestFixtureSetUp and TestFixtureTearDown. + // In this example, we simply display a message. + } + + protected override void DoOneTimeSetUp(TestResult suiteResult) + { + Console.WriteLine( "Extended Fixture SetUp called" ); + base.DoOneTimeSetUp (suiteResult); + } + + protected override void DoOneTimeTearDown(TestResult suiteResult) + { + base.DoOneTimeTearDown (suiteResult); + Console.WriteLine( "Extended Fixture TearDown called" ); + } + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.csproj b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.csproj new file mode 100644 index 0000000..1fb245b --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtension.csproj @@ -0,0 +1,109 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{ED281A23-9579-4A70-B608-1B86DCDEB78C}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "SampleFixtureExtension" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "SampleFixtureExtension" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + /> + <Reference + Name = "nunit.core.interfaces" + AssemblyName = "nunit.core.interfaces" + HintPath = "..\..\..\..\solutions\vs2003\NUnitCore\interfaces\bin\Debug\nunit.core.interfaces.dll" + /> + <Reference + Name = "nunit.core" + AssemblyName = "nunit.core" + HintPath = "..\..\..\..\solutions\vs2003\NUnitCore\core\bin\Debug\nunit.core.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleFixtureExtension.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleFixtureExtensionAttribute.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleFixtureExtensionBuilder.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionAttribute.cs b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionAttribute.cs new file mode 100644 index 0000000..2d9737c --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionAttribute.cs @@ -0,0 +1,18 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// SampleFixtureExtensionAttribute is used to identify a SampleFixtureExtension class + /// </summary> + [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] + public sealed class SampleFixtureExtensionAttribute : Attribute + { + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionBuilder.cs b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionBuilder.cs new file mode 100644 index 0000000..3713a7e --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/SampleFixtureExtensionBuilder.cs @@ -0,0 +1,58 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using NUnit.Core.Builders; +using NUnit.Core.Extensibility; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// MockFixtureExtensionBuilder knows how to build + /// a MockFixtureExtension. + /// </summary> + [NUnitAddin(Description="Wraps an NUnitTestFixture with an additional level of SetUp and TearDown")] + public class SampleFixtureExtensionBuilder : ISuiteBuilder, IAddin + { + #region NUnitTestFixtureBuilder Overrides + /// <summary> + /// Makes a SampleFixtureExtension instance + /// </summary> + /// <param name="type">The type to be used</param> + /// <returns>A SampleFixtureExtension as a TestSuite</returns> +// protected override TestSuite MakeSuite(Type type) +// { +// return new SampleFixtureExtension( type ); +// } + + // The builder recognizes the types that it can use by the presense + // of SampleFixtureExtensionAttribute. Note that an attribute does not + // have to be used. You can use any arbitrary set of rules that can be + // implemented using reflection on the type. + public bool CanBuildFrom(Type type) + { + return Reflect.HasAttribute( type, "NUnit.Core.Extensions.SampleFixtureExtensionAttribute", false ); + } + + public Test BuildFrom(Type type) + { + return null; + } + #endregion + + #region IAddin Members + public bool Install(IExtensionHost host) + { + IExtensionPoint suiteBuilders = host.GetExtensionPoint( "SuiteBuilders" ); + if ( suiteBuilders == null ) + return false; + + suiteBuilders.Install( this ); + return true; + } + #endregion + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.cs b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.cs new file mode 100644 index 0000000..671fca9 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.cs @@ -0,0 +1,48 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using NUnit.Framework; +using NUnit.Core.Extensions; + +namespace NUnit.Extensions.Tests +{ + /// <summary> + /// Test class that demonstrates SampleFixtureExtension + /// </summary> + [SampleFixtureExtension] + public class SampleFixtureExtensionTests + { + [TestFixtureSetUp] + public void SetUpTests() + { + Console.WriteLine( "TestFixtureSetUp called" ); + } + + [TestFixtureTearDown] + public void FixtureTearDown() + { + Console.WriteLine( "TestFixtureTearDown called" ); + } + + [Test] + public void SomeTest() + { + Console.WriteLine( "Hello from some test" ); + } + + [Test] + public void AnotherTest() + { + Console.WriteLine( "Hello from another test" ); + } + + public void NotATest() + { + Console.WriteLine( "I shouldn't be called!" ); + } + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.csproj b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.csproj new file mode 100644 index 0000000..cc082b9 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleFixtureExtension/Tests/SampleFixtureExtensionTests.csproj @@ -0,0 +1,94 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{0DE6C90F-BB74-4BC8-887A-2222DB56D2EB}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "SampleFixtureExtensionTests" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "Tests" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + /> + <Reference + Name = "SampleFixtureExtension" + Project = "{ED281A23-9579-4A70-B608-1B86DCDEB78C}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + <Reference + Name = "nunit.framework" + AssemblyName = "nunit.framework" + HintPath = "..\..\..\bin\nunit.framework.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "SampleFixtureExtensionTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Addin.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Addin.cs new file mode 100644 index 0000000..20a359a --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Addin.cs @@ -0,0 +1,30 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using NUnit.Core.Extensibility; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// Summary description for Addin. + /// </summary> + [NUnitAddin(Name="SampleSuiteExtension", Description = "Recognizes Tests starting with SampleTest...")] + public class Addin : IAddin + { + #region IAddin Members + public bool Install(IExtensionHost host) + { + IExtensionPoint builders = host.GetExtensionPoint( "SuiteBuilders" ); + if ( builders == null ) + return false; + + builders.Install( new SampleSuiteExtensionBuilder() ); + return true; + } + #endregion + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/AssemblyInfo.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.build b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.build new file mode 100644 index 0000000..0dda8cc --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.build @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<project name="SampleSuiteExtension" default="build" basedir="."> + + <include buildfile="../../../samples.common" /> + + <patternset id="source-files"> + <include name="Addin.cs" /> + <include name="AssemblyInfo.cs" /> + <include name="SampleSuiteExtension.cs" /> + <include name="SampleSuiteExtensionAttribute.cs" /> + <include name="SampleSuiteExtensionBuilder.cs" /> + </patternset> + + <patternset id="test-files"> + <include name="SampleSuiteExtensionTests.cs" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.cs new file mode 100644 index 0000000..7abfa2c --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.cs @@ -0,0 +1,39 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using System.Reflection; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// SampleSuiteExtension is a minimal example of a suite extension. It + /// extends test suite and creates a fixture that runs every test starting + /// with "SampleTest..." Because it inherits from TestSuite, rather than + /// TestFixture, it has to construct its own fixture object and find its + /// own tests. Everything is done in the constructor for simplicity. + /// </summary> + class SampleSuiteExtension : TestSuite + { + public SampleSuiteExtension( Type fixtureType ) + : base( fixtureType ) + { + // Create the fixture object. We could wait to do this when + // it is needed, but we do it here for simplicity. + this.Fixture = Reflect.Construct( fixtureType ); + + // Locate our test methods and add them to the suite using + // the Add method of TestSuite. Note that we don't do a simple + // Tests.Add, because that wouldn't set the parent of the tests. + foreach( MethodInfo method in fixtureType.GetMethods( + BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly ) ) + { + if ( method.Name.StartsWith( "SampleTest" ) ) + this.Add( new NUnitTestMethod( method ) ); + } + } + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.csproj b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.csproj new file mode 100644 index 0000000..c7d0a70 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtension.csproj @@ -0,0 +1,114 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{0C4269EE-3266-45DD-9062-E356C067FBEF}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "SampleSuiteExtension" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "SampleSuiteExtension" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + /> + <Reference + Name = "nunit.core.interfaces" + AssemblyName = "nunit.core.interfaces" + HintPath = "..\..\..\bin\nunit.core.interfaces.dll" + /> + <Reference + Name = "nunit.core" + AssemblyName = "nunit.core" + HintPath = "..\..\..\bin\nunit.core.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "Addin.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "AssemblyInfo.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleSuiteExtension.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleSuiteExtensionAttribute.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "SampleSuiteExtensionBuilder.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionAttribute.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionAttribute.cs new file mode 100644 index 0000000..7194ea5 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionAttribute.cs @@ -0,0 +1,18 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// SampleSuiteExtensionAttribute is used to identify a SampleSuiteExtension fixture + /// </summary> + [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] + public sealed class SampleSuiteExtensionAttribute : Attribute + { + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionBuilder.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionBuilder.cs new file mode 100644 index 0000000..39b7b49 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/SampleSuiteExtensionBuilder.cs @@ -0,0 +1,41 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using NUnit.Core.Extensibility; + +namespace NUnit.Core.Extensions +{ + /// <summary> + /// SampleSuiteExtensionBuilder knows how to build a SampleSuiteExtension + /// </summary> + public class SampleSuiteExtensionBuilder : ISuiteBuilder + { + #region ISuiteBuilder Members + + // This builder delegates all the work to the constructor of the + // extension suite. Many builders will need to do more work, + // looking for other attributes, setting properties on the + // suite and locating methods for tests, setup and teardown. + public Test BuildFrom(Type type) + { + if ( CanBuildFrom( type ) ) + return new SampleSuiteExtension( type ); + return null; + } + + // The builder recognizes the types that it can use by the presense + // of SampleSuiteExtensionAttribute. Note that an attribute does not + // have to be used. You can use any arbitrary set of rules that can be + // implemented using reflection on the type. + public bool CanBuildFrom(Type type) + { + return Reflect.HasAttribute( type, "NUnit.Core.Extensions.SampleSuiteExtensionAttribute", false ); + } + + #endregion + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.cs b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.cs new file mode 100644 index 0000000..d1a7660 --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.cs @@ -0,0 +1,33 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using System.Reflection; + +namespace NUnit.Core.Extensions.Tests +{ + /// <summary> + /// Test class that demonstrates SampleSuiteExtension + /// </summary> + [SampleSuiteExtension] + public class SampleSuiteExtensionTests + { + public void SampleTest1() + { + Console.WriteLine( "Hello from sample test 1" ); + } + + public void SampleTest2() + { + Console.WriteLine( "Hello from sample test 2" ); + } + + public void NotATest() + { + Console.WriteLine( "I shouldn't be called!" ); + } + } +} diff --git a/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.csproj b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.csproj new file mode 100644 index 0000000..339d89b --- /dev/null +++ b/tools/NUnit/samples/Extensibility/Core/SampleSuiteExtension/Tests/SampleSuiteExtensionTests.csproj @@ -0,0 +1,94 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{9F609A0D-FF7E-4F0C-B2DF-417EBC557CFF}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "SampleSuiteExtensionTests" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Library" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "Tests" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = "bin\Debug\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "false" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = "bin\Release\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "false" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + /> + <Reference + Name = "SampleSuiteExtension" + Project = "{0C4269EE-3266-45DD-9062-E356C067FBEF}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + <Reference + Name = "nunit.framework" + AssemblyName = "nunit.framework" + HintPath = "..\..\..\..\bin\nunit.framework.dll" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "SampleSuiteExtensionTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/tools/NUnit/samples/ReadMe.txt b/tools/NUnit/samples/ReadMe.txt new file mode 100644 index 0000000..71e0ee7 --- /dev/null +++ b/tools/NUnit/samples/ReadMe.txt @@ -0,0 +1,69 @@ +NUnit Samples + +This directory contains sample applications demonstrating the use of NUnit and organized as follows... + + CSharp: Samples in C# + + Failures: Demonstrates 4 failing tests and one that is not run. + + Money: This is a C# version of the money example which is found in most xUnit implementations. Thanks to Kent Beck. + + Money-Port: This shows how the Money example can be ported from Version 1 of NUnit with minimal changes. + + Syntax: Illustrates most Assert methods using both the classic and constraint-based syntax. + + JSharp: Samples in J# + + Failures: Demonstrates 4 failing tests and one that is not run. + + CPP: C++ Samples + + MANAGED: Managed C++ Samples (VS 2003 compatible) + + Failures: Demonstrates 4 failing tests and one that is not run. + + CPP-CLI: C++/CLI Samples (VS 2005 only) + + Failures: Demonstrates 4 failing tests and one that is not run. + + Syntax: Illustrates most Assert methods using both the classic and constraint-based syntax. + + VB: Samples in VB.NET + + Failures: Demonstrates 4 failing tests and one that is not run. + + Money: This is a VB.NET version of the money example found in most xUnit implementations. Thanks to Kent Beck. + + Syntax: Illustrates most Assert methods using both the classic and constraint-based syntax. + + Extensibility: Examples of extending NUnit + + Framework: + + Core: + + TestSuiteExtension + + TestFixtureExtension + + +Building the Samples + +A Visual Studio 2003 project is included for most samples. +Visual Studio 2005 will convert the format automatically upon +opening it. The C++/CLI samples, as well as other samples that +depend on .NET 2.0 features, include Visual Studio 2005 projects. + +In most cases, you will need to remove the reference to the +nunit.framework assembly and replace it with a reference to +your installed copy of NUnit. + +To build using the Microsoft compiler, use a command similar +to the following: + + csc /target:library /r:<path-to-NUnit>/nunit.framework.dll example.cs + +To build using the mono compiler, use a command like this: + + msc /target:library /r:<path-to-NUNit>/nunit.framework.dll example.cs + diff --git a/tools/NUnit/samples/cpp/cpp-cli/cpp-cli.sln b/tools/NUnit/samples/cpp/cpp-cli/cpp-cli.sln new file mode 100644 index 0000000..a30cf36 --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/cpp-cli.sln @@ -0,0 +1,41 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-cli-failures", "failures\cpp-cli-failures.vcproj", "{A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-cli-syntax", "syntax\cpp-cli-syntax.vcproj", "{72448C2D-17C9-419E-B28D-3B533E7E0CD5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Debug|Win32.ActiveCfg = Debug|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Debug|Win32.Build.0 = Debug|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Release|Any CPU.ActiveCfg = Release|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Release|Mixed Platforms.Build.0 = Release|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Release|Win32.ActiveCfg = Release|Win32 + {A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}.Release|Win32.Build.0 = Release|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Debug|Win32.ActiveCfg = Debug|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Debug|Win32.Build.0 = Debug|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Release|Any CPU.ActiveCfg = Release|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Release|Mixed Platforms.Build.0 = Release|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Release|Win32.ActiveCfg = Release|Win32 + {72448C2D-17C9-419E-B28D-3B533E7E0CD5}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/NUnit/samples/cpp/cpp-cli/failures/AssemblyInfo.cpp b/tools/NUnit/samples/cpp/cpp-cli/failures/AssemblyInfo.cpp new file mode 100644 index 0000000..e64d6ee --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/failures/AssemblyInfo.cpp @@ -0,0 +1,56 @@ +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("")]; +[assembly:AssemblyCopyrightAttribute("")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("2.2.0.0")]; + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project directory. +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly:AssemblyDelaySignAttribute(false)]; +[assembly:AssemblyKeyFileAttribute("")]; +[assembly:AssemblyKeyNameAttribute("")]; + diff --git a/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.build b/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.build new file mode 100644 index 0000000..8cf139e --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.build @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<project name="cpp-cli-failures" default="build"> + + <include buildfile="../../../samples.common"/> + + <patternset id="source-files"> + <include name="AssemblyInfo.cpp" /> + <include name="cppsample.cpp" /> + <include name="cppsample.h" /> + </patternset> + + <target name="packagex"> + <copy todir="${package.samples.dir}/cpp/cpp-cli/failures"> + <fileset basedir="."> + <include name="cpp-cli-failures.vcproj" /> + <include name="cpp-cli-failures.build" /> + <include name="AssemblyInfo.cpp" /> + <include name="cppsample.cpp" /> + <include name="cppsample.h" /> + </fileset> + </copy> + </target> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.vcproj b/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.vcproj new file mode 100644 index 0000000..364a6be --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/failures/cpp-cli-failures.vcproj @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="cpp-cli-failures" + ProjectGUID="{A0987BCD-AFE6-40E4-95A8-ADA7ADB7E97D}" + RootNamespace="cpp-failures" + Keyword="ManagedCProj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + ManagedExtensions="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalUsingDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG" + MinimalRebuild="false" + BasicRuntimeChecks="0" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/cpp-cli-failures.dll" + LinkIncremental="2" + GenerateDebugInformation="true" + AssemblyDebug="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + ManagedExtensions="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + AdditionalUsingDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG" + MinimalRebuild="false" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/cpp-cli-failures.dll" + LinkIncremental="1" + GenerateDebugInformation="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + <AssemblyReference + RelativePath="..\..\..\..\solutions\vs2005\NUnitFramework\framework\bin\Debug\nunit.framework.dll" + AssemblyName="nunit.framework, Version=2.5.0.0, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" + /> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm" + > + <File + RelativePath="AssemblyInfo.cpp" + > + </File> + <File + RelativePath="cppsample.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc" + > + <File + RelativePath="cppsample.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;r" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.cpp b/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.cpp new file mode 100644 index 0000000..f5aea7c --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.cpp @@ -0,0 +1,48 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +#include "cppsample.h" + +namespace NUnitSamples { + + void SimpleCPPSample::Init() { + fValue1 = 2; + fValue2 = 3; + } + + void SimpleCPPSample::Add() { + int result = fValue1 + fValue2; + Assert::AreEqual(6,result); + } + + void SimpleCPPSample::DivideByZero() + { + int zero= 0; + int result= 8/zero; + } + + void SimpleCPPSample::Equals() { + Assert::AreEqual(12, 12, "Integer"); + Assert::AreEqual(12L, 12L, "Long"); + Assert::AreEqual('a', 'a', "Char"); + + + Assert::AreEqual(12, 13, "Expected Failure (Integer)"); + Assert::AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)"); + } + + void SimpleCPPSample::IgnoredTest() + { + throw gcnew InvalidCastException(); + } + + void SimpleCPPSample::ExpectAnException() + { + throw gcnew InvalidCastException(); + } + +} + diff --git a/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.h b/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.h new file mode 100644 index 0000000..863feb5 --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/failures/cppsample.h @@ -0,0 +1,28 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +#pragma once + +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitSamples +{ + [TestFixture] + public ref class SimpleCPPSample + { + int fValue1; + int fValue2; + public: + [SetUp] void Init(); + + [Test] void Add(); + [Test] void DivideByZero(); + [Test] void Equals(); + [Test] [Ignore("ignored test")] void IgnoredTest(); + [Test] [ExpectedException(InvalidOperationException::typeid)] void ExpectAnException(); + }; +} diff --git a/tools/NUnit/samples/cpp/cpp-cli/syntax/AssemblyInfo.cpp b/tools/NUnit/samples/cpp/cpp-cli/syntax/AssemblyInfo.cpp new file mode 100644 index 0000000..b18cdfa --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/syntax/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("cppclisyntax")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("cppclisyntax")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2007")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.build b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.build new file mode 100644 index 0000000..f3b6328 --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="cpp-cli-syntax" default="build"> + + <include buildfile="../../../samples.common"/> + + <patternset id="source-files"> + <include name="AssemblyInfo.cpp" /> + <include name="cpp-cli-syntax.cpp" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.cpp b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.cpp new file mode 100644 index 0000000..a554e95 --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.cpp @@ -0,0 +1,641 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +using namespace NUnit::Framework; +using NUnit::Framework::Is; +using NUnit::Framework::Text; +using NUnit::Framework::List; +using NUnit::Framework::Has; +using System::String; + +namespace NUnitSamples +{ + [TestFixture] + public ref class AssertSyntaxTests : AssertionHelper + { + public: + [Test] + void IsNull() + { + Object ^nada = nullptr; + + // Classic syntax + Assert::IsNull(nada); + + // Helper syntax + Assert::That(nada, Is::Null); + + // Inherited syntax + Expect(nada, Null); + } + + [Test] + void IsNotNull() + { + // Classic syntax + Assert::IsNotNull(42); + + // Helper syntax + Assert::That(42, Is::Not->Null); + + // Inherited syntax + Expect( 42, Not->Null ); + } + + [Test] + void IsTrue() + { + // Classic syntax + Assert::IsTrue(2+2==4); + + // Helper syntax + Assert::That(2+2==4, Is::True); + Assert::That(2+2==4); + + // Inherited syntax + Expect(2+2==4, True); + Expect(2+2==4); + } + + [Test] + void IsFalse() + { + // Classic syntax + Assert::IsFalse(2+2==5); + + // Helper syntax + Assert::That(2+2==5, Is::False); + + // Inherited syntax + Expect(2+2==5, False); + } + + [Test] + void IsNaN() + { + double d = double::NaN; + float f = float::NaN; + + // Classic syntax + Assert::IsNaN(d); + Assert::IsNaN(f); + + // Helper syntax + Assert::That(d, Is::NaN); + Assert::That(f, Is::NaN); + + // Inherited syntax + Expect(d, NaN); + Expect(f, NaN); + } + + [Test] + void EmptyStringTests() + { + // Classic syntax + Assert::IsEmpty(""); + Assert::IsNotEmpty("Hello!"); + + // Helper syntax + Assert::That("", Is::Empty); + Assert::That("Hello!", Is::Not->Empty); + + // Inherited syntax + Expect("", Empty); + Expect("Hello!", Not->Empty); + } + + [Test] + void EmptyCollectionTests() + { + // Classic syntax + Assert::IsEmpty(gcnew array<bool>(0)); + Assert::IsNotEmpty(gcnew array<int>(3)); + + // Helper syntax + Assert::That(gcnew array<bool>(0), Is::Empty); + Assert::That(gcnew array<int>(3), Is::Not->Empty); + + // Inherited syntax + Expect(gcnew array<bool>(0), Empty); + Expect(gcnew array<int>(3), Not->Empty); + } + + [Test] + void ExactTypeTests() + { + // Classic syntax workarounds) + String^ greeting = "Hello"; + Assert::AreEqual(String::typeid, greeting->GetType()); + Assert::AreEqual("System.String", greeting->GetType()->FullName); + Assert::AreNotEqual(int::typeid, greeting->GetType()); + Assert::AreNotEqual("System.Int32", greeting->GetType()->FullName); + + // Helper syntax + Assert::That(greeting, Is::TypeOf(String::typeid)); + Assert::That(greeting, Is::Not->TypeOf(int::typeid)); + + // Inherited syntax + Expect( "Hello", TypeOf(String::typeid)); + Expect( "Hello", Not->TypeOf(int::typeid)); + } + + [Test] + void InstanceOfTypeTests() + { + // Classic syntax + Assert::IsInstanceOfType(String::typeid, "Hello"); + Assert::IsNotInstanceOfType(String::typeid, 5); + + // Helper syntax + Assert::That("Hello", Is::InstanceOfType(String::typeid)); + Assert::That(5, Is::Not->InstanceOfType(String::typeid)); + + // Inherited syntax + Expect("Hello", InstanceOfType(String::typeid)); + Expect(5, Not->InstanceOfType(String::typeid)); + } + + [Test] + void AssignableFromTypeTests() + { + // Classic syntax + Assert::IsAssignableFrom(String::typeid, "Hello"); + Assert::IsNotAssignableFrom(String::typeid, 5); + + // Helper syntax + Assert::That( "Hello", Is::AssignableFrom(String::typeid)); + Assert::That( 5, Is::Not->AssignableFrom(String::typeid)); + + // Inherited syntax + Expect( "Hello", AssignableFrom(String::typeid)); + Expect( 5, Not->AssignableFrom(String::typeid)); + } + + [Test] + void SubstringTests() + { + String^ phrase = "Hello World!"; + array<String^>^ strings = {"abc", "bad", "dba" }; + + // Classic Syntax + StringAssert::Contains("World", phrase); + + // Helper syntax + Assert::That(phrase, Contains("World")); + // Only available using new syntax + Assert::That(phrase, Text::DoesNotContain("goodbye")); + Assert::That(phrase, Text::Contains("WORLD")->IgnoreCase); + Assert::That(phrase, Text::DoesNotContain("BYE")->IgnoreCase); + Assert::That(strings, Text::All->Contains( "b" ) ); + + // Inherited syntax + Expect(phrase, Contains("World")); + // Only available using new syntax + Expect(phrase, Not->Contains("goodbye")); + Expect(phrase, Contains("WORLD")->IgnoreCase); + Expect(phrase, Not->Contains("BYE")->IgnoreCase); + Expect(strings, All->Contains("b")); + } + + [Test] + void StartsWithTests() + { + String^ phrase = "Hello World!"; + array<String^>^ greetings = { "Hello!", "Hi!", "Hola!" }; + + // Classic syntax + StringAssert::StartsWith("Hello", phrase); + + // Helper syntax + Assert::That(phrase, Text::StartsWith("Hello")); + // Only available using new syntax + Assert::That(phrase, Text::DoesNotStartWith("Hi!")); + Assert::That(phrase, Text::StartsWith("HeLLo")->IgnoreCase); + Assert::That(phrase, Text::DoesNotStartWith("HI")->IgnoreCase); + Assert::That(greetings, Text::All->StartsWith("h")->IgnoreCase); + + // Inherited syntax + Expect(phrase, StartsWith("Hello")); + // Only available using new syntax + Expect(phrase, Not->StartsWith("Hi!")); + Expect(phrase, StartsWith("HeLLo")->IgnoreCase); + Expect(phrase, Not->StartsWith("HI")->IgnoreCase); + Expect(greetings, All->StartsWith("h")->IgnoreCase); + } + + [Test] + void EndsWithTests() + { + String^ phrase = "Hello World!"; + array<String^>^ greetings = { "Hello!", "Hi!", "Hola!" }; + + // Classic Syntax + StringAssert::EndsWith("!", phrase); + + // Helper syntax + Assert::That(phrase, Text::EndsWith("!")); + // Only available using new syntax + Assert::That(phrase, Text::DoesNotEndWith("?")); + Assert::That(phrase, Text::EndsWith("WORLD!")->IgnoreCase); + Assert::That(greetings, Text::All->EndsWith("!")); + + // Inherited syntax + Expect(phrase, EndsWith("!")); + // Only available using new syntax + Expect(phrase, Not->EndsWith("?")); + Expect(phrase, EndsWith("WORLD!")->IgnoreCase); + Expect(greetings, All->EndsWith("!") ); + } + + [Test] + void EqualIgnoringCaseTests() + { + String^ phrase = "Hello World!"; + + // Classic syntax + StringAssert::AreEqualIgnoringCase("hello world!",phrase); + + // Helper syntax + Assert::That(phrase, Is::EqualTo("hello world!")->IgnoreCase); + //Only available using new syntax + Assert::That(phrase, Is::Not->EqualTo("goodbye world!")->IgnoreCase); + Assert::That(gcnew array<String^> { "Hello", "World" }, + Is::EqualTo(gcnew array<Object^> { "HELLO", "WORLD" })->IgnoreCase); + Assert::That(gcnew array<String^> {"HELLO", "Hello", "hello" }, + Is::All->EqualTo( "hello" )->IgnoreCase); + + // Inherited syntax + Expect(phrase, EqualTo("hello world!")->IgnoreCase); + //Only available using new syntax + Expect(phrase, Not->EqualTo("goodbye world!")->IgnoreCase); + Expect(gcnew array<String^> { "Hello", "World" }, + EqualTo(gcnew array<Object^> { "HELLO", "WORLD" })->IgnoreCase); + Expect(gcnew array<String^> {"HELLO", "Hello", "hello" }, + All->EqualTo( "hello" )->IgnoreCase); + } + + [Test] + void RegularExpressionTests() + { + String^ phrase = "Now is the time for all good men to come to the aid of their country."; + array<String^>^ quotes = { "Never say never", "It's never too late", "Nevermore!" }; + + // Classic syntax + StringAssert::IsMatch( "all good men", phrase ); + StringAssert::IsMatch( "Now.*come", phrase ); + + // Helper syntax + Assert::That( phrase, Text::Matches( "all good men" ) ); + Assert::That( phrase, Text::Matches( "Now.*come" ) ); + // Only available using new syntax + Assert::That(phrase, Text::DoesNotMatch("all.*men.*good")); + Assert::That(phrase, Text::Matches("ALL")->IgnoreCase); + Assert::That(quotes, Text::All->Matches("never")->IgnoreCase); + + // Inherited syntax + Expect( phrase, Matches( "all good men" ) ); + Expect( phrase, Matches( "Now.*come" ) ); + // Only available using new syntax + Expect(phrase, Not->Matches("all.*men.*good")); + Expect(phrase, Matches("ALL")->IgnoreCase); + Expect(quotes, All->Matches("never")->IgnoreCase); + } + + [Test] + void EqualityTests() + { + array<int>^ i3 = { 1, 2, 3 }; + array<double>^ d3 = { 1.0, 2.0, 3.0 }; + array<int>^ iunequal = { 1, 3, 2 }; + + // Classic Syntax + Assert::AreEqual(4, 2 + 2); + Assert::AreEqual(i3, d3); + Assert::AreNotEqual(5, 2 + 2); + Assert::AreNotEqual(i3, iunequal); + + // Helper syntax + Assert::That(2 + 2, Is::EqualTo(4)); + Assert::That(2 + 2 == 4); + Assert::That(i3, Is::EqualTo(d3)); + Assert::That(2 + 2, Is::Not->EqualTo(5)); + Assert::That(i3, Is::Not->EqualTo(iunequal)); + + // Inherited syntax + Expect(2 + 2, EqualTo(4)); + Expect(2 + 2 == 4); + Expect(i3, EqualTo(d3)); + Expect(2 + 2, Not->EqualTo(5)); + Expect(i3, Not->EqualTo(iunequal)); + } + + [Test] + void EqualityTestsWithTolerance() + { + // CLassic syntax + Assert::AreEqual(5.0, 4.99, 0.05); + Assert::AreEqual(5.0F, 4.99F, 0.05F); + + // Helper syntax + Assert::That(4.99L, Is::EqualTo(5.0L)->Within(0.05L)); + Assert::That(4.99f, Is::EqualTo(5.0f)->Within(0.05f)); + + // Inherited syntax + Expect(4.99L, EqualTo(5.0L)->Within(0.05L)); + Expect(4.99f, EqualTo(5.0f)->Within(0.05f)); + } + + [Test] + void ComparisonTests() + { + // Classic Syntax + Assert::Greater(7, 3); + Assert::GreaterOrEqual(7, 3); + Assert::GreaterOrEqual(7, 7); + + // Helper syntax + Assert::That(7, Is::GreaterThan(3)); + Assert::That(7, Is::GreaterThanOrEqualTo(3)); + Assert::That(7, Is::AtLeast(3)); + Assert::That(7, Is::GreaterThanOrEqualTo(7)); + Assert::That(7, Is::AtLeast(7)); + + // Inherited syntax + Expect(7, GreaterThan(3)); + Expect(7, GreaterThanOrEqualTo(3)); + Expect(7, AtLeast(3)); + Expect(7, GreaterThanOrEqualTo(7)); + Expect(7, AtLeast(7)); + + // Classic syntax + Assert::Less(3, 7); + Assert::LessOrEqual(3, 7); + Assert::LessOrEqual(3, 3); + + // Helper syntax + Assert::That(3, Is::LessThan(7)); + Assert::That(3, Is::LessThanOrEqualTo(7)); + Assert::That(3, Is::AtMost(7)); + Assert::That(3, Is::LessThanOrEqualTo(3)); + Assert::That(3, Is::AtMost(3)); + + // Inherited syntax + Expect(3, LessThan(7)); + Expect(3, LessThanOrEqualTo(7)); + Expect(3, AtMost(7)); + Expect(3, LessThanOrEqualTo(3)); + Expect(3, AtMost(3)); + } + + [Test] + void AllItemsTests() + { + array<Object^>^ ints = { 1, 2, 3, 4 }; + array<Object^>^ strings = { "abc", "bad", "cab", "bad", "dad" }; + + // Classic syntax + CollectionAssert::AllItemsAreNotNull(ints); + CollectionAssert::AllItemsAreInstancesOfType(ints, int::typeid); + CollectionAssert::AllItemsAreInstancesOfType(strings, String::typeid); + CollectionAssert::AllItemsAreUnique(ints); + + // Helper syntax + Assert::That(ints, Is::All->Not->Null); + Assert::That(ints, Is::All->InstanceOfType(int::typeid)); + Assert::That(strings, Is::All->InstanceOfType(String::typeid)); + Assert::That(ints, Is::Unique); + // Only available using new syntax + Assert::That(strings, Is::Not->Unique); + Assert::That(ints, Is::All->GreaterThan(0)); + Assert::That(strings, Text::All->Contains( "a" ) ); + Assert::That(strings, Has::Some->StartsWith( "ba" ) ); + + // Inherited syntax + Expect(ints, All->Not->Null); + Expect(ints, All->InstanceOfType(int::typeid)); + Expect(strings, All->InstanceOfType(String::typeid)); + Expect(ints, Unique); + // Only available using new syntax + Expect(strings, Not->Unique); + Expect(ints, All->GreaterThan(0)); + Expect(strings, All->Contains( "a" ) ); + Expect(strings, Some->StartsWith( "ba" ) ); + } + + [Test] + void SomeItemsTests() + { + array<Object^>^ mixed = { 1, 2, "3", nullptr, "four", 100 }; + array<Object^>^ strings = { "abc", "bad", "cab", "bad", "dad" }; + + // Not available using the classic syntax + + // Helper syntax + Assert::That(mixed, Has::Some->Null); + Assert::That(mixed, Has::Some->InstanceOfType(int::typeid)); + Assert::That(mixed, Has::Some->InstanceOfType(String::typeid)); + Assert::That(strings, Has::Some->StartsWith( "ba" ) ); + Assert::That(strings, Has::Some->Not->StartsWith( "ba" ) ); + + // Inherited syntax + Expect(mixed, Some->Null); + Expect(mixed, Some->InstanceOfType(int::typeid)); + Expect(mixed, Some->InstanceOfType(String::typeid)); + Expect(strings, Some->StartsWith( "ba" ) ); + Expect(strings, Some->Not->StartsWith( "ba" ) ); + } + + [Test] + void NoItemsTests() + { + array<Object^>^ ints = { 1, 2, 3, 4, 5 }; + array<Object^>^ strings = { "abc", "bad", "cab", "bad", "dad" }; + + // Not available using the classic syntax + + // Helper syntax + Assert::That(ints, Has::None->Null); + Assert::That(ints, Has::None->InstanceOfType(String::typeid)); + Assert::That(ints, Has::None->GreaterThan(99)); + Assert::That(strings, Has::None->StartsWith( "qu" ) ); + + // Inherited syntax + Expect(ints, None->Null); + Expect(ints, None->InstanceOfType(String::typeid)); + Expect(ints, None->GreaterThan(99)); + Expect(strings, None->StartsWith( "qu" ) ); + } + + [Test] + void CollectionContainsTests() + { + array<int>^ iarray = { 1, 2, 3 }; + array<String^>^ sarray = { "a", "b", "c" }; + + // Classic syntax + Assert::Contains(3, iarray); + Assert::Contains("b", sarray); + CollectionAssert::Contains(iarray, 3); + CollectionAssert::Contains(sarray, "b"); + CollectionAssert::DoesNotContain(sarray, "x"); + + // Helper syntax + Assert::That(iarray, Has::Member(3)); + Assert::That(sarray, Has::Member("b")); + Assert::That(sarray, Has::No->Member("x")); // Yuck! + Assert::That(sarray, !Has::Member("x")); + + // Inherited syntax + Expect(iarray, Contains(3)); + Expect(sarray, Contains("b")); + Expect(sarray, Not->Contains("x")); + Expect(sarray, !Contains("x")); + } + + [Test] + void CollectionEquivalenceTests() + { + array<int>^ ints1to5 = { 1, 2, 3, 4, 5 }; + + // Classic syntax + CollectionAssert::AreEquivalent(gcnew array<int> { 2, 1, 4, 3, 5 }, ints1to5); + CollectionAssert::AreNotEquivalent(gcnew array<int> { 2, 2, 4, 3, 5 }, ints1to5); + CollectionAssert::AreNotEquivalent(gcnew array<int> { 2, 4, 3, 5 }, ints1to5); + CollectionAssert::AreNotEquivalent(gcnew array<int> { 2, 2, 1, 1, 4, 3, 5 }, ints1to5); + + // Helper syntax + Assert::That(gcnew array<int> { 2, 1, 4, 3, 5 }, Is::EquivalentTo(ints1to5)); + Assert::That(gcnew array<int> { 2, 2, 4, 3, 5 }, Is::Not->EquivalentTo(ints1to5)); + Assert::That(gcnew array<int> { 2, 4, 3, 5 }, Is::Not->EquivalentTo(ints1to5)); + Assert::That(gcnew array<int> { 2, 2, 1, 1, 4, 3, 5 }, Is::Not->EquivalentTo(ints1to5)); + + // Inherited syntax + Expect(gcnew array<int> { 2, 1, 4, 3, 5 }, EquivalentTo(ints1to5)); + Expect(gcnew array<int> { 2, 2, 4, 3, 5 }, Not->EquivalentTo(ints1to5)); + Expect(gcnew array<int> { 2, 4, 3, 5 }, Not->EquivalentTo(ints1to5)); + Expect(gcnew array<int> { 2, 2, 1, 1, 4, 3, 5 }, Not->EquivalentTo(ints1to5)); + } + + [Test] + void SubsetTests() + { + array<int>^ ints1to5 = { 1, 2, 3, 4, 5 }; + + // Classic syntax + CollectionAssert::IsSubsetOf(gcnew array<int> { 1, 3, 5 }, ints1to5); + CollectionAssert::IsSubsetOf(gcnew array<int> { 1, 2, 3, 4, 5 }, ints1to5); + CollectionAssert::IsNotSubsetOf(gcnew array<int> { 2, 4, 6 }, ints1to5); + CollectionAssert::IsNotSubsetOf(gcnew array<int> { 1, 2, 2, 2, 5 }, ints1to5); + + // Helper syntax + Assert::That(gcnew array<int> { 1, 3, 5 }, Is::SubsetOf(ints1to5)); + Assert::That(gcnew array<int> { 1, 2, 3, 4, 5 }, Is::SubsetOf(ints1to5)); + Assert::That(gcnew array<int> { 2, 4, 6 }, Is::Not->SubsetOf(ints1to5)); + Assert::That(gcnew array<int> { 1, 2, 2, 2, 5 }, Is::Not->SubsetOf(ints1to5)); + + // Inherited syntax + Expect(gcnew array<int> { 1, 3, 5 }, SubsetOf(ints1to5)); + Expect(gcnew array<int> { 1, 2, 3, 4, 5 }, SubsetOf(ints1to5)); + Expect(gcnew array<int> { 2, 4, 6 }, Not->SubsetOf(ints1to5)); + Expect(gcnew array<int> { 1, 2, 2, 2, 5 }, Not->SubsetOf(ints1to5)); + } + + [Test] + void PropertyTests() + { + array<String^>^ strings = { "abc", "bca", "xyz" }; + + // Helper syntax + Assert::That( "Hello", Has::Property("Length")->EqualTo(5) ); + Assert::That( "Hello", Has::Length->EqualTo( 5 ) ); + Assert::That( strings , Has::All->Property( "Length")->EqualTo(3) ); + Assert::That( strings, Has::All->Length->EqualTo( 3 ) ); + + // Inherited syntax + Expect( "Hello", Property("Length")->EqualTo(5) ); + Expect( "Hello", Length->EqualTo( 5 ) ); + Expect( strings, All->Property("Length")->EqualTo(3) ); + Expect( strings, All->Length->EqualTo( 3 ) ); + } + + [Test] + void NotTests() + { + // Not available using the classic syntax + + // Helper syntax + Assert::That(42, Is::Not->Null); + Assert::That(42, Is::Not->True); + Assert::That(42, Is::Not->False); + Assert::That(2.5, Is::Not->NaN); + Assert::That(2 + 2, Is::Not->EqualTo(3)); + Assert::That(2 + 2, Is::Not->Not->EqualTo(4)); + Assert::That(2 + 2, Is::Not->Not->Not->EqualTo(5)); + + // Inherited syntax + Expect(42, Not->Null); + Expect(42, Not->True); + Expect(42, Not->False); + Expect(2.5, Not->NaN); + Expect(2 + 2, Not->EqualTo(3)); + Expect(2 + 2, Not->Not->EqualTo(4)); + Expect(2 + 2, Not->Not->Not->EqualTo(5)); + } + + [Test] + void NotOperator() + { + // The ! operator is only available in the new syntax + Assert::That(42, !Is::Null); + // Inherited syntax + Expect( 42, !Null ); + } + + [Test] + void AndOperator() + { + // The & operator is only available in the new syntax + Assert::That(7, Is::GreaterThan(5) & Is::LessThan(10)); + // Inherited syntax + Expect( 7, GreaterThan(5) & LessThan(10)); + } + + [Test] + void OrOperator() + { + // The | operator is only available in the new syntax + Assert::That(3, Is::LessThan(5) | Is::GreaterThan(10)); + Expect( 3, LessThan(5) | GreaterThan(10)); + } + + [Test] + void ComplexTests() + { + Assert::That(7, Is::Not->Null & Is::Not->LessThan(5) & Is::Not->GreaterThan(10)); + Expect(7, Not->Null & Not->LessThan(5) & Not->GreaterThan(10)); + + Assert::That(7, !Is::Null & !Is::LessThan(5) & !Is::GreaterThan(10)); + Expect(7, !Null & !LessThan(5) & !GreaterThan(10)); + } + + // This method contains assertions that should not compile + // You can check by uncommenting it. + //void WillNotCompile() + //{ + // Assert::That(42, Is::Not); + // Assert::That(42, Is::All); + // Assert::That(42, Is::Null->Not); + // Assert::That(42, Is::Not->Null->GreaterThan(10)); + // Assert::That(42, Is::GreaterThan(10)->LessThan(99)); + + // object[] c = new object[0]; + // Assert::That(c, Is::Null->All); + // Assert::That(c, Is::Not->All); + // Assert::That(c, Is::All->Not); + //} + }; +}
\ No newline at end of file diff --git a/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.vcproj b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.vcproj new file mode 100644 index 0000000..ff1efe8 --- /dev/null +++ b/tools/NUnit/samples/cpp/cpp-cli/syntax/cpp-cli-syntax.vcproj @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="cpp-cli-syntax" + ProjectGUID="{72448C2D-17C9-419E-B28D-3B533E7E0CD5}" + RootNamespace="cppclisyntax" + Keyword="ManagedCProj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + ManagedExtensions="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG" + RuntimeLibrary="3" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="$(NoInherit)" + LinkIncremental="2" + GenerateDebugInformation="true" + AssemblyDebug="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + ManagedExtensions="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="WIN32;NDEBUG" + RuntimeLibrary="2" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="$(NoInherit)" + LinkIncremental="1" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + <AssemblyReference + RelativePath="System.dll" + AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" + /> + <AssemblyReference + RelativePath="..\..\..\..\solutions\vs2005\NUnitFramework\framework\bin\Debug\nunit.framework.dll" + AssemblyName="nunit.framework, Version=2.5.0.0, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" + /> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\cpp-cli-syntax.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/tools/NUnit/samples/cpp/managed/failures/AssemblyInfo.cpp b/tools/NUnit/samples/cpp/managed/failures/AssemblyInfo.cpp new file mode 100644 index 0000000..e64d6ee --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/failures/AssemblyInfo.cpp @@ -0,0 +1,56 @@ +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("")]; +[assembly:AssemblyCopyrightAttribute("")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("2.2.0.0")]; + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project directory. +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly:AssemblyDelaySignAttribute(false)]; +[assembly:AssemblyKeyFileAttribute("")]; +[assembly:AssemblyKeyNameAttribute("")]; + diff --git a/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.build b/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.build new file mode 100644 index 0000000..5bf96a1 --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.build @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<project name="cpp-managed-failures" default="build"> + + <include buildfile="../../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.cpp" /> + <include name="cppsample.cpp" /> + <include name="cppsample.h" /> + </patternset> + + <target name="packagex"> + <copy todir="${package.samples.dir}/cpp/managed/failures"> + <fileset basedir="."> + <include name="cpp-managed-failures.build" /> + <include name="AssemblyInfo.cpp" /> + <include name="cppsample.cpp" /> + <include name="cppsample.h" /> + </fileset> + </copy> + + <copy todir="${package.samples.dir}/cpp/managed/failures" + file="./cpp-managed-failures.vcproj"> + <filterchain> + <replacestring from="$(SolutionDir)..\..\..\src\NUnitFramework\framework\bin\Debug\nunit.framework.dll" + to="..\..\..\..\bin\nunit.framework.dll"/> + </filterchain> + </copy> + </target> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.vcproj b/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.vcproj new file mode 100644 index 0000000..ec3e599 --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/failures/cpp-managed-failures.vcproj @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="cpp-managed-failures" + ProjectGUID="{7E5849C7-0469-4AD2-91B9-C87203934254}" + Keyword="ManagedCProj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="2" + CharacterSet="2" + ManagedExtensions="TRUE" + ReferencesPath=""D:\Dev\NUnit\nunit-2.5\solutions\vs2005\NUnitFramework\framework\bin\Release""> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalUsingDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG" + MinimalRebuild="FALSE" + BasicRuntimeChecks="0" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/managed-cpp-failures.dll" + LinkIncremental="2" + GenerateDebugInformation="TRUE"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="2" + CharacterSet="2" + ManagedExtensions="TRUE" + ReferencesPath=""D:\Dev\NUnit\nunit-2.5\solutions\vs2005\NUnitFramework\framework\bin\Release""> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + AdditionalUsingDirectories="..\..\src\NUnitFramework\framework\bin\Release;..\..\src\NUnitFramework\framework\bin\Debug" + PreprocessorDefinitions="WIN32;NDEBUG" + MinimalRebuild="FALSE" + UsePrecompiledHeader="0" + WarningLevel="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)/managed-cpp-failures.dll" + LinkIncremental="1" + GenerateDebugInformation="TRUE"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + <AssemblyReference + RelativePath="mscorlib.dll"/> + <AssemblyReference + RelativePath="$(SolutionDir)..\..\bin\nunit.framework.dll"/> + <AssemblyReference + RelativePath="System.dll"/> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> + <File + RelativePath="AssemblyInfo.cpp"> + </File> + <File + RelativePath="cppsample.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc"> + <File + RelativePath="cppsample.h"> + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;r"> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/tools/NUnit/samples/cpp/managed/failures/cppsample.cpp b/tools/NUnit/samples/cpp/managed/failures/cppsample.cpp new file mode 100644 index 0000000..dac7156 --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/failures/cppsample.cpp @@ -0,0 +1,48 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +#include "cppsample.h" + +namespace NUnitSamples { + + void SimpleCPPSample::Init() { + fValue1 = 2; + fValue2 = 3; + } + + void SimpleCPPSample::Add() { + int result = fValue1 + fValue2; + Assert::AreEqual(6,result); + } + + void SimpleCPPSample::DivideByZero() + { + int zero= 0; + int result= 8/zero; + } + + void SimpleCPPSample::Equals() { + Assert::AreEqual(12, 12, "Integer"); + Assert::AreEqual(12L, 12L, "Long"); + Assert::AreEqual('a', 'a', "Char"); + + + Assert::AreEqual(12, 13, "Expected Failure (Integer)"); + Assert::AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)"); + } + + void SimpleCPPSample::IgnoredTest() + { + throw new InvalidCastException(); + } + + void SimpleCPPSample::ExpectAnException() + { + throw new InvalidCastException(); + } + +} + diff --git a/tools/NUnit/samples/cpp/managed/failures/cppsample.h b/tools/NUnit/samples/cpp/managed/failures/cppsample.h new file mode 100644 index 0000000..4e47439 --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/failures/cppsample.h @@ -0,0 +1,28 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +#pragma once + +using namespace System; +using namespace NUnit::Framework; + +namespace NUnitSamples +{ + [TestFixture] + public __gc class SimpleCPPSample + { + int fValue1; + int fValue2; + public: + [SetUp] void Init(); + + [Test] void Add(); + [Test] void DivideByZero(); + [Test] void Equals(); + [Test] [Ignore("ignored test")] void IgnoredTest(); + [Test] [ExpectedException(__typeof(InvalidOperationException))] void ExpectAnException(); + }; +} diff --git a/tools/NUnit/samples/cpp/managed/managed-cpp.sln b/tools/NUnit/samples/cpp/managed/managed-cpp.sln new file mode 100644 index 0000000..4462fb0 --- /dev/null +++ b/tools/NUnit/samples/cpp/managed/managed-cpp.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-managed-failures", "failures\cpp-managed-failures.vcproj", "{7E5849C7-0469-4AD2-91B9-C87203934254}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {7E5849C7-0469-4AD2-91B9-C87203934254}.Debug.ActiveCfg = Debug|Win32 + {7E5849C7-0469-4AD2-91B9-C87203934254}.Debug.Build.0 = Debug|Win32 + {7E5849C7-0469-4AD2-91B9-C87203934254}.Release.ActiveCfg = Release|Win32 + {7E5849C7-0469-4AD2-91B9-C87203934254}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/NUnit/samples/csharp/CSharp.sln b/tools/NUnit/samples/csharp/CSharp.sln new file mode 100644 index 0000000..ed95f8a --- /dev/null +++ b/tools/NUnit/samples/csharp/CSharp.sln @@ -0,0 +1,37 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs-failures", "failures\cs-failures.csproj", "{15D66EEE-A852-4A52-89C2-83E74ECF3770}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs-money", "money\cs-money.csproj", "{11EDF872-A04D-4F75-A1BF-71168DC86AF3}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs-syntax", "syntax\cs-syntax.csproj", "{06F46FA2-687B-4B46-A912-C1B0B4CC1B20}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {15D66EEE-A852-4A52-89C2-83E74ECF3770}.Debug.ActiveCfg = Debug|.NET + {15D66EEE-A852-4A52-89C2-83E74ECF3770}.Debug.Build.0 = Debug|.NET + {15D66EEE-A852-4A52-89C2-83E74ECF3770}.Release.ActiveCfg = Release|.NET + {15D66EEE-A852-4A52-89C2-83E74ECF3770}.Release.Build.0 = Release|.NET + {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Debug.ActiveCfg = Debug|.NET + {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Debug.Build.0 = Debug|.NET + {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Release.ActiveCfg = Release|.NET + {11EDF872-A04D-4F75-A1BF-71168DC86AF3}.Release.Build.0 = Release|.NET + {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Debug.ActiveCfg = Debug|.NET + {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Debug.Build.0 = Debug|.NET + {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Release.ActiveCfg = Release|.NET + {06F46FA2-687B-4B46-A912-C1B0B4CC1B20}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/NUnit/samples/csharp/failures/AssemblyInfo.cs b/tools/NUnit/samples/csharp/failures/AssemblyInfo.cs new file mode 100644 index 0000000..67e65b0 --- /dev/null +++ b/tools/NUnit/samples/csharp/failures/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("csharp.sample.dll")] +[assembly: AssemblyDescription("C# Sample Unit Tests")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("NUnit")] +[assembly: AssemblyProduct("NUnit")] +[assembly: AssemblyCopyright("Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. \nCopyright (C) 2000-2003 Philip Craig.\nAll Rights Reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("2.2.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/NUnit/samples/csharp/failures/CSharpTest.cs b/tools/NUnit/samples/csharp/failures/CSharpTest.cs new file mode 100644 index 0000000..0ab0fe6 --- /dev/null +++ b/tools/NUnit/samples/csharp/failures/CSharpTest.cs @@ -0,0 +1,85 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +namespace NUnit.Samples +{ + using System; + using NUnit.Framework; + + /// <summary>Some simple Tests.</summary> + /// + [TestFixture] + public class SimpleCSharpTest + { + /// <summary> + /// + /// </summary> + protected int fValue1; + /// <summary> + /// + /// </summary> + protected int fValue2; + + /// <summary> + /// + /// </summary> + [SetUp] public void Init() + { + fValue1= 2; + fValue2= 3; + } + + /// <summary> + /// + /// </summary> + /// + [Test] public void Add() + { + double result= fValue1 + fValue2; + // forced failure result == 5 + Assert.AreEqual(6, result, "Expected Failure."); + } + + /// <summary> + /// + /// </summary> + /// + [Test] public void DivideByZero() + { + int zero= 0; + int result= 8/zero; + } + + /// <summary> + /// + /// </summary> + /// + [Test] public void Equals() + { + Assert.AreEqual(12, 12, "Integer"); + Assert.AreEqual(12L, 12L, "Long"); + Assert.AreEqual('a', 'a', "Char"); + Assert.AreEqual((object)12, (object)12, "Integer Object Cast"); + + Assert.AreEqual(12, 13, "Expected Failure (Integer)"); + Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); + } + + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void ExpectAnException() + { + throw new InvalidCastException(); + } + + [Test] + [Ignore("ignored test")] + public void IgnoredTest() + { + throw new Exception(); + } + } +}
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/failures/cs-failures.build b/tools/NUnit/samples/csharp/failures/cs-failures.build new file mode 100644 index 0000000..ea71419 --- /dev/null +++ b/tools/NUnit/samples/csharp/failures/cs-failures.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="cs-failures" default="build"> + + <include buildfile="../../samples.common"/> + + <patternset id="source-files"> + <include name="AssemblyInfo.cs" /> + <include name="CSharpTest.cs" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/failures/cs-failures.csproj b/tools/NUnit/samples/csharp/failures/cs-failures.csproj new file mode 100644 index 0000000..e66e6d4 --- /dev/null +++ b/tools/NUnit/samples/csharp/failures/cs-failures.csproj @@ -0,0 +1,20 @@ +<VisualStudioProject> + <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{15D66EEE-A852-4A52-89C2-83E74ECF3770}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="cs-failures" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="csharp_sample" RunPostBuildEvent="OnBuildSuccess" StartupObject=""> + <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="true" NoStdLib="false" NoWarn="" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + <Config Name="Release" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Release\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="CSharpTest.cs" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/money/AssemblyInfo.cs b/tools/NUnit/samples/csharp/money/AssemblyInfo.cs new file mode 100644 index 0000000..72a1771 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("2.2.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/NUnit/samples/csharp/money/IMoney.cs b/tools/NUnit/samples/csharp/money/IMoney.cs new file mode 100644 index 0000000..9b3fd35 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/IMoney.cs @@ -0,0 +1,37 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +namespace NUnit.Samples.Money +{ + + /// <summary>The common interface for simple Monies and MoneyBags.</summary> + interface IMoney + { + + /// <summary>Adds a money to this money.</summary> + IMoney Add(IMoney m); + + /// <summary>Adds a simple Money to this money. This is a helper method for + /// implementing double dispatch.</summary> + IMoney AddMoney(Money m); + + /// <summary>Adds a MoneyBag to this money. This is a helper method for + /// implementing double dispatch.</summary> + IMoney AddMoneyBag(MoneyBag s); + + /// <value>True if this money is zero.</value> + bool IsZero { get; } + + /// <summary>Multiplies a money by the given factor.</summary> + IMoney Multiply(int factor); + + /// <summary>Negates this money.</summary> + IMoney Negate(); + + /// <summary>Subtracts a money from this money.</summary> + IMoney Subtract(IMoney m); + } +} diff --git a/tools/NUnit/samples/csharp/money/Money.cs b/tools/NUnit/samples/csharp/money/Money.cs new file mode 100644 index 0000000..2e2de93 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/Money.cs @@ -0,0 +1,103 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +namespace NUnit.Samples.Money +{ + + using System; + using System.Text; + + /// <summary>A simple Money.</summary> + class Money: IMoney + { + + private int fAmount; + private String fCurrency; + + /// <summary>Constructs a money from the given amount and + /// currency.</summary> + public Money(int amount, String currency) + { + fAmount= amount; + fCurrency= currency; + } + + /// <summary>Adds a money to this money. Forwards the request to + /// the AddMoney helper.</summary> + public IMoney Add(IMoney m) + { + return m.AddMoney(this); + } + + public IMoney AddMoney(Money m) + { + if (m.Currency.Equals(Currency) ) + return new Money(Amount+m.Amount, Currency); + return new MoneyBag(this, m); + } + + public IMoney AddMoneyBag(MoneyBag s) + { + return s.AddMoney(this); + } + + public int Amount + { + get { return fAmount; } + } + + public String Currency + { + get { return fCurrency; } + } + + public override bool Equals(Object anObject) + { + if (IsZero) + if (anObject is IMoney) + return ((IMoney)anObject).IsZero; + if (anObject is Money) + { + Money aMoney= (Money)anObject; + return aMoney.Currency.Equals(Currency) + && Amount == aMoney.Amount; + } + return false; + } + + public override int GetHashCode() + { + return fCurrency.GetHashCode()+fAmount; + } + + public bool IsZero + { + get { return Amount == 0; } + } + + public IMoney Multiply(int factor) + { + return new Money(Amount*factor, Currency); + } + + public IMoney Negate() + { + return new Money(-Amount, Currency); + } + + public IMoney Subtract(IMoney m) + { + return Add(m.Negate()); + } + + public override String ToString() + { + StringBuilder buffer = new StringBuilder(); + buffer.Append("["+Amount+" "+Currency+"]"); + return buffer.ToString(); + } + } +} diff --git a/tools/NUnit/samples/csharp/money/MoneyBag.cs b/tools/NUnit/samples/csharp/money/MoneyBag.cs new file mode 100644 index 0000000..45b9442 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/MoneyBag.cs @@ -0,0 +1,174 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +namespace NUnit.Samples.Money +{ + + using System; + using System.Collections; + using System.Text; + + /// <summary>A MoneyBag defers exchange rate conversions.</summary> + /// <remarks>For example adding + /// 12 Swiss Francs to 14 US Dollars is represented as a bag + /// containing the two Monies 12 CHF and 14 USD. Adding another + /// 10 Swiss francs gives a bag with 22 CHF and 14 USD. Due to + /// the deferred exchange rate conversion we can later value a + /// MoneyBag with different exchange rates. + /// + /// A MoneyBag is represented as a list of Monies and provides + /// different constructors to create a MoneyBag.</remarks> + class MoneyBag: IMoney + { + private ArrayList fMonies= new ArrayList(5); + + private MoneyBag() + { + } + public MoneyBag(Money[] bag) + { + for (int i= 0; i < bag.Length; i++) + { + if (!bag[i].IsZero) + AppendMoney(bag[i]); + } + } + public MoneyBag(Money m1, Money m2) + { + AppendMoney(m1); + AppendMoney(m2); + } + public MoneyBag(Money m, MoneyBag bag) + { + AppendMoney(m); + AppendBag(bag); + } + public MoneyBag(MoneyBag m1, MoneyBag m2) + { + AppendBag(m1); + AppendBag(m2); + } + public IMoney Add(IMoney m) + { + return m.AddMoneyBag(this); + } + public IMoney AddMoney(Money m) + { + return (new MoneyBag(m, this)).Simplify(); + } + public IMoney AddMoneyBag(MoneyBag s) + { + return (new MoneyBag(s, this)).Simplify(); + } + private void AppendBag(MoneyBag aBag) + { + foreach (Money m in aBag.fMonies) + AppendMoney(m); + } + private void AppendMoney(Money aMoney) + { + IMoney old= FindMoney(aMoney.Currency); + if (old == null) + { + fMonies.Add(aMoney); + return; + } + fMonies.Remove(old); + IMoney sum= old.Add(aMoney); + if (sum.IsZero) + return; + fMonies.Add(sum); + } + private bool Contains(Money aMoney) + { + Money m= FindMoney(aMoney.Currency); + return m.Amount == aMoney.Amount; + } + public override bool Equals(Object anObject) + { + if (IsZero) + if (anObject is IMoney) + return ((IMoney)anObject).IsZero; + + if (anObject is MoneyBag) + { + MoneyBag aMoneyBag= (MoneyBag)anObject; + if (aMoneyBag.fMonies.Count != fMonies.Count) + return false; + + foreach (Money m in fMonies) + { + if (!aMoneyBag.Contains(m)) + return false; + } + return true; + } + return false; + } + private Money FindMoney(String currency) + { + foreach (Money m in fMonies) + { + if (m.Currency.Equals(currency)) + return m; + } + return null; + } + public override int GetHashCode() + { + int hash= 0; + foreach (Money m in fMonies) + { + hash^= m.GetHashCode(); + } + return hash; + } + public bool IsZero + { + get { return fMonies.Count == 0; } + } + public IMoney Multiply(int factor) + { + MoneyBag result= new MoneyBag(); + if (factor != 0) + { + foreach (Money m in fMonies) + { + result.AppendMoney((Money)m.Multiply(factor)); + } + } + return result; + } + public IMoney Negate() + { + MoneyBag result= new MoneyBag(); + foreach (Money m in fMonies) + { + result.AppendMoney((Money)m.Negate()); + } + return result; + } + private IMoney Simplify() + { + if (fMonies.Count == 1) + return (IMoney)fMonies[0]; + return this; + } + public IMoney Subtract(IMoney m) + { + return Add(m.Negate()); + } + public override String ToString() + { + StringBuilder buffer = new StringBuilder(); + buffer.Append("{"); + foreach (Money m in fMonies) + buffer.Append(m); + buffer.Append("}"); + return buffer.ToString(); + } + } +} diff --git a/tools/NUnit/samples/csharp/money/MoneyTest.cs b/tools/NUnit/samples/csharp/money/MoneyTest.cs new file mode 100644 index 0000000..603dcf8 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/MoneyTest.cs @@ -0,0 +1,321 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +namespace NUnit.Samples.Money +{ + using System; + using NUnit.Framework; + /// <summary> + /// + /// </summary> + /// + [TestFixture] + public class MoneyTest + { + private Money f12CHF; + private Money f14CHF; + private Money f7USD; + private Money f21USD; + + private MoneyBag fMB1; + private MoneyBag fMB2; + + /// <summary> + /// + /// </summary> + /// + [SetUp] + protected void SetUp() + { + f12CHF= new Money(12, "CHF"); + f14CHF= new Money(14, "CHF"); + f7USD= new Money( 7, "USD"); + f21USD= new Money(21, "USD"); + + fMB1= new MoneyBag(f12CHF, f7USD); + fMB2= new MoneyBag(f14CHF, f21USD); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void BagMultiply() + { + // {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]} + Money[] bag = { new Money(24, "CHF"), new Money(14, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, fMB1.Multiply(2)); + Assert.AreEqual(fMB1, fMB1.Multiply(1)); + Assert.IsTrue(fMB1.Multiply(0).IsZero); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void BagNegate() + { + // {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]} + Money[] bag= { new Money(-12, "CHF"), new Money(-7, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, fMB1.Negate()); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void BagSimpleAdd() + { + // {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]} + Money[] bag= { new Money(26, "CHF"), new Money(7, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, fMB1.Add(f14CHF)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void BagSubtract() + { + // {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]} + Money[] bag= { new Money(-2, "CHF"), new Money(-14, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, fMB1.Subtract(fMB2)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void BagSumAdd() + { + // {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]} + Money[] bag= { new Money(26, "CHF"), new Money(28, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, fMB1.Add(fMB2)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void IsZero() + { + Assert.IsTrue(fMB1.Subtract(fMB1).IsZero); + + Money[] bag = { new Money(0, "CHF"), new Money(0, "USD") }; + Assert.IsTrue(new MoneyBag(bag).IsZero); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void MixedSimpleAdd() + { + // [12 CHF] + [7 USD] == {[12 CHF][7 USD]} + Money[] bag= { f12CHF, f7USD }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, f12CHF.Add(f7USD)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void MoneyBagEquals() + { + //NOTE: Normally we use Assert.AreEqual to test whether two + // objects are equal. But here we are testing the MoneyBag.Equals() + // method itself, so using AreEqual would not serve the purpose. + Assert.IsFalse(fMB1.Equals(null)); + + Assert.IsTrue(fMB1.Equals( fMB1 )); + MoneyBag equal= new MoneyBag(new Money(12, "CHF"), new Money(7, "USD")); + Assert.IsTrue(fMB1.Equals(equal)); + Assert.IsTrue(!fMB1.Equals(f12CHF)); + Assert.IsTrue(!f12CHF.Equals(fMB1)); + Assert.IsTrue(!fMB1.Equals(fMB2)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void MoneyBagHash() + { + MoneyBag equal= new MoneyBag(new Money(12, "CHF"), new Money(7, "USD")); + Assert.AreEqual(fMB1.GetHashCode(), equal.GetHashCode()); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void MoneyEquals() + { + //NOTE: Normally we use Assert.AreEqual to test whether two + // objects are equal. But here we are testing the MoneyBag.Equals() + // method itself, so using AreEqual would not serve the purpose. + Assert.IsFalse(f12CHF.Equals(null)); + Money equalMoney= new Money(12, "CHF"); + Assert.IsTrue(f12CHF.Equals( f12CHF )); + Assert.IsTrue(f12CHF.Equals( equalMoney )); + Assert.IsFalse(f12CHF.Equals(f14CHF)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void MoneyHash() + { + Assert.IsFalse(f12CHF.Equals(null)); + Money equal= new Money(12, "CHF"); + Assert.AreEqual(f12CHF.GetHashCode(), equal.GetHashCode()); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void Normalize() + { + Money[] bag= { new Money(26, "CHF"), new Money(28, "CHF"), new Money(6, "CHF") }; + MoneyBag moneyBag= new MoneyBag(bag); + Money[] expected = { new Money(60, "CHF") }; + // note: expected is still a MoneyBag + MoneyBag expectedBag= new MoneyBag(expected); + Assert.AreEqual(expectedBag, moneyBag); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void Normalize2() + { + // {[12 CHF][7 USD]} - [12 CHF] == [7 USD] + Money expected= new Money(7, "USD"); + Assert.AreEqual(expected, fMB1.Subtract(f12CHF)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void Normalize3() + { + // {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD] + Money[] s1 = { new Money(12, "CHF"), new Money(3, "USD") }; + MoneyBag ms1= new MoneyBag(s1); + Money expected= new Money(4, "USD"); + Assert.AreEqual(expected, fMB1.Subtract(ms1)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void Normalize4() + { + // [12 CHF] - {[12 CHF][3 USD]} == [-3 USD] + Money[] s1 = { new Money(12, "CHF"), new Money(3, "USD") }; + MoneyBag ms1= new MoneyBag(s1); + Money expected= new Money(-3, "USD"); + Assert.AreEqual(expected, f12CHF.Subtract(ms1)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void Print() + { + Assert.AreEqual("[12 CHF]", f12CHF.ToString()); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void SimpleAdd() + { + // [12 CHF] + [14 CHF] == [26 CHF] + Money expected= new Money(26, "CHF"); + Assert.AreEqual(expected, f12CHF.Add(f14CHF)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void SimpleBagAdd() + { + // [14 CHF] + {[12 CHF][7 USD]} == {[26 CHF][7 USD]} + Money[] bag= { new Money(26, "CHF"), new Money(7, "USD") }; + MoneyBag expected= new MoneyBag(bag); + Assert.AreEqual(expected, f14CHF.Add(fMB1)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void SimpleMultiply() + { + // [14 CHF] *2 == [28 CHF] + Money expected= new Money(28, "CHF"); + Assert.AreEqual(expected, f14CHF.Multiply(2)); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void SimpleNegate() + { + // [14 CHF] negate == [-14 CHF] + Money expected= new Money(-14, "CHF"); + Assert.AreEqual(expected, f14CHF.Negate()); + } + + /// <summary> + /// + /// </summary> + /// + [Test] + public void SimpleSubtract() + { + // [14 CHF] - [12 CHF] == [2 CHF] + Money expected= new Money(2, "CHF"); + Assert.AreEqual(expected, f14CHF.Subtract(f12CHF)); + } + } +}
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/money/cs-money.build b/tools/NUnit/samples/csharp/money/cs-money.build new file mode 100644 index 0000000..917d973 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/cs-money.build @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<project name="cs-money" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.cs" /> + <include name="IMoney.cs" /> + <include name="Money.cs" /> + <include name="MoneyBag.cs" /> + <include name="MoneyTest.cs" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/money/cs-money.csproj b/tools/NUnit/samples/csharp/money/cs-money.csproj new file mode 100644 index 0000000..1ccc7c9 --- /dev/null +++ b/tools/NUnit/samples/csharp/money/cs-money.csproj @@ -0,0 +1,23 @@ +<VisualStudioProject> + <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{11EDF872-A04D-4F75-A1BF-71168DC86AF3}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="cs-money" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="money" RunPostBuildEvent="OnBuildSuccess" StartupObject=""> + <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="true" NoStdLib="false" NoWarn="" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + <Config Name="Release" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Release\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="IMoney.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="Money.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="MoneyBag.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="MoneyTest.cs" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/syntax/AssemblyInfo.cs b/tools/NUnit/samples/csharp/syntax/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/tools/NUnit/samples/csharp/syntax/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/NUnit/samples/csharp/syntax/AssertSyntaxTests.cs b/tools/NUnit/samples/csharp/syntax/AssertSyntaxTests.cs new file mode 100644 index 0000000..b612580 --- /dev/null +++ b/tools/NUnit/samples/csharp/syntax/AssertSyntaxTests.cs @@ -0,0 +1,828 @@ +// **************************************************************** +// Copyright 2007, Charlie Poole +// This is free software licensed under the NUnit license. You may +// obtain a copy of the license at http://nunit.org/?p=license&r=2.4 +// **************************************************************** + +using System; +using System.Collections; +using NUnit.Framework.Constraints; + +namespace NUnit.Framework.Tests +{ + /// <summary> + /// This test fixture attempts to exercise all the syntactic + /// variations of Assert without getting into failures, errors + /// or corner cases. Thus, some of the tests may be duplicated + /// in other fixtures. + /// + /// Each test performs the same operations using the classic + /// syntax (if available) and the new syntax in both the + /// helper-based and inherited forms. + /// + /// This Fixture will eventually be duplicated in other + /// supported languages. + /// </summary> + [TestFixture] + public class AssertSyntaxTests : AssertionHelper + { + #region Simple Constraint Tests + [Test] + public void IsNull() + { + object nada = null; + + // Classic syntax + Assert.IsNull(nada); + + // Helper syntax + Assert.That(nada, Is.Null); + + // Inherited syntax + Expect(nada, Null); + } + + [Test] + public void IsNotNull() + { + // Classic syntax + Assert.IsNotNull(42); + + // Helper syntax + Assert.That(42, Is.Not.Null); + + // Inherited syntax + Expect( 42, Not.Null ); + } + + [Test] + public void IsTrue() + { + // Classic syntax + Assert.IsTrue(2+2==4); + + // Helper syntax + Assert.That(2+2==4, Is.True); + Assert.That(2+2==4); + + // Inherited syntax + Expect(2+2==4, True); + Expect(2+2==4); + } + + [Test] + public void IsFalse() + { + // Classic syntax + Assert.IsFalse(2+2==5); + + // Helper syntax + Assert.That(2+2== 5, Is.False); + + // Inherited syntax + Expect(2+2==5, False); + } + + [Test] + public void IsNaN() + { + double d = double.NaN; + float f = float.NaN; + + // Classic syntax + Assert.IsNaN(d); + Assert.IsNaN(f); + + // Helper syntax + Assert.That(d, Is.NaN); + Assert.That(f, Is.NaN); + + // Inherited syntax + Expect(d, NaN); + Expect(f, NaN); + } + + [Test] + public void EmptyStringTests() + { + // Classic syntax + Assert.IsEmpty(""); + Assert.IsNotEmpty("Hello!"); + + // Helper syntax + Assert.That("", Is.Empty); + Assert.That("Hello!", Is.Not.Empty); + + // Inherited syntax + Expect("", Empty); + Expect("Hello!", Not.Empty); + } + + [Test] + public void EmptyCollectionTests() + { + // Classic syntax + Assert.IsEmpty(new bool[0]); + Assert.IsNotEmpty(new int[] { 1, 2, 3 }); + + // Helper syntax + Assert.That(new bool[0], Is.Empty); + Assert.That(new int[] { 1, 2, 3 }, Is.Not.Empty); + + // Inherited syntax + Expect(new bool[0], Empty); + Expect(new int[] { 1, 2, 3 }, Not.Empty); + } + #endregion + + #region TypeConstraint Tests + [Test] + public void ExactTypeTests() + { + // Classic syntax workarounds + 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); + + // Helper syntax + Assert.That("Hello", Is.TypeOf(typeof(string))); + Assert.That("Hello", Is.Not.TypeOf(typeof(int))); + + // Inherited syntax + Expect( "Hello", TypeOf(typeof(string))); + Expect( "Hello", Not.TypeOf(typeof(int))); + } + + [Test] + public void InstanceOfTypeTests() + { + // Classic syntax + Assert.IsInstanceOf(typeof(string), "Hello"); + Assert.IsNotInstanceOf(typeof(string), 5); + + // Helper syntax + Assert.That("Hello", Is.InstanceOf(typeof(string))); + Assert.That(5, Is.Not.InstanceOf(typeof(string))); + + // Inherited syntax + Expect("Hello", InstanceOf(typeof(string))); + Expect(5, Not.InstanceOf(typeof(string))); + } + + [Test] + public void AssignableFromTypeTests() + { + // Classic syntax + Assert.IsAssignableFrom(typeof(string), "Hello"); + Assert.IsNotAssignableFrom(typeof(string), 5); + + // Helper syntax + Assert.That( "Hello", Is.AssignableFrom(typeof(string))); + Assert.That( 5, Is.Not.AssignableFrom(typeof(string))); + + // Inherited syntax + Expect( "Hello", AssignableFrom(typeof(string))); + Expect( 5, Not.AssignableFrom(typeof(string))); + } + #endregion + + #region StringConstraint Tests + [Test] + public void SubstringTests() + { + string phrase = "Hello World!"; + string[] array = new string[] { "abc", "bad", "dba" }; + + // Classic Syntax + StringAssert.Contains("World", phrase); + + // Helper syntax + Assert.That(phrase, Text.Contains("World")); + // Only available using new syntax + Assert.That(phrase, Text.DoesNotContain("goodbye")); + Assert.That(phrase, Text.Contains("WORLD").IgnoreCase); + Assert.That(phrase, Text.DoesNotContain("BYE").IgnoreCase); + Assert.That(array, Text.All.Contains( "b" ) ); + + // Inherited syntax + Expect(phrase, Contains("World")); + // Only available using new syntax + Expect(phrase, Not.Contains("goodbye")); + Expect(phrase, Contains("WORLD").IgnoreCase); + Expect(phrase, Not.Contains("BYE").IgnoreCase); + Expect(array, All.Contains("b")); + } + + [Test] + public void StartsWithTests() + { + string phrase = "Hello World!"; + string[] greetings = new string[] { "Hello!", "Hi!", "Hola!" }; + + // Classic syntax + StringAssert.StartsWith("Hello", phrase); + + // Helper syntax + Assert.That(phrase, Text.StartsWith("Hello")); + // Only available using new syntax + Assert.That(phrase, Text.DoesNotStartWith("Hi!")); + Assert.That(phrase, Text.StartsWith("HeLLo").IgnoreCase); + Assert.That(phrase, Text.DoesNotStartWith("HI").IgnoreCase); + Assert.That(greetings, Text.All.StartsWith("h").IgnoreCase); + + // Inherited syntax + Expect(phrase, StartsWith("Hello")); + // Only available using new syntax + Expect(phrase, Not.StartsWith("Hi!")); + Expect(phrase, StartsWith("HeLLo").IgnoreCase); + Expect(phrase, Not.StartsWith("HI").IgnoreCase); + Expect(greetings, All.StartsWith("h").IgnoreCase); + } + + [Test] + public void EndsWithTests() + { + string phrase = "Hello World!"; + string[] greetings = new string[] { "Hello!", "Hi!", "Hola!" }; + + // Classic Syntax + StringAssert.EndsWith("!", phrase); + + // Helper syntax + Assert.That(phrase, Text.EndsWith("!")); + // Only available using new syntax + Assert.That(phrase, Text.DoesNotEndWith("?")); + Assert.That(phrase, Text.EndsWith("WORLD!").IgnoreCase); + Assert.That(greetings, Text.All.EndsWith("!")); + + // Inherited syntax + Expect(phrase, EndsWith("!")); + // Only available using new syntax + Expect(phrase, Not.EndsWith("?")); + Expect(phrase, EndsWith("WORLD!").IgnoreCase); + Expect(greetings, All.EndsWith("!") ); + } + + [Test] + public void EqualIgnoringCaseTests() + { + string phrase = "Hello World!"; + + // Classic syntax + StringAssert.AreEqualIgnoringCase("hello world!",phrase); + + // Helper syntax + Assert.That(phrase, Is.EqualTo("hello world!").IgnoreCase); + //Only available using new syntax + Assert.That(phrase, Is.Not.EqualTo("goodbye world!").IgnoreCase); + Assert.That(new string[] { "Hello", "World" }, + Is.EqualTo(new object[] { "HELLO", "WORLD" }).IgnoreCase); + Assert.That(new string[] {"HELLO", "Hello", "hello" }, + Is.All.EqualTo( "hello" ).IgnoreCase); + + // Inherited syntax + Expect(phrase, EqualTo("hello world!").IgnoreCase); + //Only available using new syntax + Expect(phrase, Not.EqualTo("goodbye world!").IgnoreCase); + Expect(new string[] { "Hello", "World" }, + EqualTo(new object[] { "HELLO", "WORLD" }).IgnoreCase); + Expect(new string[] {"HELLO", "Hello", "hello" }, + All.EqualTo( "hello" ).IgnoreCase); + } + + [Test] + public void RegularExpressionTests() + { + string phrase = "Now is the time for all good men to come to the aid of their country."; + string[] quotes = new string[] { "Never say never", "It's never too late", "Nevermore!" }; + + // Classic syntax + StringAssert.IsMatch( "all good men", phrase ); + StringAssert.IsMatch( "Now.*come", phrase ); + + // Helper syntax + Assert.That( phrase, Text.Matches( "all good men" ) ); + Assert.That( phrase, Text.Matches( "Now.*come" ) ); + // Only available using new syntax + Assert.That(phrase, Text.DoesNotMatch("all.*men.*good")); + Assert.That(phrase, Text.Matches("ALL").IgnoreCase); + Assert.That(quotes, Text.All.Matches("never").IgnoreCase); + + // Inherited syntax + Expect( phrase, Matches( "all good men" ) ); + Expect( phrase, Matches( "Now.*come" ) ); + // Only available using new syntax + Expect(phrase, Not.Matches("all.*men.*good")); + Expect(phrase, Matches("ALL").IgnoreCase); + Expect(quotes, All.Matches("never").IgnoreCase); + } + #endregion + + #region Equality Tests + [Test] + public void EqualityTests() + { + int[] i3 = new int[] { 1, 2, 3 }; + double[] d3 = new double[] { 1.0, 2.0, 3.0 }; + int[] iunequal = new int[] { 1, 3, 2 }; + + // Classic Syntax + Assert.AreEqual(4, 2 + 2); + Assert.AreEqual(i3, d3); + Assert.AreNotEqual(5, 2 + 2); + Assert.AreNotEqual(i3, iunequal); + + // Helper syntax + Assert.That(2 + 2, Is.EqualTo(4)); + Assert.That(2 + 2 == 4); + Assert.That(i3, Is.EqualTo(d3)); + Assert.That(2 + 2, Is.Not.EqualTo(5)); + Assert.That(i3, Is.Not.EqualTo(iunequal)); + + // Inherited syntax + Expect(2 + 2, EqualTo(4)); + Expect(2 + 2 == 4); + Expect(i3, EqualTo(d3)); + Expect(2 + 2, Not.EqualTo(5)); + Expect(i3, Not.EqualTo(iunequal)); + } + + [Test] + public void EqualityTestsWithTolerance() + { + // CLassic syntax + Assert.AreEqual(5.0d, 4.99d, 0.05d); + Assert.AreEqual(5.0f, 4.99f, 0.05f); + + // Helper syntax + Assert.That(4.99d, Is.EqualTo(5.0d).Within(0.05d)); + Assert.That(4.0d, Is.Not.EqualTo(5.0d).Within(0.5d)); + Assert.That(4.99f, Is.EqualTo(5.0f).Within(0.05f)); + Assert.That(4.99m, Is.EqualTo(5.0m).Within(0.05m)); + Assert.That(3999999999u, Is.EqualTo(4000000000u).Within(5u)); + Assert.That(499, Is.EqualTo(500).Within(5)); + Assert.That(4999999999L, Is.EqualTo(5000000000L).Within(5L)); + Assert.That(5999999999ul, Is.EqualTo(6000000000ul).Within(5ul)); + + // Inherited syntax + Expect(4.99d, EqualTo(5.0d).Within(0.05d)); + Expect(4.0d, Not.EqualTo(5.0d).Within(0.5d)); + Expect(4.99f, EqualTo(5.0f).Within(0.05f)); + Expect(4.99m, EqualTo(5.0m).Within(0.05m)); + Expect(499u, EqualTo(500u).Within(5u)); + Expect(499, EqualTo(500).Within(5)); + Expect(4999999999L, EqualTo(5000000000L).Within(5L)); + Expect(5999999999ul, EqualTo(6000000000ul).Within(5ul)); + } + + [Test] + public void EqualityTestsWithTolerance_MixedFloatAndDouble() + { + // Bug Fix 1743844 + Assert.That(2.20492d, Is.EqualTo(2.2d).Within(0.01f), + "Double actual, Double expected, Single tolerance"); + Assert.That(2.20492d, Is.EqualTo(2.2f).Within(0.01d), + "Double actual, Single expected, Double tolerance" ); + Assert.That(2.20492d, Is.EqualTo(2.2f).Within(0.01f), + "Double actual, Single expected, Single tolerance" ); + Assert.That(2.20492f, Is.EqualTo(2.2f).Within(0.01d), + "Single actual, Single expected, Double tolerance"); + Assert.That(2.20492f, Is.EqualTo(2.2d).Within(0.01d), + "Single actual, Double expected, Double tolerance"); + Assert.That(2.20492f, Is.EqualTo(2.2d).Within(0.01f), + "Single actual, Double expected, Single tolerance"); + } + + [Test] + public void EqualityTestsWithTolerance_MixingTypesGenerally() + { + // Extending tolerance to all numeric types + Assert.That(202d, Is.EqualTo(200d).Within(2), + "Double actual, Double expected, int tolerance"); + Assert.That( 4.87m, Is.EqualTo(5).Within(.25), + "Decimal actual, int expected, Double tolerance" ); + Assert.That( 4.87m, Is.EqualTo(5ul).Within(1), + "Decimal actual, ulong expected, int tolerance" ); + Assert.That( 487, Is.EqualTo(500).Within(25), + "int actual, int expected, int tolerance" ); + Assert.That( 487u, Is.EqualTo(500).Within(25), + "uint actual, int expected, int tolerance" ); + Assert.That( 487L, Is.EqualTo(500).Within(25), + "long actual, int expected, int tolerance" ); + Assert.That( 487ul, Is.EqualTo(500).Within(25), + "ulong actual, int expected, int tolerance" ); + } + #endregion + + #region Comparison Tests + [Test] + public void ComparisonTests() + { + // Classic Syntax + Assert.Greater(7, 3); + Assert.GreaterOrEqual(7, 3); + Assert.GreaterOrEqual(7, 7); + + // Helper syntax + Assert.That(7, Is.GreaterThan(3)); + Assert.That(7, Is.GreaterThanOrEqualTo(3)); + Assert.That(7, Is.AtLeast(3)); + Assert.That(7, Is.GreaterThanOrEqualTo(7)); + Assert.That(7, Is.AtLeast(7)); + + // Inherited syntax + Expect(7, GreaterThan(3)); + Expect(7, GreaterThanOrEqualTo(3)); + Expect(7, AtLeast(3)); + Expect(7, GreaterThanOrEqualTo(7)); + Expect(7, AtLeast(7)); + + // Classic syntax + Assert.Less(3, 7); + Assert.LessOrEqual(3, 7); + Assert.LessOrEqual(3, 3); + + // Helper syntax + Assert.That(3, Is.LessThan(7)); + Assert.That(3, Is.LessThanOrEqualTo(7)); + Assert.That(3, Is.AtMost(7)); + Assert.That(3, Is.LessThanOrEqualTo(3)); + Assert.That(3, Is.AtMost(3)); + + // Inherited syntax + Expect(3, LessThan(7)); + Expect(3, LessThanOrEqualTo(7)); + Expect(3, AtMost(7)); + Expect(3, LessThanOrEqualTo(3)); + Expect(3, AtMost(3)); + } + #endregion + + #region Collection Tests + [Test] + public void AllItemsTests() + { + object[] ints = new object[] { 1, 2, 3, 4 }; + object[] doubles = new object[] { 0.99, 2.1, 3.0, 4.05 }; + object[] strings = new object[] { "abc", "bad", "cab", "bad", "dad" }; + + // Classic syntax + CollectionAssert.AllItemsAreNotNull(ints); + CollectionAssert.AllItemsAreInstancesOfType(ints, typeof(int)); + CollectionAssert.AllItemsAreInstancesOfType(strings, typeof(string)); + CollectionAssert.AllItemsAreUnique(ints); + + // Helper syntax + Assert.That(ints, Is.All.Not.Null); + Assert.That(ints, Has.None.Null); + Assert.That(ints, Is.All.InstanceOfType(typeof(int))); + Assert.That(ints, Has.All.InstanceOfType(typeof(int))); + Assert.That(strings, Is.All.InstanceOfType(typeof(string))); + Assert.That(strings, Has.All.InstanceOfType(typeof(string))); + Assert.That(ints, Is.Unique); + // Only available using new syntax + Assert.That(strings, Is.Not.Unique); + Assert.That(ints, Is.All.GreaterThan(0)); + Assert.That(ints, Has.All.GreaterThan(0)); + Assert.That(ints, Has.None.LessThanOrEqualTo(0)); + Assert.That(strings, Text.All.Contains( "a" ) ); + Assert.That(strings, Has.All.Contains( "a" ) ); + Assert.That(strings, Has.Some.StartsWith( "ba" ) ); + Assert.That( strings, Has.Some.Property( "Length" ).EqualTo( 3 ) ); + Assert.That( strings, Has.Some.StartsWith( "BA" ).IgnoreCase ); + Assert.That( doubles, Has.Some.EqualTo( 1.0 ).Within( .05 ) ); + + // Inherited syntax + Expect(ints, All.Not.Null); + Expect(ints, None.Null); + Expect(ints, All.InstanceOfType(typeof(int))); + Expect(strings, All.InstanceOfType(typeof(string))); + Expect(ints, Unique); + // Only available using new syntax + Expect(strings, Not.Unique); + Expect(ints, All.GreaterThan(0)); + Expect(ints, None.LessThanOrEqualTo(0)); + Expect(strings, All.Contains( "a" ) ); + Expect(strings, Some.StartsWith( "ba" ) ); + Expect(strings, Some.StartsWith( "BA" ).IgnoreCase ); + Expect(doubles, Some.EqualTo( 1.0 ).Within( .05 ) ); + } + + [Test] + public void SomeItemTests() + { + object[] mixed = new object[] { 1, 2, "3", null, "four", 100 }; + object[] strings = new object[] { "abc", "bad", "cab", "bad", "dad" }; + + // Not available using the classic syntax + + // Helper syntax + Assert.That(mixed, Has.Some.Null); + Assert.That(mixed, Has.Some.InstanceOfType(typeof(int))); + Assert.That(mixed, Has.Some.InstanceOfType(typeof(string))); + Assert.That(strings, Has.Some.StartsWith( "ba" ) ); + Assert.That(strings, Has.Some.Not.StartsWith( "ba" ) ); + + // Inherited syntax + Expect(mixed, Some.Null); + Expect(mixed, Some.InstanceOfType(typeof(int))); + Expect(mixed, Some.InstanceOfType(typeof(string))); + Expect(strings, Some.StartsWith( "ba" ) ); + Expect(strings, Some.Not.StartsWith( "ba" ) ); + } + + [Test] + public void NoItemTests() + { + object[] ints = new object[] { 1, 2, 3, 4, 5 }; + object[] strings = new object[] { "abc", "bad", "cab", "bad", "dad" }; + + // Not available using the classic syntax + + // Helper syntax + Assert.That(ints, Has.None.Null); + Assert.That(ints, Has.None.InstanceOfType(typeof(string))); + Assert.That(ints, Has.None.GreaterThan(99)); + Assert.That(strings, Has.None.StartsWith( "qu" ) ); + + // Inherited syntax + Expect(ints, None.Null); + Expect(ints, None.InstanceOfType(typeof(string))); + Expect(ints, None.GreaterThan(99)); + Expect(strings, None.StartsWith( "qu" ) ); + } + + [Test] + public void CollectionContainsTests() + { + int[] iarray = new int[] { 1, 2, 3 }; + string[] sarray = new string[] { "a", "b", "c" }; + + // Classic syntax + 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 ); + + // Helper syntax + Assert.That(iarray, Has.Member(3)); + Assert.That(sarray, Has.Member("b")); + Assert.That(sarray, Has.No.Member("x")); + // Showing that Contains uses NUnit equality + Assert.That(iarray, Has.Member( 1.0d )); + + // Only available using the new syntax + // Note that EqualTo and SameAs do NOT give + // identical results to Contains because + // Contains uses Object.Equals() + Assert.That(iarray, Has.Some.EqualTo(3)); + 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)); + + // Inherited syntax + Expect(iarray, Contains(3)); + Expect(sarray, Contains("b")); + Expect(sarray, Not.Contains("x")); + + // Only available using new syntax + // Note that EqualTo and SameAs do NOT give + // identical results to Contains because + // Contains uses Object.Equals() + Expect(iarray, Some.EqualTo(3)); + Expect(sarray, Some.EqualTo("b")); + Expect(sarray, None.EqualTo("x")); + Expect(iarray, All.LessThan(10)); + Expect(sarray, All.Length.EqualTo(1)); + Expect(sarray, None.Property("Length").GreaterThan(3)); + } + + [Test] + public void CollectionEquivalenceTests() + { + int[] ints1to5 = new int[] { 1, 2, 3, 4, 5 }; + int[] twothrees = new int[] { 1, 2, 3, 3, 4, 5 }; + int[] twofours = new int[] { 1, 2, 3, 4, 4, 5 }; + + // Classic syntax + CollectionAssert.AreEquivalent(new int[] { 2, 1, 4, 3, 5 }, ints1to5); + CollectionAssert.AreNotEquivalent(new int[] { 2, 2, 4, 3, 5 }, ints1to5); + CollectionAssert.AreNotEquivalent(new int[] { 2, 4, 3, 5 }, ints1to5); + CollectionAssert.AreNotEquivalent(new int[] { 2, 2, 1, 1, 4, 3, 5 }, ints1to5); + CollectionAssert.AreNotEquivalent(twothrees, twofours); + + // Helper syntax + Assert.That(new int[] { 2, 1, 4, 3, 5 }, Is.EquivalentTo(ints1to5)); + Assert.That(new int[] { 2, 2, 4, 3, 5 }, Is.Not.EquivalentTo(ints1to5)); + Assert.That(new int[] { 2, 4, 3, 5 }, Is.Not.EquivalentTo(ints1to5)); + Assert.That(new int[] { 2, 2, 1, 1, 4, 3, 5 }, Is.Not.EquivalentTo(ints1to5)); + + // Inherited syntax + Expect(new int[] { 2, 1, 4, 3, 5 }, EquivalentTo(ints1to5)); + Expect(new int[] { 2, 2, 4, 3, 5 }, Not.EquivalentTo(ints1to5)); + Expect(new int[] { 2, 4, 3, 5 }, Not.EquivalentTo(ints1to5)); + Expect(new int[] { 2, 2, 1, 1, 4, 3, 5 }, Not.EquivalentTo(ints1to5)); + } + + [Test] + public void SubsetTests() + { + int[] ints1to5 = new int[] { 1, 2, 3, 4, 5 }; + + // Classic syntax + CollectionAssert.IsSubsetOf(new int[] { 1, 3, 5 }, ints1to5); + CollectionAssert.IsSubsetOf(new int[] { 1, 2, 3, 4, 5 }, ints1to5); + CollectionAssert.IsNotSubsetOf(new int[] { 2, 4, 6 }, ints1to5); + CollectionAssert.IsNotSubsetOf(new int[] { 1, 2, 2, 2, 5 }, ints1to5); + + // Helper syntax + Assert.That(new int[] { 1, 3, 5 }, Is.SubsetOf(ints1to5)); + Assert.That(new int[] { 1, 2, 3, 4, 5 }, Is.SubsetOf(ints1to5)); + Assert.That(new int[] { 2, 4, 6 }, Is.Not.SubsetOf(ints1to5)); + + // Inherited syntax + Expect(new int[] { 1, 3, 5 }, SubsetOf(ints1to5)); + Expect(new int[] { 1, 2, 3, 4, 5 }, SubsetOf(ints1to5)); + Expect(new int[] { 2, 4, 6 }, Not.SubsetOf(ints1to5)); + } + #endregion + + #region Property Tests + [Test] + public void PropertyTests() + { + string[] array = { "abc", "bca", "xyz", "qrs" }; + string[] array2 = { "a", "ab", "abc" }; + ArrayList list = new ArrayList( array ); + + // Not available using the classic syntax + + // Helper syntax + Assert.That( list, Has.Property( "Count" ) ); + Assert.That( list, Has.No.Property( "Length" ) ); + + Assert.That( "Hello", Has.Length.EqualTo( 5 ) ); + Assert.That( "Hello", Has.Length.LessThan( 10 ) ); + Assert.That( "Hello", Has.Property("Length").EqualTo(5) ); + Assert.That( "Hello", Has.Property("Length").GreaterThan(3) ); + + Assert.That( array, Has.Property( "Length" ).EqualTo( 4 ) ); + Assert.That( array, Has.Length.EqualTo( 4 ) ); + Assert.That( array, Has.Property( "Length" ).LessThan( 10 ) ); + + Assert.That( array, Has.All.Property("Length").EqualTo(3) ); + Assert.That( array, Has.All.Length.EqualTo( 3 ) ); + Assert.That( array, Is.All.Length.EqualTo( 3 ) ); + Assert.That( array, Has.All.Property("Length").EqualTo(3) ); + Assert.That( array, Is.All.Property("Length").EqualTo(3) ); + + Assert.That( array2, Has.Some.Property("Length").EqualTo(2) ); + Assert.That( array2, Has.Some.Length.EqualTo(2) ); + Assert.That( array2, Has.Some.Property("Length").GreaterThan(2) ); + + Assert.That( array2, Is.Not.Property("Length").EqualTo(4) ); + Assert.That( array2, Is.Not.Length.EqualTo( 4 ) ); + Assert.That( array2, Has.No.Property("Length").GreaterThan(3) ); + + Assert.That( List.Map( array2 ).Property("Length"), Is.EqualTo( new int[] { 1, 2, 3 } ) ); + Assert.That( List.Map( array2 ).Property("Length"), Is.EquivalentTo( new int[] { 3, 2, 1 } ) ); + Assert.That( List.Map( array2 ).Property("Length"), Is.SubsetOf( new int[] { 1, 2, 3, 4, 5 } ) ); + Assert.That( List.Map( array2 ).Property("Length"), Is.Unique ); + + Assert.That( list, Has.Count.EqualTo( 4 ) ); + + // Inherited syntax + Expect( list, Property( "Count" ) ); + Expect( list, Not.Property( "Nada" ) ); + + Expect( "Hello", Length.EqualTo( 5 ) ); + Expect( "Hello", Property("Length").EqualTo(5) ); + Expect( "Hello", Property("Length").GreaterThan(0) ); + + Expect( array, Property("Length").EqualTo(4) ); + Expect( array, Length.EqualTo(4) ); + Expect( array, Property("Length").LessThan(10)); + + Expect( array, All.Length.EqualTo( 3 ) ); + Expect( array, All.Property("Length").EqualTo(3)); + + Expect( array2, Some.Property("Length").EqualTo(2) ); + Expect( array2, Some.Length.EqualTo( 2 ) ); + Expect( array2, Some.Property("Length").GreaterThan(2)); + + Expect( array2, None.Property("Length").EqualTo(4) ); + Expect( array2, None.Length.EqualTo( 4 ) ); + Expect( array2, None.Property("Length").GreaterThan(3)); + + Expect( Map( array2 ).Property("Length"), EqualTo( new int[] { 1, 2, 3 } ) ); + Expect( Map( array2 ).Property("Length"), EquivalentTo( new int[] { 3, 2, 1 } ) ); + Expect( Map( array2 ).Property("Length"), SubsetOf( new int[] { 1, 2, 3, 4, 5 } ) ); + Expect( Map( array2 ).Property("Length"), Unique ); + + Expect( list, Count.EqualTo( 4 ) ); + + } + #endregion + + #region Not Tests + [Test] + public void NotTests() + { + // Not available using the classic syntax + + // Helper syntax + Assert.That(42, Is.Not.Null); + Assert.That(42, Is.Not.True); + Assert.That(42, Is.Not.False); + Assert.That(2.5, Is.Not.NaN); + Assert.That(2 + 2, Is.Not.EqualTo(3)); + Assert.That(2 + 2, Is.Not.Not.EqualTo(4)); + Assert.That(2 + 2, Is.Not.Not.Not.EqualTo(5)); + + // Inherited syntax + Expect(42, Not.Null); + Expect(42, Not.True); + Expect(42, Not.False); + Expect(2.5, Not.NaN); + Expect(2 + 2, Not.EqualTo(3)); + Expect(2 + 2, Not.Not.EqualTo(4)); + Expect(2 + 2, Not.Not.Not.EqualTo(5)); + } + #endregion + + #region Operator Tests + [Test] + public void NotOperator() + { + // The ! operator is only available in the new syntax + Assert.That(42, !Is.Null); + // Inherited syntax + Expect( 42, !Null ); + } + + [Test] + public void AndOperator() + { + // The & operator is only available in the new syntax + Assert.That(7, Is.GreaterThan(5) & Is.LessThan(10)); + // Inherited syntax + Expect( 7, GreaterThan(5) & LessThan(10)); + } + + [Test] + public void OrOperator() + { + // The | operator is only available in the new syntax + Assert.That(3, Is.LessThan(5) | Is.GreaterThan(10)); + Expect( 3, LessThan(5) | GreaterThan(10)); + } + + [Test] + public void ComplexTests() + { + Assert.That(7, Is.Not.Null & Is.Not.LessThan(5) & Is.Not.GreaterThan(10)); + Expect(7, Not.Null & Not.LessThan(5) & Not.GreaterThan(10)); + + Assert.That(7, !Is.Null & !Is.LessThan(5) & !Is.GreaterThan(10)); + Expect(7, !Null & !LessThan(5) & !GreaterThan(10)); + + // TODO: Remove #if when mono compiler can handle null +#if MONO + Constraint x = null; + Assert.That(7, !x & !Is.LessThan(5) & !Is.GreaterThan(10)); + Expect(7, !x & !LessThan(5) & !GreaterThan(10)); +#else + Assert.That(7, !(Constraint)null & !Is.LessThan(5) & !Is.GreaterThan(10)); + Expect(7, !(Constraint)null & !LessThan(5) & !GreaterThan(10)); +#endif + } + #endregion + + #region Invalid Code Tests + // This method contains assertions that should not compile + // You can check by uncommenting it. + //public void WillNotCompile() + //{ + // Assert.That(42, Is.Not); + // Assert.That(42, Is.All); + // Assert.That(42, Is.Null.Not); + // Assert.That(42, Is.Not.Null.GreaterThan(10)); + // Assert.That(42, Is.GreaterThan(10).LessThan(99)); + + // object[] c = new object[0]; + // Assert.That(c, Is.Null.All); + // Assert.That(c, Is.Not.All); + // Assert.That(c, Is.All.Not); + //} + #endregion + } + +} diff --git a/tools/NUnit/samples/csharp/syntax/cs-syntax.build b/tools/NUnit/samples/csharp/syntax/cs-syntax.build new file mode 100644 index 0000000..c144588 --- /dev/null +++ b/tools/NUnit/samples/csharp/syntax/cs-syntax.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="cs-syntax" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.cs" /> + <include name="AssertSyntaxTests.cs" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/csharp/syntax/cs-syntax.csproj b/tools/NUnit/samples/csharp/syntax/cs-syntax.csproj new file mode 100644 index 0000000..b3970c7 --- /dev/null +++ b/tools/NUnit/samples/csharp/syntax/cs-syntax.csproj @@ -0,0 +1,20 @@ +<VisualStudioProject> + <CSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{06F46FA2-687B-4B46-A912-C1B0B4CC1B20}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="cs-syntax" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="cs_syntax" RunPostBuildEvent="OnBuildSuccess" StartupObject=""> + <Config Name="Debug" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DocumentationFile="" DebugSymbols="true" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + <Config Name="Release" AllowUnsafeBlocks="false" BaseAddress="285212672" CheckForOverflowUnderflow="false" ConfigurationOverrideFile="" DefineConstants="TRACE" DocumentationFile="" DebugSymbols="false" FileAlignment="4096" IncrementalBuild="false" NoStdLib="false" NoWarn="" Optimize="true" OutputPath="bin\Release\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="4" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.cs" SubType="Code" BuildAction="Compile" /> + <File RelPath="AssertSyntaxTests.cs" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/jsharp/failures/AssemblyInfo.jsl b/tools/NUnit/samples/jsharp/failures/AssemblyInfo.jsl new file mode 100644 index 0000000..5e4d026 --- /dev/null +++ b/tools/NUnit/samples/jsharp/failures/AssemblyInfo.jsl @@ -0,0 +1,58 @@ +import System.Reflection.*; +import System.Runtime.CompilerServices.*; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +/** @assembly AssemblyTitle("") */ +/** @assembly AssemblyDescription("") */ +/** @assembly AssemblyConfiguration("") */ +/** @assembly AssemblyCompany("") */ +/** @assembly AssemblyProduct("") */ +/** @assembly AssemblyCopyright("") */ +/** @assembly AssemblyTrademark("") */ +/** @assembly AssemblyCulture("") */ + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build +// Numbers by using the '*' as shown below: + +/** @assembly AssemblyVersion("2.2.0.0") */ + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project directory. For example, if your KeyFile is +// located in the project directory itself, you would specify the +// AssemblyKeyFile attribute as @assembly AssemblyKeyFile("mykey.snk") +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// + +/** @assembly AssemblyDelaySign(false) */ +/** @assembly AssemblyKeyFile("") */ +/** @assembly AssemblyKeyName("") */ diff --git a/tools/NUnit/samples/jsharp/failures/JSharpTest.jsl b/tools/NUnit/samples/jsharp/failures/JSharpTest.jsl new file mode 100644 index 0000000..5ae1c47 --- /dev/null +++ b/tools/NUnit/samples/jsharp/failures/JSharpTest.jsl @@ -0,0 +1,65 @@ +// **************************************************************** +// This is free software licensed under the NUnit license. You +// may obtain a copy of the license as well as information regarding +// copyright ownership at http://nunit.org/?p=license&r=2.4. +// **************************************************************** + +package NUnit.Samples; + +import System.*; +import NUnit.Framework.Assert; + +/** @attribute NUnit.Framework.TestFixture() */ +public class SimpleJSharpTest +{ + protected int fValue1; + protected int fValue2; + + /** @attribute NUnit.Framework.SetUp() */ + public void Init() + { + fValue1 = 2; + fValue2 = 3; + } + + /** @attribute NUnit.Framework.Test() */ + public void Add() + { + int result= fValue1 + fValue2; + Assert.AreEqual(6,result, "Expected Failure"); + } + + /** @attribute NUnit.Framework.Test() */ + public void DivideByZero() + { + int zero= 0; + int result = 8/zero; + KeepCompilerFromWarning(result); // never executed, here to avoid compiler warning that result is unused. + } + + /** @attribute NUnit.Framework.Test() */ + public void Equals() + { + Assert.AreEqual(12, 12, "Integer"); + Assert.AreEqual(new Long(12), new Long(13), "Long"); + Assert.AreEqual('a', 'a', "Char"); + Assert.AreEqual(new Integer(12), new Integer(12), "Integer Object Cast"); + + Assert.AreEqual(12, 13, "Expected Failure (Integer)"); + Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)."); + } + + /** @attribute NUnit.Framework.Test() */ + /** @attribute NUnit.Framework.Ignore("ignored test") */ + public void IgnoredTest() + { + throw new InvalidCastException(); + } + + // A useless function, designed to avoid a compiler warning in the the DivideByZero test. + private int KeepCompilerFromWarning(int dummy) + { + return dummy; + } + +}
\ No newline at end of file diff --git a/tools/NUnit/samples/jsharp/failures/jsharp-failures.build b/tools/NUnit/samples/jsharp/failures/jsharp-failures.build new file mode 100644 index 0000000..51f20da --- /dev/null +++ b/tools/NUnit/samples/jsharp/failures/jsharp-failures.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="jsharp-failures" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.jsl" /> + <include name="JSharpTest.jsl" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/jsharp/failures/jsharp-failures.vjsproj b/tools/NUnit/samples/jsharp/failures/jsharp-failures.vjsproj new file mode 100644 index 0000000..e12f5c4 --- /dev/null +++ b/tools/NUnit/samples/jsharp/failures/jsharp-failures.vjsproj @@ -0,0 +1,21 @@ +<VisualStudioProject> + <VISUALJSHARP ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{B55A6E53-57A9-4205-B396-C9983B3AF46A}"> + <Build> + <Settings AssemblyKeyContainerName="" AssemblyName="jsharp-failures" AssemblyOriginatorKeyFile="" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" OutputType="Library" PreBuildEvent="" PostBuildEvent="" RootNamespace="jsharp" RunPostBuildEvent="OnBuildSuccess" StartupObject=""> + <Config Name="Debug" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="DEBUG;TRACE" DebugSymbols="true" NoWarn="" Optimize="false" OutputPath="bin\Debug\" RegisterForComInterop="false" TreatWarningsAsErrors="false" WarningLevel="4" AdditionalOptions="" /> + <Config Name="Release" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="TRACE" DebugSymbols="false" NoWarn="" Optimize="true" OutputPath="bin\Release\" RegisterForComInterop="false" TreatWarningsAsErrors="false" WarningLevel="4" AdditionalOptions="" /> + </Settings> + <References> + <Reference Name="vjslib" AssemblyName="vjslib" /> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.jsl" SubType="Code" BuildAction="Compile" /> + <File RelPath="JSharpTest.jsl" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </VISUALJSHARP> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/jsharp/jsharp.sln b/tools/NUnit/samples/jsharp/jsharp.sln new file mode 100644 index 0000000..507fcc8 --- /dev/null +++ b/tools/NUnit/samples/jsharp/jsharp.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}") = "jsharp-failures", "failures\jsharp-failures.vjsproj", "{B55A6E53-57A9-4205-B396-C9983B3AF46A}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B55A6E53-57A9-4205-B396-C9983B3AF46A}.Debug.ActiveCfg = Debug|.NET + {B55A6E53-57A9-4205-B396-C9983B3AF46A}.Debug.Build.0 = Debug|.NET + {B55A6E53-57A9-4205-B396-C9983B3AF46A}.Release.ActiveCfg = Release|.NET + {B55A6E53-57A9-4205-B396-C9983B3AF46A}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/NUnit/samples/samples.common b/tools/NUnit/samples/samples.common new file mode 100644 index 0000000..c6cbdb1 --- /dev/null +++ b/tools/NUnit/samples/samples.common @@ -0,0 +1,308 @@ +<?xml version="1.0"?> +<project> + + <property name="project.base" value="${project::get-base-directory()}" /> + + <property name="samples.base" value="${path::get-full-path('../..')}" /> + <!-- Duplicate the following if more levels are added -->te + <property name="samples.base" value="${path::get-full-path('../../..')}" + unless="${path::get-file-name(samples.base)=='samples'}" /> + + <property name="output.dir" value="${samples.base}/bin" /> + + <property name="nunit.bin.dir" + value="${path::combine(path::get-directory-name(samples.base), 'bin')}" /> + <property name="nunit.framework.dll" + value="${path::combine(nunit.bin.dir,'net-1.1/framework/nunit.framework.dll')}" /> + <property name="nunit.core.dll" + value="${path::combine(nunit.bin.dir,'net-1.1/nunit.core.dll')}" /> + <property name="nunit.core.interfaces.dll" + value="${path::combine(nunit.bin.dir,'net-1.1/nunit.core.interfaces.dll')}" /> + + <property name="sample" value="${project::get-name()}" + unless="${property::exists('sample')}"/> + <property name="sample.dll" value="${sample}.dll" /> + + <property name="sample.type" + value="${path::get-file-name(path::get-directory-name(project.base))}" /> + <property name="sample.type" value="addin" if="${sample.type=='Core'}" /> + + <if test="${directory::exists(path::combine(project.base, 'Tests'))}" > + <property name="tests" value="${sample}Tests" + unless="${property::exists('tests')}" /> + <property name="test.dll" value="${tests}.dll" /> + </if> + + <property name="nunit.build" value="false" + unless="${property::exists('project.package.dir')}"/> + <property name="nunit.build" value="true" + if="${property::exists('project.package.dir')}"/> + + <property name="build.debug" value="true" + unless="${property::exists('build.debug')}" /> + <property name="build.config" value="Debug" + if="${build.debug}" /> + <property name="build.config" value="Release" + unless="${build.debug}" /> + + + <target name="clean" description="Remove files created by build"> + + <delete file="${output.dir}/${sample.dll}" /> + <delete file="${output.dir}/${sample}.pdb" /> + + <if test="${property::exists('test.dll')}"> + <delete file="${output.dir}/${test.dll}" /> + <delete file="${output.dir}/${path::change-extension(test.dll, '.pdb')}" /> + </if> + + </target> + + <target name="init"> + + <mkdir dir="${output.dir}" unless="${directory::exists(output.dir)}" /> + + <copy file="${nunit.framework.dll}" todir="${output.dir}" + if="${not nunit.build and file::exists(nunit.framework.dll)}" /> + + </target> + + <target name="init-addin"> + + <mkdir dir="${output.dir}" unless="${directory::exists(output.dir)}" /> + + <copy file="${nunit.core.dll}" todir="${output.dir}" + if="${not nunit.build and file::exists(nunit.core.dll)}" /> + <copy file="${nunit.core.interfaces.dll}" todir="${output.dir}" + if="${not nunit.build and file::exists(nunit.core.interfaces.dll)}" /> + + </target> + + <target name="build" Description="Build the sample"> + <call target="build-${sample.type}"/> + </target> + + <target name="build-csharp" depends="init"> + + <csc target="library" output="${output.dir}/${sample.dll}" debug="${build.debug}"> + <sources> + <patternset refid="source-files"/> + </sources> + <references basedir="${output.dir}"> + <include name="nunit.framework.dll" /> + </references> + </csc> + + </target> + + <target name="build-addin" depends="init-addin"> + + <csc target="library" output="${output.dir}/${sample}.dll" debug="${build.debug}"> + <sources> + <patternset refid="source-files"/> + </sources> + <references basedir="${output.dir}"> + <include name="nunit.core.interfaces.dll" /> + <include name="nunit.core.dll" /> + </references> + </csc> + + <call target="build-addin-test" if="${property::exists('test.dll')}" /> + + </target> + + <target name="build-addin-test"> + + <csc target="library" output="${output.dir}/${test.dll}" debug="${build.debug}"> + <sources basedir="Tests"> + <patternset refid="test-files"/> + </sources> + <references basedir="${output.dir}"> + <include name="nunit.framework.dll" /> + <include name="${sample}.dll" /> + </references> + </csc> + + </target> + + <target name="build-vb" depends="init"> + + <vbc target="library" + output="${output.dir}/${sample.dll}" debug="${build.debug}"> + <imports> + <import namespace="System"/> + <import namespace="System.Collections"/> + </imports> + <sources> + <patternset refid="source-files"/> + </sources> + <references basedir="${output.dir}"> + <include name="System.dll" /> + <include name="nunit.framework.dll" /> + </references> + </vbc> + + </target> + + <target name="build-jsharp" depends="init"> + + <vjc target="library" output="${output.dir}/${sample.dll}" debug="${build.debug}"> + <sources> + <patternset refid="source-files"/> + </sources> + <references basedir="${output.dir}"> + <include name="nunit.framework.dll" /> + </references> + </vjc> + + </target> + + <target name="build-managed" depends="init"> + + <readregistry property="vs.2003.path" + key="Software\Microsoft\VisualStudio\7.1\InstallDir" + hive="LocalMachine" failonerror="false" + unless="${property::exists( 'vs.2003.path' )}"/> + + <fail message="VS 2003 must be installed to build this sample" + unless="${property::exists( 'vs.2003.path' )}"/> + + <exec program="devenv.exe" basedir="${vs.2003.path}" workingdir="." + commandline="${sample}.vcproj /build ${build.config} /out ${output.dir}/${sample.dll}" /> + + </target> + + <target name="build-cpp-cli" depends="init"> + + <readregistry property="vs.2005.path" + key="Software\Microsoft\VisualStudio\8.0\InstallDir" + hive="LocalMachine" failonerror="false" + unless="${property::exists( 'vs.2005.path' )}"/> + + <fail message="VS 2005 must be installed to build this sample" + unless="${property::exists( 'vs.2005.path' )}"/> + + <exec program="devenv.exe" + basedir="${vs.2005.path}" workingdir="." + commandline="${sample}.vcproj /build ${build.config} /out ${output.dir}/${sample.dll}"/> + + </target> + + <!-- ************************************************************* --> + <!-- Package targets are only used by the NUnit build script in --> + <!-- order to package the samples for distribution. --> + <!-- ************************************************************* --> + + <target name="package"> + + <fail message="Can't use package target directly - it must be called from the NUnit build script." + unless="${nunit.build}"/> + + <property name="sample.path" + value="${string::replace(project.base, samples.base, package.samples.dir)}" /> + + <call target="package-${sample.type}" /> + + </target> + + <target name="package-csharp"> + + <property name="sample.proj" value="${sample}.csproj" /> + + <call target="copy-source-files" /> + <call target="update-framework-ref" /> + + </target> + + <target name="package-jsharp"> + + <property name="sample.proj" value="${sample}.vjsproj" /> + + <call target="copy-source-files" /> + <call target="update-framework-ref" /> + + </target> + + <target name="update-framework-ref"> + + <xmlpoke + file="${sample.path}/${sample.proj}" + xpath="/VisualStudioProject/*/Build/References/Reference[@Name='nunit.framework']/@HintPath" + value="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + + </target> + + <target name="package-vb"> + + <property name="sample.proj" value="${sample}.vbproj" /> + + <call target="copy-source-files" /> + <call target="update-framework-ref" /> + + </target> + + <target name="package-managed"> + + <property name="sample.proj" value="${sample}.vcproj" /> + + <call target="copy-source-files" /> + + <copy todir="${package.samples.dir}/cpp/managed/failures" + file="./cpp-managed-failures.vcproj"> + <filterchain> + <replacestring from="$(SolutionDir)..\..\..\src\NUnitFramework\framework\bin\Debug\nunit.framework.dll" + to="..\..\..\..\bin\nunit.framework.dll"/> + </filterchain> + </copy> + + </target> + + <target name="package-cpp-cli"> + + <property name="sample.proj" value="${sample}.vcproj" /> + + <call target="copy-source-files" /> + + <xmlpoke + file="${sample.path}/${sample.proj}" + xpath="/VisualStudioProject/References/AssemblyReference[@AssemblyName='nunit.framework']/@RelativePath" + value="..\..\..\..\bin\net-2.0\framework\nunit.framework.dll" /> + + </target> + + <target name="package-addin"> + + <property name="sample.proj" value="${sample}.csproj" /> + + <call target="copy-source-files" /> + <call target="copy-test-files" + if="${property::exists('test.dll')}"/> + + </target> + + <target name="copy-source-files"> + + <copy todir="${sample.path}" includeemptydirs="false"> + <fileset basedir="."> + <include name="${sample.proj}" /> + <include name="${sample}.build" /> + <include name="Readme.txt" /> + <patternset refid="source-files" /> + </fileset> + </copy> + + </target> + + <target name="copy-test-files"> + + <copy todir="${sample.path}/Tests" includeemptydirs="false"> + <fileset basedir="Tests"> + <include name="${sample}Tests.csproj" /> + <include name="${sample}Tests.build" /> + <patternset refid="test-files" /> + </fileset> + </copy> + + </target> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/failures/AssemblyInfo.vb b/tools/NUnit/samples/vb/failures/AssemblyInfo.vb new file mode 100644 index 0000000..3e9a34c --- /dev/null +++ b/tools/NUnit/samples/vb/failures/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + +<Assembly: AssemblyTitle("")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("")> +<Assembly: AssemblyProduct("")> +<Assembly: AssemblyCopyright("")> +<Assembly: AssemblyTrademark("")> +<Assembly: CLSCompliant(True)> + +'The following GUID is for the ID of the typelib if this project is exposed to COM +<Assembly: Guid("592E12A6-DA65-4E00-BCE6-4AB403604F41")> + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + +<Assembly: AssemblyVersion("2.2.0.0")> + diff --git a/tools/NUnit/samples/vb/failures/SimpleVBTest.vb b/tools/NUnit/samples/vb/failures/SimpleVBTest.vb new file mode 100644 index 0000000..14b49a2 --- /dev/null +++ b/tools/NUnit/samples/vb/failures/SimpleVBTest.vb @@ -0,0 +1,60 @@ +' **************************************************************** +' This is free software licensed under the NUnit license. You +' may obtain a copy of the license as well as information regarding +' copyright ownership at http://nunit.org/?p=license&r=2.4. +' **************************************************************** + +Option Explicit On +Imports System +Imports NUnit.Framework + +Namespace NUnit.Samples + + <TestFixture()> Public Class SimpleVBTest + + Private fValue1 As Integer + Private fValue2 As Integer + + Public Sub New() + MyBase.New() + End Sub + + <SetUp()> Public Sub Init() + fValue1 = 2 + fValue2 = 3 + End Sub + + <Test()> Public Sub Add() + Dim result As Double + + result = fValue1 + fValue2 + Assert.AreEqual(6, result) + End Sub + + <Test()> Public Sub DivideByZero() + Dim zero As Integer + Dim result As Integer + + zero = 0 + result = 8 / zero + End Sub + + <Test()> Public Sub TestEquals() + Assert.AreEqual(12, 12) + Assert.AreEqual(CLng(12), CLng(12)) + + Assert.AreEqual(12, 13, "Size") + Assert.AreEqual(12, 11.99, 0, "Capacity") + End Sub + + <Test(), ExpectedException(GetType(Exception))> Public Sub ExpectAnException() + Throw New InvalidCastException() + End Sub + + <Test(), Ignore("sample ignore")> Public Sub IgnoredTest() + ' does not matter what we type the test is not run + Throw New ArgumentException() + End Sub + + End Class +End Namespace
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/failures/vb-failures.build b/tools/NUnit/samples/vb/failures/vb-failures.build new file mode 100644 index 0000000..1d89264 --- /dev/null +++ b/tools/NUnit/samples/vb/failures/vb-failures.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="vb-failures" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.vb" /> + <include name="SimpleVBTest.vb" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/failures/vb-failures.vbproj b/tools/NUnit/samples/vb/failures/vb-failures.vbproj new file mode 100644 index 0000000..329376f --- /dev/null +++ b/tools/NUnit/samples/vb/failures/vb-failures.vbproj @@ -0,0 +1,24 @@ +<VisualStudioProject> + <VisualBasic ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{F199991B-6C8E-4AB0-9AAA-703CD4897700}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="vb-failures" AssemblyOriginatorKeyFile="" AssemblyOriginatorKeyMode="None" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" OptionCompare="Binary" OptionExplicit="On" OptionStrict="Off" RootNamespace="vb_failures" StartupObject="vb_failures.(None)"> + <Config Name="Debug" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="true" DefineTrace="true" DebugSymbols="true" IncrementalBuild="true" Optimize="false" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + <Config Name="Release" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="false" DefineTrace="true" DebugSymbols="false" IncrementalBuild="false" Optimize="true" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + <Imports> + <Import Namespace="Microsoft.VisualBasic" /> + <Import Namespace="System" /> + </Imports> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="SimpleVBTest.vb" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </VisualBasic> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/money/AssemblyInfo.vb b/tools/NUnit/samples/vb/money/AssemblyInfo.vb new file mode 100644 index 0000000..f929cbc --- /dev/null +++ b/tools/NUnit/samples/vb/money/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + +<Assembly: AssemblyTitle("")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("")> +<Assembly: AssemblyProduct("")> +<Assembly: AssemblyCopyright("")> +<Assembly: AssemblyTrademark("")> +<Assembly: CLSCompliant(True)> + +'The following GUID is for the ID of the typelib if this project is exposed to COM +<Assembly: Guid("F21BB3B6-0C5E-4AE5-ABC7-4D25FC3F98DB")> + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + +<Assembly: AssemblyVersion("1.0.*")> diff --git a/tools/NUnit/samples/vb/money/IMoney.vb b/tools/NUnit/samples/vb/money/IMoney.vb new file mode 100644 index 0000000..ddc8ae6 --- /dev/null +++ b/tools/NUnit/samples/vb/money/IMoney.vb @@ -0,0 +1,37 @@ +' **************************************************************** +' This is free software licensed under the NUnit license. You +' may obtain a copy of the license as well as information regarding +' copyright ownership at http://nunit.org/?p=license&r=2.4. +' **************************************************************** + +Namespace NUnit.Samples + + 'The common interface for simple Monies and MoneyBags. + Public Interface IMoney + + 'Adds a money to this money + Function Add(ByVal m As IMoney) As IMoney + + 'Adds a simple Money to this money. This is a helper method for + 'implementing double dispatch. + Function AddMoney(ByVal m As Money) As IMoney + + 'Adds a MoneyBag to this money. This is a helper method for + 'implementing double dispatch. + Function AddMoneyBag(ByVal s As MoneyBag) As IMoney + + 'True if this money is zero. + ReadOnly Property IsZero() As Boolean + + 'Multiplies a money by the given factor. + Function Multiply(ByVal factor As Int32) As IMoney + + 'Negates this money. + Function Negate() As IMoney + + 'Subtracts a money from this money. + Function Subtract(ByVal m As IMoney) As IMoney + + End Interface + +End Namespace diff --git a/tools/NUnit/samples/vb/money/Money.vb b/tools/NUnit/samples/vb/money/Money.vb new file mode 100644 index 0000000..f7699a8 --- /dev/null +++ b/tools/NUnit/samples/vb/money/Money.vb @@ -0,0 +1,109 @@ +' **************************************************************** +' This is free software licensed under the NUnit license. You +' may obtain a copy of the license as well as information regarding +' copyright ownership at http://nunit.org/?p=license&r=2.4. +' **************************************************************** + +Option Explicit On + +Namespace NUnit.Samples + + ' A Simple Money. + Public Class Money + Implements IMoney + + Private fAmount As Int32 + Private fCurrency As String + + ' Constructs a money from a given amount and currency. + Public Sub New(ByVal amount As Int32, ByVal currency As String) + Me.fAmount = amount + Me.fCurrency = currency + End Sub + + + ' Adds a money to this money. Forwards the request + ' to the AddMoney helper. + Public Overloads Function Add(ByVal m As IMoney) As IMoney Implements IMoney.Add + Return m.AddMoney(Me) + End Function + + Public Overloads Function AddMoney(ByVal m As Money) As IMoney Implements IMoney.AddMoney + If m.Currency.Equals(Currency) Then + Return New Money(Amount + m.Amount, Currency) + End If + + Return New MoneyBag(Me, m) + End Function + + Public Function AddMoneyBag(ByVal s As MoneyBag) As IMoney Implements IMoney.AddMoneyBag + Return s.AddMoney(Me) + End Function + + Public ReadOnly Property Amount() As Integer + Get + Return fAmount + End Get + End Property + + Public ReadOnly Property Currency() As String + Get + Return fCurrency + End Get + End Property + + Public Overloads Overrides Function Equals(ByVal anObject As Object) As Boolean + If IsZero And TypeOf anObject Is IMoney Then + Dim aMoney As IMoney = anObject + Return aMoney.IsZero + End If + + If TypeOf anObject Is Money Then + Dim aMoney As Money = anObject + If (IsZero) Then + Return aMoney.IsZero + End If + + Return Currency.Equals(aMoney.Currency) And Amount.Equals(aMoney.Amount) + End If + + Return False + End Function + + Public Overrides Function GetHashCode() As Int32 + Return fCurrency.GetHashCode() + fAmount + End Function + + Public ReadOnly Property IsZero() As Boolean Implements IMoney.IsZero + Get + Return Amount.Equals(0) + End Get + End Property + + Public Function Multiply(ByVal factor As Integer) As IMoney Implements IMoney.Multiply + + Return New Money(Amount * factor, Currency) + + End Function + + Public Function Negate() As IMoney Implements IMoney.Negate + + Return New Money(-Amount, Currency) + + End Function + + Public Function Subtract(ByVal m As IMoney) As IMoney Implements IMoney.Subtract + + Return Add(m.Negate()) + + End Function + + Public Overrides Function ToString() As String + + Return String.Format("[{0} {1}]", Amount, Currency) + + End Function + + End Class + +End Namespace diff --git a/tools/NUnit/samples/vb/money/MoneyBag.vb b/tools/NUnit/samples/vb/money/MoneyBag.vb new file mode 100644 index 0000000..409c1a1 --- /dev/null +++ b/tools/NUnit/samples/vb/money/MoneyBag.vb @@ -0,0 +1,164 @@ +' **************************************************************** +' This is free software licensed under the NUnit license. You +' may obtain a copy of the license as well as information regarding +' copyright ownership at http://nunit.org/?p=license&r=2.4. +' **************************************************************** + +Option Explicit On + +Namespace NUnit.Samples + + Public Class MoneyBag + Implements IMoney + + Private fmonies As ArrayList = New ArrayList(5) + + Private Sub New() + + End Sub + + Public Sub New(ByVal bag As Money()) + For Each m As Money In bag + If Not m.IsZero Then + AppendMoney(m) + End If + Next + End Sub + + Public Sub New(ByVal m1 As Money, ByVal m2 As Money) + + AppendMoney(m1) + AppendMoney(m2) + + End Sub + + Public Sub New(ByVal m As Money, ByVal bag As MoneyBag) + AppendMoney(m) + AppendBag(bag) + End Sub + + Public Sub New(ByVal m1 As MoneyBag, ByVal m2 As MoneyBag) + AppendBag(m1) + AppendBag(m2) + End Sub + + Public Function Add(ByVal m As IMoney) As IMoney Implements IMoney.Add + Return m.AddMoneyBag(Me) + End Function + + Public Function AddMoney(ByVal m As Money) As IMoney Implements IMoney.AddMoney + Return New MoneyBag(m, Me).Simplify + End Function + + Public Function AddMoneyBag(ByVal s As MoneyBag) As IMoney Implements IMoney.AddMoneyBag + Return New MoneyBag(s, Me).Simplify() + End Function + + Private Sub AppendBag(ByVal aBag As MoneyBag) + For Each m As Money In aBag.fmonies + AppendMoney(m) + Next + End Sub + + Private Sub AppendMoney(ByVal aMoney As Money) + + Dim old As Money = FindMoney(aMoney.Currency) + If old Is Nothing Then + fmonies.Add(aMoney) + Return + End If + fmonies.Remove(old) + Dim sum As IMoney = old.Add(aMoney) + If (sum.IsZero) Then + Return + End If + fmonies.Add(sum) + End Sub + + Private Function Contains(ByVal aMoney As Money) As Boolean + Dim m As Money = FindMoney(aMoney.Currency) + Return m.Amount.Equals(aMoney.Amount) + End Function + + Public Overloads Overrides Function Equals(ByVal anObject As Object) As Boolean + If IsZero Then + If TypeOf anObject Is IMoney Then + Dim aMoney As IMoney = anObject + Return aMoney.IsZero + End If + End If + + If TypeOf anObject Is MoneyBag Then + Dim aMoneyBag As MoneyBag = anObject + If Not aMoneyBag.fmonies.Count.Equals(fmonies.Count) Then + Return False + End If + + For Each m As Money In fmonies + If Not aMoneyBag.Contains(m) Then + Return False + End If + + Return True + Next + End If + + Return False + End Function + + Private Function FindMoney(ByVal currency As String) As Money + For Each m As Money In fmonies + If m.Currency.Equals(currency) Then + Return m + End If + Next + + Return Nothing + End Function + + Public Overrides Function GetHashCode() As Int32 + Dim hash As Int32 = 0 + For Each m As Money In fmonies + hash += m.GetHashCode() + Next + Return hash + End Function + + Public ReadOnly Property IsZero() As Boolean Implements IMoney.IsZero + Get + Return fmonies.Count.Equals(0) + End Get + End Property + + Public Function Multiply(ByVal factor As Integer) As IMoney Implements IMoney.Multiply + Dim result As New MoneyBag + If Not factor.Equals(0) Then + For Each m As Money In fmonies + result.AppendMoney(m.Multiply(factor)) + Next + End If + Return result + End Function + + Public Function Negate() As IMoney Implements IMoney.Negate + Dim result As New MoneyBag + For Each m As Money In fmonies + result.AppendMoney(m.Negate()) + Next + Return result + End Function + + Private Function Simplify() As IMoney + If fmonies.Count.Equals(1) Then + Return fmonies(0) + End If + Return Me + End Function + + + Public Function Subtract(ByVal m As IMoney) As IMoney Implements IMoney.Subtract + Return Add(m.Negate()) + End Function + End Class + +End Namespace diff --git a/tools/NUnit/samples/vb/money/MoneyTest.vb b/tools/NUnit/samples/vb/money/MoneyTest.vb new file mode 100644 index 0000000..acb2c42 --- /dev/null +++ b/tools/NUnit/samples/vb/money/MoneyTest.vb @@ -0,0 +1,216 @@ +' **************************************************************** +' This is free software licensed under the NUnit license. You +' may obtain a copy of the license as well as information regarding +' copyright ownership at http://nunit.org/?p=license&r=2.4. +' **************************************************************** + +Option Explicit On + +Imports System +Imports NUnit.Framework + +Namespace NUnit.Samples + + <TestFixture()> _ + Public Class MoneyTest + + Private f12CHF As Money + Private f14CHF As Money + Private f7USD As Money + Private f21USD As Money + + Private fMB1 As MoneyBag + Private fMB2 As MoneyBag + + <SetUp()> _ + Protected Sub SetUp() + + f12CHF = New Money(12, "CHF") + f14CHF = New Money(14, "CHF") + f7USD = New Money(7, "USD") + f21USD = New Money(21, "USD") + + fMB1 = New MoneyBag(f12CHF, f7USD) + fMB2 = New MoneyBag(f14CHF, f21USD) + + End Sub + + <Test()> _ + Public Sub BagMultiply() + ' {[12 CHF][7 USD]} *2 == {[24 CHF][14 USD]} + Dim bag() As Money = New Money() {New Money(24, "CHF"), New Money(14, "USD")} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, fMB1.Multiply(2)) + Assert.AreEqual(fMB1, fMB1.Multiply(1)) + Assert.IsTrue(fMB1.Multiply(0).IsZero) + End Sub + + <Test()> _ + Public Sub BagNegate() + ' {[12 CHF][7 USD]} negate == {[-12 CHF][-7 USD]} + Dim bag() As Money = New Money() {New Money(-12, "CHF"), New Money(-7, "USD")} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, fMB1.Negate()) + End Sub + + <Test()> _ + Public Sub BagSimpleAdd() + + ' {[12 CHF][7 USD]} + [14 CHF] == {[26 CHF][7 USD]} + Dim bag() As Money = New Money() {New Money(26, "CHF"), New Money(7, "USD")} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, fMB1.Add(f14CHF)) + + End Sub + + <Test()> _ + Public Sub BagSubtract() + ' {[12 CHF][7 USD]} - {[14 CHF][21 USD] == {[-2 CHF][-14 USD]} + Dim bag() As Money = New Money() {New Money(-2, "CHF"), New Money(-14, "USD")} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, fMB1.Subtract(fMB2)) + End Sub + + <Test()> _ + Public Sub BagSumAdd() + ' {[12 CHF][7 USD]} + {[14 CHF][21 USD]} == {[26 CHF][28 USD]} + Dim bag() As Money = New Money() {New Money(26, "CHF"), New Money(28, "USD")} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, fMB1.Add(fMB2)) + End Sub + + <Test()> _ + Public Sub IsZero() + Assert.IsTrue(fMB1.Subtract(fMB1).IsZero) + + Dim bag() As Money = New Money() {New Money(0, "CHF"), New Money(0, "USD")} + Assert.IsTrue(New MoneyBag(bag).IsZero) + End Sub + + <Test()> _ + Public Sub MixedSimpleAdd() + ' [12 CHF] + [7 USD] == {[12 CHF][7 USD]} + Dim bag() As Money = New Money() {f12CHF, f7USD} + Dim expected As New MoneyBag(bag) + Assert.AreEqual(expected, f12CHF.Add(f7USD)) + End Sub + + <Test()> _ + Public Sub MoneyBagEquals() + ' NOTE: Normally we use Assert.AreEqual to test whether two + ' objects are equal. But here we are testing the MoneyBag.Equals() + ' method itself, so using AreEqual would not serve the purpose. + Assert.IsFalse(fMB1.Equals(Nothing)) + + Assert.IsTrue(fMB1.Equals(fMB1)) + Dim equal As MoneyBag = New MoneyBag(New Money(12, "CHF"), New Money(7, "USD")) + Assert.IsTrue(fMB1.Equals(equal)) + Assert.IsFalse(fMB1.Equals(f12CHF)) + Assert.IsFalse(f12CHF.Equals(fMB1)) + Assert.IsFalse(fMB1.Equals(fMB2)) + End Sub + + <Test()> _ + Public Sub MoneyBagHash() + Dim equal As MoneyBag = New MoneyBag(New Money(12, "CHF"), New Money(7, "USD")) + Assert.AreEqual(fMB1.GetHashCode(), equal.GetHashCode()) + End Sub + + <Test()> _ + Public Sub MoneyEquals() + ' NOTE: Normally we use Assert.AreEqual to test whether two + ' objects are equal. But here we are testing the MoneyBag.Equals() + ' method itself, so using AreEqual would not serve the purpose. + Assert.IsFalse(f12CHF.Equals(Nothing)) + Dim equalMoney As Money = New Money(12, "CHF") + Assert.IsTrue(f12CHF.Equals(f12CHF)) + Assert.IsTrue(f12CHF.Equals(equalMoney)) + Assert.IsFalse(f12CHF.Equals(f14CHF)) + End Sub + + <Test()> _ + Public Sub MoneyHash() + Assert.IsFalse(f12CHF.Equals(Nothing)) + Dim equal As Money = New Money(12, "CHF") + Assert.AreEqual(f12CHF.GetHashCode(), equal.GetHashCode()) + End Sub + + <Test()> _ + Public Sub Normalize() + Dim bag() As Money = New Money() {New Money(26, "CHF"), New Money(28, "CHF"), New Money(6, "CHF")} + Dim moneyBag As New MoneyBag(bag) + Dim expected() As Money = New Money() {New Money(60, "CHF")} + ' // note: expected is still a MoneyBag + Dim expectedBag As New MoneyBag(expected) + Assert.AreEqual(expectedBag, moneyBag) + End Sub + + <Test()> _ + Public Sub Normalize2() + ' {[12 CHF][7 USD]} - [12 CHF] == [7 USD] + Dim expected As Money = New Money(7, "USD") + Assert.AreEqual(expected, fMB1.Subtract(f12CHF)) + End Sub + + <Test()> _ + Public Sub Normalize3() + ' {[12 CHF][7 USD]} - {[12 CHF][3 USD]} == [4 USD] + Dim s1() As Money = New Money() {New Money(12, "CHF"), New Money(3, "USD")} + Dim ms1 As New MoneyBag(s1) + Dim expected As New Money(4, "USD") + Assert.AreEqual(expected, fMB1.Subtract(ms1)) + End Sub + + <Test()> _ + Public Sub Normalize4() + ' [12 CHF] - {[12 CHF][3 USD]} == [-3 USD] + Dim s1() As Money = New Money() {New Money(12, "CHF"), New Money(3, "USD")} + Dim ms1 As New MoneyBag(s1) + Dim expected As New Money(-3, "USD") + Assert.AreEqual(expected, f12CHF.Subtract(ms1)) + End Sub + + <Test()> _ + Public Sub Print() + Assert.AreEqual("[12 CHF]", f12CHF.ToString()) + End Sub + + <Test()> _ + Public Sub SimpleAdd() + + ' [12 CHF] + [14 CHF] == [26 CHF] + Dim expected As Money = New Money(26, "CHF") + Assert.AreEqual(expected, f12CHF.Add(f14CHF)) + + End Sub + + <Test()> _ + Public Sub SimpleNegate() + + ' [14 CHF] negate == [-14 CHF] + Dim expected As New Money(-14, "CHF") + Assert.AreEqual(expected, f14CHF.Negate()) + + End Sub + + <Test()> _ + Public Sub SimpleSubtract() + + ' [14 CHF] - [12 CHF] == [2 CHF] + Dim expected As New Money(2, "CHF") + Assert.AreEqual(expected, f14CHF.Subtract(f12CHF)) + + End Sub + + <Test()> _ + Public Sub SimpleMultiply() + + ' [14 CHF] *2 == [28 CHF] + Dim expected As New Money(28, "CHF") + Assert.AreEqual(expected, f14CHF.Multiply(2)) + + End Sub + + End Class + +End Namespace diff --git a/tools/NUnit/samples/vb/money/vb-money.build b/tools/NUnit/samples/vb/money/vb-money.build new file mode 100644 index 0000000..0d3cc04 --- /dev/null +++ b/tools/NUnit/samples/vb/money/vb-money.build @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<project name="vb-money" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.vb" /> + <include name="IMoney.vb" /> + <include name="Money.vb" /> + <include name="MoneyBag.vb" /> + <include name="MoneyTest.vb" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/money/vb-money.vbproj b/tools/NUnit/samples/vb/money/vb-money.vbproj new file mode 100644 index 0000000..b5579af --- /dev/null +++ b/tools/NUnit/samples/vb/money/vb-money.vbproj @@ -0,0 +1,28 @@ +<VisualStudioProject> + <VisualBasic ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{95394B96-A794-48EA-9879-0E4EC79C5724}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="vb-money" AssemblyOriginatorKeyFile="" AssemblyOriginatorKeyMode="None" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" OptionCompare="Binary" OptionExplicit="On" OptionStrict="Off" RootNamespace="Money" StartupObject=""> + <Config Name="Debug" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="true" DefineTrace="true" DebugSymbols="true" IncrementalBuild="true" Optimize="false" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + <Config Name="Release" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="false" DefineTrace="true" DebugSymbols="false" IncrementalBuild="false" Optimize="true" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + <Imports> + <Import Namespace="Microsoft.VisualBasic" /> + <Import Namespace="System" /> + <Import Namespace="System.Collections" /> + </Imports> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="IMoney.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="Money.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="MoneyBag.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="MoneyTest.vb" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </VisualBasic> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/syntax/AssemblyInfo.vb b/tools/NUnit/samples/vb/syntax/AssemblyInfo.vb new file mode 100644 index 0000000..e29c3d4 --- /dev/null +++ b/tools/NUnit/samples/vb/syntax/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + +<Assembly: AssemblyTitle("")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("")> +<Assembly: AssemblyProduct("")> +<Assembly: AssemblyCopyright("")> +<Assembly: AssemblyTrademark("")> +<Assembly: CLSCompliant(True)> + +'The following GUID is for the ID of the typelib if this project is exposed to COM +<Assembly: Guid("966C964A-3C92-4834-AC3A-9A47BA0A728B")> + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + +<Assembly: AssemblyVersion("1.0.*")> diff --git a/tools/NUnit/samples/vb/syntax/AssertSyntaxTests.vb b/tools/NUnit/samples/vb/syntax/AssertSyntaxTests.vb new file mode 100644 index 0000000..bec1e0b --- /dev/null +++ b/tools/NUnit/samples/vb/syntax/AssertSyntaxTests.vb @@ -0,0 +1,705 @@ +' **************************************************************** +' Copyright 2007, Charlie Poole +' This is free software licensed under the NUnit license. You may +' obtain a copy of the license at http:'nunit.org/?p=license&r=2.4 +' **************************************************************** + +Option Explicit On + +Imports System +Imports NUnit.Framework +Imports NUnit.Framework.Constraints +Imports Text = NUnit.Framework.Text + +Namespace NUnit.Samples + + ' This test fixture attempts to exercise all the syntactic + ' variations of Assert without getting into failures, errors + ' or corner cases. Thus, some of the tests may be duplicated + ' in other fixtures. + ' + ' Each test performs the same operations using the classic + ' syntax (if available) and the new syntax in both the + ' helper-based and inherited forms. + ' + ' This Fixture will eventually be duplicated in other + ' supported languages. + + <TestFixture()> _ + Public Class AssertSyntaxTests + Inherits AssertionHelper + +#Region "Simple Constraint Tests" + <Test()> _ + Public Sub IsNull() + Dim nada As Object = Nothing + + ' Classic syntax + Assert.IsNull(nada) + + ' Helper syntax + Assert.That(nada, Iz.Null) + + ' Inherited syntax + Expect(nada, Null) + End Sub + + + <Test()> _ + Public Sub IsNotNull() + ' Classic syntax + Assert.IsNotNull(42) + + ' Helper syntax + Assert.That(42, Iz.Not.Null) + + ' Inherited syntax + Expect(42, Iz.Not.Null) + End Sub + + <Test()> _ + Public Sub IsTrue() + ' Classic syntax + Assert.IsTrue(2 + 2 = 4) + + ' Helper syntax + Assert.That(2 + 2 = 4, Iz.True) + Assert.That(2 + 2 = 4) + + ' Inherited syntax + Expect(2 + 2 = 4, Iz.True) + Expect(2 + 2 = 4) + End Sub + + <Test()> _ + Public Sub IsFalse() + ' Classic syntax + Assert.IsFalse(2 + 2 = 5) + + ' Helper syntax + Assert.That(2 + 2 = 5, Iz.False) + + ' Inherited syntax + Expect(2 + 2 = 5, Iz.False) + End Sub + + <Test()> _ + Public Sub IsNaN() + Dim d As Double = Double.NaN + Dim f As Single = Single.NaN + + ' Classic syntax + Assert.IsNaN(d) + Assert.IsNaN(f) + + ' Helper syntax + Assert.That(d, Iz.NaN) + Assert.That(f, Iz.NaN) + + ' Inherited syntax + Expect(d, NaN) + Expect(f, NaN) + End Sub + + <Test()> _ + Public Sub EmptyStringTests() + ' Classic syntax + Assert.IsEmpty("") + Assert.IsNotEmpty("Hello!") + + ' Helper syntax + Assert.That("", Iz.Empty) + Assert.That("Hello!", Iz.Not.Empty) + + ' Inherited syntax + Expect("", Empty) + Expect("Hello!", Iz.Not.Empty) + End Sub + + <Test()> _ + Public Sub EmptyCollectionTests() + + Dim boolArray As Boolean() = New Boolean() {} + Dim nonEmpty As Integer() = New Integer() {1, 2, 3} + + ' Classic syntax + Assert.IsEmpty(boolArray) + Assert.IsNotEmpty(nonEmpty) + + ' Helper syntax + Assert.That(boolArray, Iz.Empty) + Assert.That(nonEmpty, Iz.Not.Empty) + + ' Inherited syntax + Expect(boolArray, Iz.Empty) + Expect(nonEmpty, Iz.Not.Empty) + End Sub +#End Region + +#Region "TypeConstraint Tests" + <Test()> _ + Public Sub ExactTypeTests() + ' Classic syntax workarounds + Assert.AreEqual(GetType(String), "Hello".GetType()) + Assert.AreEqual("System.String", "Hello".GetType().FullName) + Assert.AreNotEqual(GetType(Integer), "Hello".GetType()) + Assert.AreNotEqual("System.Int32", "Hello".GetType().FullName) + + ' Helper syntax + Assert.That("Hello", Iz.TypeOf(GetType(String))) + Assert.That("Hello", Iz.Not.TypeOf(GetType(Integer))) + + ' Inherited syntax + Expect("Hello", Iz.TypeOf(GetType(String))) + Expect("Hello", Iz.Not.TypeOf(GetType(Integer))) + End Sub + + <Test()> _ + Public Sub InstanceOfTypeTests() + ' Classic syntax + Assert.IsInstanceOf(GetType(String), "Hello") + Assert.IsNotInstanceOf(GetType(String), 5) + + ' Helper syntax + Assert.That("Hello", Iz.InstanceOf(GetType(String))) + Assert.That(5, Iz.Not.InstanceOf(GetType(String))) + + ' Inherited syntax + Expect("Hello", InstanceOf(GetType(String))) + Expect(5, Iz.Not.InstanceOf(GetType(String))) + End Sub + + <Test()> _ + Public Sub AssignableFromTypeTests() + ' Classic syntax + Assert.IsAssignableFrom(GetType(String), "Hello") + Assert.IsNotAssignableFrom(GetType(String), 5) + + ' Helper syntax + Assert.That("Hello", Iz.AssignableFrom(GetType(String))) + Assert.That(5, Iz.Not.AssignableFrom(GetType(String))) + + ' Inherited syntax + Expect("Hello", AssignableFrom(GetType(String))) + Expect(5, Iz.Not.AssignableFrom(GetType(String))) + End Sub +#End Region + +#Region "StringConstraintTests" + <Test()> _ + Public Sub SubstringTests() + Dim phrase As String = "Hello World!" + Dim array As String() = New String() {"abc", "bad", "dba"} + + ' Classic Syntax + StringAssert.Contains("World", phrase) + + ' Helper syntax + Assert.That(phrase, Text.Contains("World")) + ' Only available using new syntax + Assert.That(phrase, Text.DoesNotContain("goodbye")) + Assert.That(phrase, Text.Contains("WORLD").IgnoreCase) + Assert.That(phrase, Text.DoesNotContain("BYE").IgnoreCase) + Assert.That(array, Text.All.Contains("b")) + + ' Inherited syntax + Expect(phrase, Contains("World")) + ' Only available using new syntax + Expect(phrase, Text.DoesNotContain("goodbye")) + Expect(phrase, Contains("WORLD").IgnoreCase) + Expect(phrase, Text.DoesNotContain("BYE").IgnoreCase) + Expect(array, All.Contains("b")) + End Sub + + <Test()> _ + Public Sub StartsWithTests() + Dim phrase As String = "Hello World!" + Dim greetings As String() = New String() {"Hello!", "Hi!", "Hola!"} + + ' Classic syntax + StringAssert.StartsWith("Hello", phrase) + + ' Helper syntax + Assert.That(phrase, Text.StartsWith("Hello")) + ' Only available using new syntax + Assert.That(phrase, Text.DoesNotStartWith("Hi!")) + Assert.That(phrase, Text.StartsWith("HeLLo").IgnoreCase) + Assert.That(phrase, Text.DoesNotStartWith("HI").IgnoreCase) + Assert.That(greetings, Text.All.StartsWith("h").IgnoreCase) + + ' Inherited syntax + Expect(phrase, StartsWith("Hello")) + ' Only available using new syntax + Expect(phrase, Text.DoesNotStartWith("Hi!")) + Expect(phrase, StartsWith("HeLLo").IgnoreCase) + Expect(phrase, Text.DoesNotStartWith("HI").IgnoreCase) + Expect(greetings, All.StartsWith("h").IgnoreCase) + End Sub + + <Test()> _ + Public Sub EndsWithTests() + Dim phrase As String = "Hello World!" + Dim greetings As String() = New String() {"Hello!", "Hi!", "Hola!"} + + ' Classic Syntax + StringAssert.EndsWith("!", phrase) + + ' Helper syntax + Assert.That(phrase, Text.EndsWith("!")) + ' Only available using new syntax + Assert.That(phrase, Text.DoesNotEndWith("?")) + Assert.That(phrase, Text.EndsWith("WORLD!").IgnoreCase) + Assert.That(greetings, Text.All.EndsWith("!")) + + ' Inherited syntax + Expect(phrase, EndsWith("!")) + ' Only available using new syntax + Expect(phrase, Text.DoesNotEndWith("?")) + Expect(phrase, EndsWith("WORLD!").IgnoreCase) + Expect(greetings, All.EndsWith("!")) + End Sub + + <Test()> _ + Public Sub EqualIgnoringCaseTests() + + Dim phrase As String = "Hello World!" + Dim array1 As String() = New String() {"Hello", "World"} + Dim array2 As String() = New String() {"HELLO", "WORLD"} + Dim array3 As String() = New String() {"HELLO", "Hello", "hello"} + + ' Classic syntax + StringAssert.AreEqualIgnoringCase("hello world!", phrase) + + ' Helper syntax + Assert.That(phrase, Iz.EqualTo("hello world!").IgnoreCase) + 'Only available using new syntax + Assert.That(phrase, Iz.Not.EqualTo("goodbye world!").IgnoreCase) + Assert.That(array1, Iz.EqualTo(array2).IgnoreCase) + Assert.That(array3, Iz.All.EqualTo("hello").IgnoreCase) + + ' Inherited syntax + Expect(phrase, EqualTo("hello world!").IgnoreCase) + 'Only available using new syntax + Expect(phrase, Iz.Not.EqualTo("goodbye world!").IgnoreCase) + Expect(array1, EqualTo(array2).IgnoreCase) + Expect(array3, All.EqualTo("hello").IgnoreCase) + End Sub + + <Test()> _ + Public Sub RegularExpressionTests() + Dim phrase As String = "Now is the time for all good men to come to the aid of their country." + Dim quotes As String() = New String() {"Never say never", "It's never too late", "Nevermore!"} + + ' Classic syntax + StringAssert.IsMatch("all good men", phrase) + StringAssert.IsMatch("Now.*come", phrase) + + ' Helper syntax + Assert.That(phrase, Text.Matches("all good men")) + Assert.That(phrase, Text.Matches("Now.*come")) + ' Only available using new syntax + Assert.That(phrase, Text.DoesNotMatch("all.*men.*good")) + Assert.That(phrase, Text.Matches("ALL").IgnoreCase) + Assert.That(quotes, Text.All.Matches("never").IgnoreCase) + + ' Inherited syntax + Expect(phrase, Matches("all good men")) + Expect(phrase, Matches("Now.*come")) + ' Only available using new syntax + Expect(phrase, Text.DoesNotMatch("all.*men.*good")) + Expect(phrase, Matches("ALL").IgnoreCase) + Expect(quotes, All.Matches("never").IgnoreCase) + End Sub +#End Region + +#Region "Equality Tests" + <Test()> _ + Public Sub EqualityTests() + + Dim i3 As Integer() = {1, 2, 3} + Dim d3 As Double() = {1.0, 2.0, 3.0} + Dim iunequal As Integer() = {1, 3, 2} + + ' Classic Syntax + Assert.AreEqual(4, 2 + 2) + Assert.AreEqual(i3, d3) + Assert.AreNotEqual(5, 2 + 2) + Assert.AreNotEqual(i3, iunequal) + + ' Helper syntax + Assert.That(2 + 2, Iz.EqualTo(4)) + Assert.That(2 + 2 = 4) + Assert.That(i3, Iz.EqualTo(d3)) + Assert.That(2 + 2, Iz.Not.EqualTo(5)) + Assert.That(i3, Iz.Not.EqualTo(iunequal)) + + ' Inherited syntax + Expect(2 + 2, EqualTo(4)) + Expect(2 + 2 = 4) + Expect(i3, EqualTo(d3)) + Expect(2 + 2, Iz.Not.EqualTo(5)) + Expect(i3, Iz.Not.EqualTo(iunequal)) + End Sub + + <Test()> _ + Public Sub EqualityTestsWithTolerance() + ' CLassic syntax + Assert.AreEqual(5.0R, 4.99R, 0.05R) + Assert.AreEqual(5.0F, 4.99F, 0.05F) + + ' Helper syntax + Assert.That(4.99R, Iz.EqualTo(5.0R).Within(0.05R)) + Assert.That(4D, Iz.Not.EqualTo(5D).Within(0.5D)) + Assert.That(4.99F, Iz.EqualTo(5.0F).Within(0.05F)) + Assert.That(4.99D, Iz.EqualTo(5D).Within(0.05D)) + Assert.That(499, Iz.EqualTo(500).Within(5)) + Assert.That(4999999999L, Iz.EqualTo(5000000000L).Within(5L)) + + ' Inherited syntax + Expect(4.99R, EqualTo(5.0R).Within(0.05R)) + Expect(4D, Iz.Not.EqualTo(5D).Within(0.5D)) + Expect(4.99F, EqualTo(5.0F).Within(0.05F)) + Expect(4.99D, EqualTo(5D).Within(0.05D)) + Expect(499, EqualTo(500).Within(5)) + Expect(4999999999L, EqualTo(5000000000L).Within(5L)) + End Sub + + <Test()> _ + Public Sub EqualityTestsWithTolerance_MixedFloatAndDouble() + ' Bug Fix 1743844 + Assert.That(2.20492R, Iz.EqualTo(2.2R).Within(0.01F), _ + "Double actual, Double expected, Single tolerance") + Assert.That(2.20492R, Iz.EqualTo(2.2F).Within(0.01R), _ + "Double actual, Single expected, Double tolerance") + Assert.That(2.20492R, Iz.EqualTo(2.2F).Within(0.01F), _ + "Double actual, Single expected, Single tolerance") + Assert.That(2.20492F, Iz.EqualTo(2.2F).Within(0.01R), _ + "Single actual, Single expected, Double tolerance") + Assert.That(2.20492F, Iz.EqualTo(2.2R).Within(0.01R), _ + "Single actual, Double expected, Double tolerance") + Assert.That(2.20492F, Iz.EqualTo(2.2R).Within(0.01F), _ + "Single actual, Double expected, Single tolerance") + End Sub + + <Test()> _ + Public Sub EqualityTestsWithTolerance_MixingTypesGenerally() + ' Extending tolerance to all numeric types + Assert.That(202.0R, Iz.EqualTo(200.0R).Within(2), _ + "Double actual, Double expected, int tolerance") + Assert.That(4.87D, Iz.EqualTo(5).Within(0.25R), _ + "Decimal actual, int expected, Double tolerance") + Assert.That(4.87D, Iz.EqualTo(5L).Within(1), _ + "Decimal actual, long expected, int tolerance") + Assert.That(487, Iz.EqualTo(500).Within(25), _ + "int actual, int expected, int tolerance") + Assert.That(487L, Iz.EqualTo(500).Within(25), _ + "long actual, int expected, int tolerance") + End Sub +#End Region + +#Region "Comparison Tests" + <Test()> _ + Public Sub ComparisonTests() + ' Classic Syntax + Assert.Greater(7, 3) + Assert.GreaterOrEqual(7, 3) + Assert.GreaterOrEqual(7, 7) + + ' Helper syntax + Assert.That(7, Iz.GreaterThan(3)) + Assert.That(7, Iz.GreaterThanOrEqualTo(3)) + Assert.That(7, Iz.AtLeast(3)) + Assert.That(7, Iz.GreaterThanOrEqualTo(7)) + Assert.That(7, Iz.AtLeast(7)) + + ' Inherited syntax + Expect(7, GreaterThan(3)) + Expect(7, GreaterThanOrEqualTo(3)) + Expect(7, AtLeast(3)) + Expect(7, GreaterThanOrEqualTo(7)) + Expect(7, AtLeast(7)) + + ' Classic syntax + Assert.Less(3, 7) + Assert.LessOrEqual(3, 7) + Assert.LessOrEqual(3, 3) + + ' Helper syntax + Assert.That(3, Iz.LessThan(7)) + Assert.That(3, Iz.LessThanOrEqualTo(7)) + Assert.That(3, Iz.AtMost(7)) + Assert.That(3, Iz.LessThanOrEqualTo(3)) + Assert.That(3, Iz.AtMost(3)) + + ' Inherited syntax + Expect(3, LessThan(7)) + Expect(3, LessThanOrEqualTo(7)) + Expect(3, AtMost(7)) + Expect(3, LessThanOrEqualTo(3)) + Expect(3, AtMost(3)) + End Sub +#End Region + +#Region "Collection Tests" + <Test()> _ + Public Sub AllItemsTests() + + Dim ints As Object() = {1, 2, 3, 4} + Dim doubles As Object() = {0.99, 2.1, 3.0, 4.05} + Dim strings As Object() = {"abc", "bad", "cab", "bad", "dad"} + + ' Classic syntax + CollectionAssert.AllItemsAreNotNull(ints) + CollectionAssert.AllItemsAreInstancesOfType(ints, GetType(Integer)) + CollectionAssert.AllItemsAreInstancesOfType(strings, GetType(String)) + CollectionAssert.AllItemsAreUnique(ints) + + ' Helper syntax + Assert.That(ints, Iz.All.Not.Null) + Assert.That(ints, Has.None.Null) + Assert.That(ints, Iz.All.InstanceOfType(GetType(Integer))) + Assert.That(ints, Has.All.InstanceOfType(GetType(Integer))) + Assert.That(strings, Iz.All.InstanceOfType(GetType(String))) + Assert.That(strings, Has.All.InstanceOfType(GetType(String))) + Assert.That(ints, Iz.Unique) + ' Only available using new syntax + Assert.That(strings, Iz.Not.Unique) + Assert.That(ints, Iz.All.GreaterThan(0)) + Assert.That(ints, Has.All.GreaterThan(0)) + Assert.That(ints, Has.None.LessThanOrEqualTo(0)) + Assert.That(strings, Text.All.Contains("a")) + Assert.That(strings, Has.All.Contains("a")) + Assert.That(strings, Has.Some.StartsWith("ba")) + Assert.That(strings, Has.Some.Property("Length").EqualTo(3)) + Assert.That(strings, Has.Some.StartsWith("BA").IgnoreCase) + Assert.That(doubles, Has.Some.EqualTo(1.0).Within(0.05)) + + ' Inherited syntax + Expect(ints, All.Not.Null) + Expect(ints, None.Null) + Expect(ints, All.InstanceOfType(GetType(Integer))) + Expect(strings, All.InstanceOfType(GetType(String))) + Expect(ints, Unique) + ' Only available using new syntax + Expect(strings, Iz.Not.Unique) + Expect(ints, All.GreaterThan(0)) + Expect(strings, All.Contains("a")) + Expect(strings, Some.StartsWith("ba")) + Expect(strings, Some.StartsWith("BA").IgnoreCase) + Expect(doubles, Some.EqualTo(1.0).Within(0.05)) + End Sub + + <Test()> _ + Public Sub SomeItemsTests() + + Dim mixed As Object() = {1, 2, "3", Nothing, "four", 100} + Dim strings As Object() = {"abc", "bad", "cab", "bad", "dad"} + + ' Not available using the classic syntax + + ' Helper syntax + Assert.That(mixed, Has.Some.Null) + Assert.That(mixed, Has.Some.InstanceOfType(GetType(Integer))) + Assert.That(mixed, Has.Some.InstanceOfType(GetType(String))) + Assert.That(strings, Has.Some.StartsWith("ba")) + Assert.That(strings, Has.Some.Not.StartsWith("ba")) + + ' Inherited syntax + Expect(mixed, Some.Null) + Expect(mixed, Some.InstanceOfType(GetType(Integer))) + Expect(mixed, Some.InstanceOfType(GetType(String))) + Expect(strings, Some.StartsWith("ba")) + Expect(strings, Some.Not.StartsWith("ba")) + End Sub + + <Test()> _ + Public Sub NoItemsTests() + + Dim ints As Object() = {1, 2, 3, 4, 5} + Dim strings As Object() = {"abc", "bad", "cab", "bad", "dad"} + + ' Not available using the classic syntax + + ' Helper syntax + Assert.That(ints, Has.None.Null) + Assert.That(ints, Has.None.InstanceOfType(GetType(String))) + Assert.That(ints, Has.None.GreaterThan(99)) + Assert.That(strings, Has.None.StartsWith("qu")) + + ' Inherited syntax + Expect(ints, None.Null) + Expect(ints, None.InstanceOfType(GetType(String))) + Expect(ints, None.GreaterThan(99)) + Expect(strings, None.StartsWith("qu")) + End Sub + + <Test()> _ + Public Sub CollectionContainsTests() + + Dim iarray As Integer() = {1, 2, 3} + Dim sarray As String() = {"a", "b", "c"} + + ' Classic syntax + 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.0R) + + ' Helper syntax + Assert.That(iarray, Has.Member(3)) + Assert.That(sarray, Has.Member("b")) + Assert.That(sarray, Has.No.Member("x")) + ' Showing that Contains uses NUnit equality + Assert.That(iarray, Has.Member(1.0R)) + + ' Only available using the new syntax + ' Note that EqualTo and SameAs do NOT give + ' identical results to Contains because + ' Contains uses Object.Equals() + Assert.That(iarray, Has.Some.EqualTo(3)) + 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.0R)) + Assert.That(iarray, Has.All.LessThan(10)) + Assert.That(sarray, Has.All.Length.EqualTo(1)) + Assert.That(sarray, Has.None.Property("Length").GreaterThan(3)) + + ' Inherited syntax + Expect(iarray, Contains(3)) + Expect(sarray, Contains("b")) + Expect(sarray, Has.No.Member("x")) + + ' Only available using new syntax + ' Note that EqualTo and SameAs do NOT give + ' identical results to Contains because + ' Contains uses Object.Equals() + Expect(iarray, Some.EqualTo(3)) + Expect(sarray, Some.EqualTo("b")) + Expect(sarray, None.EqualTo("x")) + Expect(iarray, All.LessThan(10)) + Expect(sarray, All.Length.EqualTo(1)) + Expect(sarray, None.Property("Length").GreaterThan(3)) + End Sub + + <Test()> _ + Public Sub CollectionEquivalenceTests() + + Dim ints1to5 As Integer() = {1, 2, 3, 4, 5} + Dim twothrees As Integer() = {1, 2, 3, 3, 4, 5} + Dim twofours As Integer() = {1, 2, 3, 4, 4, 5} + + ' Classic syntax + CollectionAssert.AreEquivalent(New Integer() {2, 1, 4, 3, 5}, ints1to5) + CollectionAssert.AreNotEquivalent(New Integer() {2, 2, 4, 3, 5}, ints1to5) + CollectionAssert.AreNotEquivalent(New Integer() {2, 4, 3, 5}, ints1to5) + CollectionAssert.AreNotEquivalent(New Integer() {2, 2, 1, 1, 4, 3, 5}, ints1to5) + CollectionAssert.AreNotEquivalent(twothrees, twofours) + + ' Helper syntax + Assert.That(New Integer() {2, 1, 4, 3, 5}, Iz.EquivalentTo(ints1to5)) + Assert.That(New Integer() {2, 2, 4, 3, 5}, Iz.Not.EquivalentTo(ints1to5)) + Assert.That(New Integer() {2, 4, 3, 5}, Iz.Not.EquivalentTo(ints1to5)) + Assert.That(New Integer() {2, 2, 1, 1, 4, 3, 5}, Iz.Not.EquivalentTo(ints1to5)) + Assert.That(twothrees, Iz.Not.EquivalentTo(twofours)) + + ' Inherited syntax + Expect(New Integer() {2, 1, 4, 3, 5}, EquivalentTo(ints1to5)) + End Sub + + <Test()> _ + Public Sub SubsetTests() + + Dim ints1to5 As Integer() = {1, 2, 3, 4, 5} + + ' Classic syntax + CollectionAssert.IsSubsetOf(New Integer() {1, 3, 5}, ints1to5) + CollectionAssert.IsSubsetOf(New Integer() {1, 2, 3, 4, 5}, ints1to5) + CollectionAssert.IsNotSubsetOf(New Integer() {2, 4, 6}, ints1to5) + CollectionAssert.IsNotSubsetOf(New Integer() {1, 2, 2, 2, 5}, ints1to5) + + ' Helper syntax + Assert.That(New Integer() {1, 3, 5}, Iz.SubsetOf(ints1to5)) + Assert.That(New Integer() {1, 2, 3, 4, 5}, Iz.SubsetOf(ints1to5)) + Assert.That(New Integer() {2, 4, 6}, Iz.Not.SubsetOf(ints1to5)) + + ' Inherited syntax + Expect(New Integer() {1, 3, 5}, SubsetOf(ints1to5)) + Expect(New Integer() {1, 2, 3, 4, 5}, SubsetOf(ints1to5)) + Expect(New Integer() {2, 4, 6}, Iz.Not.SubsetOf(ints1to5)) + End Sub +#End Region + +#Region "Property Tests" + <Test()> _ + Public Sub PropertyTests() + + Dim array As String() = {"abc", "bca", "xyz", "qrs"} + Dim array2 As String() = {"a", "ab", "abc"} + Dim list As New ArrayList(array) + + ' Not available using the classic syntax + + ' Helper syntax + ' Assert.That(list, Has.Property("Count")) + ' Assert.That(list, Has.No.Property("Length")) + + Assert.That("Hello", Has.Length.EqualTo(5)) + Assert.That("Hello", Has.Property("Length").EqualTo(5)) + Assert.That("Hello", Has.Property("Length").GreaterThan(3)) + + Assert.That(array, Has.Property("Length").EqualTo(4)) + Assert.That(array, Has.Length.EqualTo(4)) + Assert.That(array, Has.Property("Length").LessThan(10)) + + Assert.That(array, Has.All.Property("Length").EqualTo(3)) + Assert.That(array, Has.All.Length.EqualTo(3)) + Assert.That(array, Iz.All.Length.EqualTo(3)) + Assert.That(array, Has.All.Property("Length").EqualTo(3)) + Assert.That(array, Iz.All.Property("Length").EqualTo(3)) + + Assert.That(array2, Iz.Not.Property("Length").EqualTo(4)) + Assert.That(array2, Iz.Not.Length.EqualTo(4)) + Assert.That(array2, Has.No.Property("Length").GreaterThan(3)) + + ' Inherited syntax + ' Expect(list, Has.Property("Count")) + ' Expect(list, Has.No.Property("Nada")) + + Expect(array, All.Property("Length").EqualTo(3)) + Expect(array, All.Length.EqualTo(3)) + End Sub +#End Region + +#Region "Not Tests" + <Test()> _ + Public Sub NotTests() + ' Not available using the classic syntax + + ' Helper syntax + Assert.That(42, Iz.Not.Null) + Assert.That(42, Iz.Not.True) + Assert.That(42, Iz.Not.False) + Assert.That(2.5, Iz.Not.NaN) + Assert.That(2 + 2, Iz.Not.EqualTo(3)) + Assert.That(2 + 2, Iz.Not.Not.EqualTo(4)) + Assert.That(2 + 2, Iz.Not.Not.Not.EqualTo(5)) + + ' Inherited syntax + Expect(42, Iz.Not.Null) + Expect(42, Iz.Not.True) + Expect(42, Iz.Not.False) + Expect(2.5, Iz.Not.NaN) + Expect(2 + 2, Iz.Not.EqualTo(3)) + Expect(2 + 2, Iz.Not.Not.EqualTo(4)) + Expect(2 + 2, Iz.Not.Not.Not.EqualTo(5)) + End Sub +#End Region + + End Class + +End Namespace + diff --git a/tools/NUnit/samples/vb/syntax/vb-syntax.build b/tools/NUnit/samples/vb/syntax/vb-syntax.build new file mode 100644 index 0000000..aa0f584 --- /dev/null +++ b/tools/NUnit/samples/vb/syntax/vb-syntax.build @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<project name="vb-syntax" default="build"> + + <include buildfile="../../samples.common" /> + + <patternset id="source-files"> + <include name="AssemblyInfo.vb" /> + <include name="AssertSyntaxTests.vb" /> + </patternset> + +</project>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/syntax/vb-syntax.vbproj b/tools/NUnit/samples/vb/syntax/vb-syntax.vbproj new file mode 100644 index 0000000..082a46d --- /dev/null +++ b/tools/NUnit/samples/vb/syntax/vb-syntax.vbproj @@ -0,0 +1,29 @@ +<VisualStudioProject> + <VisualBasic ProjectType="Local" ProductVersion="7.10.3077" SchemaVersion="2.0" ProjectGuid="{6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}"> + <Build> + <Settings ApplicationIcon="" AssemblyKeyContainerName="" AssemblyName="vb-syntax" AssemblyOriginatorKeyFile="" AssemblyOriginatorKeyMode="None" DefaultClientScript="JScript" DefaultHTMLPageLayout="Grid" DefaultTargetSchema="IE50" DelaySign="false" OutputType="Library" OptionCompare="Binary" OptionExplicit="On" OptionStrict="Off" RootNamespace="NUnit.Samples" StartupObject="NUnit.Samples.(None)"> + <Config Name="Debug" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="true" DefineTrace="true" DebugSymbols="true" IncrementalBuild="true" Optimize="false" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + <Config Name="Release" BaseAddress="285212672" ConfigurationOverrideFile="" DefineConstants="" DefineDebug="false" DefineTrace="true" DebugSymbols="false" IncrementalBuild="false" Optimize="true" OutputPath="bin\" RegisterForComInterop="false" RemoveIntegerChecks="false" TreatWarningsAsErrors="false" WarningLevel="1" /> + </Settings> + <References> + <Reference Name="System" AssemblyName="System" /> + <Reference Name="System.Data" AssemblyName="System.Data" /> + <Reference Name="System.XML" AssemblyName="System.Xml" /> + <Reference Name="nunit.framework" AssemblyName="nunit.framework, Version=2.5, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" HintPath="..\..\..\bin\net-1.1\framework\nunit.framework.dll" /> + </References> + <Imports> + <Import Namespace="Microsoft.VisualBasic" /> + <Import Namespace="System" /> + <Import Namespace="System.Collections" /> + <Import Namespace="System.Data" /> + <Import Namespace="System.Diagnostics" /> + </Imports> + </Build> + <Files> + <Include> + <File RelPath="AssemblyInfo.vb" SubType="Code" BuildAction="Compile" /> + <File RelPath="AssertSyntaxTests.vb" SubType="Code" BuildAction="Compile" /> + </Include> + </Files> + </VisualBasic> +</VisualStudioProject>
\ No newline at end of file diff --git a/tools/NUnit/samples/vb/vb-samples.sln b/tools/NUnit/samples/vb/vb-samples.sln new file mode 100644 index 0000000..7bf8156 --- /dev/null +++ b/tools/NUnit/samples/vb/vb-samples.sln @@ -0,0 +1,37 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "vb-failures", "failures\vb-failures.vbproj", "{F199991B-6C8E-4AB0-9AAA-703CD4897700}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "vb-money", "money\vb-money.vbproj", "{95394B96-A794-48EA-9879-0E4EC79C5724}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "vb-syntax", "syntax\vb-syntax.vbproj", "{6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F199991B-6C8E-4AB0-9AAA-703CD4897700}.Debug.ActiveCfg = Debug|.NET + {F199991B-6C8E-4AB0-9AAA-703CD4897700}.Debug.Build.0 = Debug|.NET + {F199991B-6C8E-4AB0-9AAA-703CD4897700}.Release.ActiveCfg = Release|.NET + {F199991B-6C8E-4AB0-9AAA-703CD4897700}.Release.Build.0 = Release|.NET + {95394B96-A794-48EA-9879-0E4EC79C5724}.Debug.ActiveCfg = Debug|.NET + {95394B96-A794-48EA-9879-0E4EC79C5724}.Debug.Build.0 = Debug|.NET + {95394B96-A794-48EA-9879-0E4EC79C5724}.Release.ActiveCfg = Release|.NET + {95394B96-A794-48EA-9879-0E4EC79C5724}.Release.Build.0 = Release|.NET + {6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}.Debug.ActiveCfg = Debug|.NET + {6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}.Debug.Build.0 = Debug|.NET + {6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}.Release.ActiveCfg = Release|.NET + {6BEF566A-2691-4EE8-91AF-0390CCCDDAF1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/StyleCop/Docs/StyleCop.chm b/tools/StyleCop/Docs/StyleCop.chm Binary files differnew file mode 100644 index 0000000..cf062a0 --- /dev/null +++ b/tools/StyleCop/Docs/StyleCop.chm diff --git a/tools/StyleCop/Microsoft.SourceAnalysis.Targets b/tools/StyleCop/Microsoft.SourceAnalysis.Targets new file mode 100644 index 0000000..4b4a625 --- /dev/null +++ b/tools/StyleCop/Microsoft.SourceAnalysis.Targets @@ -0,0 +1,5 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!-- This targets file is obsolete and will be removed in a future version of StyleCop. --> + <!-- Redirect your imports to the Microsoft.StyleCop.Targets file. --> + <Import Project="Microsoft.StyleCop.Targets" /> +</Project> diff --git a/tools/StyleCop/Microsoft.StyleCop.CSharp.Rules.dll b/tools/StyleCop/Microsoft.StyleCop.CSharp.Rules.dll Binary files differnew file mode 100644 index 0000000..c9c50f5 --- /dev/null +++ b/tools/StyleCop/Microsoft.StyleCop.CSharp.Rules.dll diff --git a/tools/StyleCop/Microsoft.StyleCop.CSharp.dll b/tools/StyleCop/Microsoft.StyleCop.CSharp.dll Binary files differnew file mode 100644 index 0000000..80ed66a --- /dev/null +++ b/tools/StyleCop/Microsoft.StyleCop.CSharp.dll diff --git a/tools/StyleCop/Microsoft.StyleCop.Targets b/tools/StyleCop/Microsoft.StyleCop.Targets new file mode 100644 index 0000000..9220008 --- /dev/null +++ b/tools/StyleCop/Microsoft.StyleCop.Targets @@ -0,0 +1,117 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!-- Specify where tasks are implemented. --> + <UsingTask AssemblyFile="Microsoft.StyleCop.dll" TaskName="StyleCopTask"/> + + <PropertyGroup> + <BuildDependsOn>$(BuildDependsOn);StyleCop</BuildDependsOn> + <RebuildDependsOn>StyleCopForceFullAnalysis;$(RebuildDependsOn)</RebuildDependsOn> + </PropertyGroup> + + <!-- Define StyleCopForceFullAnalysis property. --> + <PropertyGroup Condition="('$(SourceAnalysisForceFullAnalysis)' != '') and ('$(StyleCopForceFullAnalysis)' == '')"> + <StyleCopForceFullAnalysis>$(SourceAnalysisForceFullAnalysis)</StyleCopForceFullAnalysis> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopForceFullAnalysis)' == ''"> + <StyleCopForceFullAnalysis>false</StyleCopForceFullAnalysis> + </PropertyGroup> + + <!-- Define StyleCopCacheResults property. --> + <PropertyGroup Condition="('$(SourceAnalysisCacheResults)' != '') and ('$(StyleCopCacheResults)' == '')"> + <StyleCopCacheResults>$(SourceAnalysisCacheResults)</StyleCopCacheResults> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopCacheResults)' == ''"> + <StyleCopCacheResults>true</StyleCopCacheResults> + </PropertyGroup> + + <!-- Define StyleCopTreatErrorsAsWarnings property. --> + <PropertyGroup Condition="('$(SourceAnalysisTreatErrorsAsWarnings)' != '') and ('$(StyleCopTreatErrorsAsWarnings)' == '')"> + <StyleCopTreatErrorsAsWarnings>$(SourceAnalysisTreatErrorsAsWarnings)</StyleCopTreatErrorsAsWarnings> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopTreatErrorsAsWarnings)' == ''"> + <StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings> + </PropertyGroup> + + <!-- Define StyleCopEnabled property. --> + <PropertyGroup Condition="('$(SourceAnalysisEnabled)' != '') and ('$(StyleCopEnabled)' == '')"> + <StyleCopEnabled>$(SourceAnalysisEnabled)</StyleCopEnabled> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopEnabled)' == ''"> + <StyleCopEnabled>true</StyleCopEnabled> + </PropertyGroup> + + <!-- Define StyleCopOverrideSettingsFile property. --> + <PropertyGroup Condition="('$(SourceAnalysisOverrideSettingsFile)' != '') and ('$(StyleCopOverrideSettingsFile)' == '')"> + <StyleCopOverrideSettingsFile>$(SourceAnalysisOverrideSettingsFile)</StyleCopOverrideSettingsFile> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopOverrideSettingsFile)' == ''"> + <StyleCopOverrideSettingsFile> </StyleCopOverrideSettingsFile> + </PropertyGroup> + + <!-- Define StyleCopOutputFile property. --> + <PropertyGroup Condition="('$(SourceAnalysisOutputFile)' != '') and ('$(StyleCopOutputFile)' == '')"> + <StyleCopOutputFile>$(SourceAnalysisOutputFile)</StyleCopOutputFile> + </PropertyGroup> + <PropertyGroup Condition="'$(StyleCopOutputFile)' == ''"> + <StyleCopOutputFile>$(IntermediateOutputPath)StyleCopViolations.xml</StyleCopOutputFile> + </PropertyGroup> + + <!-- Define all new properties which do not need to have both StyleCop and SourceAnalysis variations. --> + <PropertyGroup> + <!-- Specifying 0 will cause StyleCop to use the default violation count limit. + Specifying any positive number will cause StyleCop to use that number as the violation count limit. + Specifying any negative number will cause StyleCop to allow any number of violations without limit. --> + <StyleCopMaxViolationCount Condition="'$(StyleCopMaxViolationCount)' == ''">0</StyleCopMaxViolationCount> + </PropertyGroup> + + <!-- Define target: StyleCopForceFullAnalysis --> + <Target Name="StyleCopForceFullAnalysis"> + <CreateProperty Value="true"> + <Output TaskParameter="Value" PropertyName="StyleCopForceFullAnalysis" /> + </CreateProperty> + </Target> + + <!-- Define target: StyleCop --> + <Target Name="StyleCop" Condition="'$(StyleCopEnabled)' != 'false'"> + <Message Text="Forcing full StyleCop reanalysis." Condition="'$(StyleCopForceFullAnalysis)' == 'true'" Importance="Low" /> + + <!-- Determine what files should be checked. Take all Compile items, but exclude those that have + set ExcludeFromStyleCop=true or ExcludeFromSourceAnalysis=true. --> + <CreateItem Include="@(Compile)" Condition="('%(Compile.ExcludeFromStyleCop)' != 'true') and ('%(Compile.ExcludeFromSourceAnalysis)' != 'true')"> + <Output TaskParameter="Include" ItemName="StyleCopFiles"/> + </CreateItem> + + <Message Text="Analyzing @(StyleCopFiles)" Importance="Low" /> + + <!-- Show list of what files should be excluded. checked. Take all Compile items, but exclude those that have + set ExcludeFromStyleCop=true or ExcludeFromSourceAnalysis=true. --> + <CreateItem Include="@(Compile)" Condition="('%(Compile.ExcludeFromStyleCop)' == 'true') or ('%(Compile.ExcludeFromSourceAnalysis)' == 'true')"> + <Output TaskParameter="Include" ItemName="StyleCopExcludedFiles"/> + </CreateItem> + + <Message Text="Excluding @(StyleCopExcludedFiles)" Importance="Normal" /> + + <!-- Run the StyleCop MSBuild task. --> + <StyleCopTask + ProjectFullPath="$(MSBuildProjectFile)" + SourceFiles="@(StyleCopFiles)" + AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)" + ForceFullAnalysis="$(StyleCopForceFullAnalysis)" + DefineConstants="$(DefineConstants)" + TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)" + CacheResults="$(StyleCopCacheResults)" + OverrideSettingsFile="$(StyleCopOverrideSettingsFile)" + OutputFile="$(StyleCopOutputFile)" + MaxViolationCount="$(StyleCopMaxViolationCount)" + /> + + <!-- Make output files cleanable --> + <CreateItem Include="$(StyleCopOutputFile)"> + <Output TaskParameter="Include" ItemName="FileWrites"/> + </CreateItem> + + <!-- Add the StyleCop.cache file to the list of files we've written - so they can be cleaned up on a Build Clean. --> + <CreateItem Include="StyleCop.Cache" Condition="'$(StyleCopCacheResults)' == 'true'"> + <Output TaskParameter="Include" ItemName="FileWrites"/> + </CreateItem> + </Target> +</Project> diff --git a/tools/StyleCop/Microsoft.StyleCop.dll b/tools/StyleCop/Microsoft.StyleCop.dll Binary files differnew file mode 100644 index 0000000..aa995b6 --- /dev/null +++ b/tools/StyleCop/Microsoft.StyleCop.dll diff --git a/tools/StyleCop/Settings.StyleCop b/tools/StyleCop/Settings.StyleCop new file mode 100644 index 0000000..8be9507 --- /dev/null +++ b/tools/StyleCop/Settings.StyleCop @@ -0,0 +1,21 @@ +<StyleCopSettings Version="4.3"> + <Analyzers> + <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules"> + <AnalyzerSettings> + <CollectionProperty Name="Hungarian"> + <Value>as</Value> + <Value>do</Value> + <Value>id</Value> + <Value>if</Value> + <Value>in</Value> + <Value>is</Value> + <Value>my</Value> + <Value>no</Value> + <Value>on</Value> + <Value>to</Value> + <Value>ui</Value> + </CollectionProperty> + </AnalyzerSettings> + </Analyzer> + </Analyzers> +</StyleCopSettings>
\ No newline at end of file diff --git a/tools/StyleCop/StyleCopSettingsEditor.exe b/tools/StyleCop/StyleCopSettingsEditor.exe Binary files differnew file mode 100644 index 0000000..8f735a4 --- /dev/null +++ b/tools/StyleCop/StyleCopSettingsEditor.exe diff --git a/tools/drop.proj b/tools/drop.proj index 68e19ba..9a8d102 100644 --- a/tools/drop.proj +++ b/tools/drop.proj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\DotNetOpenAuth.automated.props"/> <Target Name="Layout" DependsOnTargets="BuildUnifiedProduct;ReSignDelaySignedAssemblies"> @@ -70,7 +71,6 @@ $(ProjectRoot)**\*.log*; $(ProjectRoot)**\*~; $(ProjectRoot)**\Debug\**; - $(ProjectRoot)**\Settings.StyleCop; $(ProjectRoot)**\StyleCop.Cache; $(ProjectRoot)Samples\**\DotNetOpenAuth.???; $(ProjectRoot)Samples\**\DotNetOpenAuth.resources.???; @@ -139,6 +139,7 @@ <DowngradeProjects Projects="@(SampleProjectTargets);@(SampleSolutionTargets)" DowngradeMvc2ToMvc1="$(DowngradeMvc2ToMvc1)" + Condition=" '$(DowngradeVS2010ToVS2008)' != 'false' " /> </Target> @@ -155,4 +156,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/tools/ohloh.proj b/tools/ohloh.proj index f1c41a6..cf98b38 100644 --- a/tools/ohloh.proj +++ b/tools/ohloh.proj @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\DotNetOpenAuth.automated.props"/> <Target Name="Build"> @@ -30,4 +31,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/vsi/vsi.proj b/vsi/vsi.proj index d46fadc..eca131e 100644 --- a/vsi/vsi.proj +++ b/vsi/vsi.proj @@ -1,4 +1,5 @@ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <Import Project="..\projecttemplates\ProjectTemplates.props"/> @@ -52,4 +53,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file diff --git a/vsix/vsix.proj b/vsix/vsix.proj index 636bff9..9fa8919 100644 --- a/vsix/vsix.proj +++ b/vsix/vsix.proj @@ -1,4 +1,5 @@ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " /> <Import Project="$(MSBuildProjectDirectory)\..\tools\DotNetOpenAuth.automated.props"/> <Import Project="..\projecttemplates\ProjectTemplates.props"/> @@ -130,4 +131,5 @@ </Target> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.automated.targets"/> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> </Project>
\ No newline at end of file |