diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-19 20:47:35 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-19 20:47:35 -0700 |
commit | d9beb0eb2429894f18cc0545bfd2ef7a5ac54589 (patch) | |
tree | 3330f0b5d53b012ca83d06c4d558834f18b4df9a /tools/NUnit/samples/cpp/managed/failures | |
parent | 558e51ae4b40e79b7d681a94d9b14afba846db19 (diff) | |
download | DotNetOpenAuth-d9beb0eb2429894f18cc0545bfd2ef7a5ac54589.zip DotNetOpenAuth-d9beb0eb2429894f18cc0545bfd2ef7a5ac54589.tar.gz DotNetOpenAuth-d9beb0eb2429894f18cc0545bfd2ef7a5ac54589.tar.bz2 |
Added NUnit runner to the repo.
Diffstat (limited to 'tools/NUnit/samples/cpp/managed/failures')
5 files changed, 302 insertions, 0 deletions
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(); + }; +} |