Skip to content

Commit

Permalink
start a test project using NUnit framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristaba committed Dec 30, 2010
1 parent 4a2e225 commit 866cc2b
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 119 deletions.
9 changes: 6 additions & 3 deletions ParrotSharp.csproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,7 +10,6 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Parrot</RootNamespace>
<AssemblyName>ParrotSharp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -56,7 +55,6 @@
<Compile Include="src\Pmc\String.cs" />
<Compile Include="src\Pmc\Integer.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\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.
Expand All @@ -68,4 +66,9 @@
<ItemGroup>
<Folder Include="src\Pmc\" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties InternalTargetFrameworkVersion="3.5" />
</MonoDevelop>
</ProjectExtensions>
</Project>
14 changes: 7 additions & 7 deletions ParrotSharp.sln
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParrotSharp", "ParrotSharp.csproj", "{AAED9261-C134-4905-88E6-197FBEA661F8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParrotTest", "ParrotTest\ParrotTest.csproj", "{D5EE4663-DB60-4B96-825A-D05842A9F8D0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParrotSharpTest", "ParrotSharpTest\ParrotSharpTest.csproj", "{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,10 +15,10 @@ Global
{AAED9261-C134-4905-88E6-197FBEA661F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAED9261-C134-4905-88E6-197FBEA661F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAED9261-C134-4905-88E6-197FBEA661F8}.Release|Any CPU.Build.0 = Release|Any CPU
{D5EE4663-DB60-4B96-825A-D05842A9F8D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5EE4663-DB60-4B96-825A-D05842A9F8D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5EE4663-DB60-4B96-825A-D05842A9F8D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5EE4663-DB60-4B96-825A-D05842A9F8D0}.Release|Any CPU.Build.0 = Release|Any CPU
{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = ParrotSharp.csproj
Expand Down
38 changes: 38 additions & 0 deletions ParrotSharpTest/PMC_Test.cs
@@ -0,0 +1,38 @@
using NUnit.Framework;
using ParrotSharp;
using ParrotSharp.Pmc;
using System;

namespace ParrotSharpTest
{
[TestFixture()]
public class PMC_Test {

[Test()]
public void BoxString() {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(Parrot_Test.ParentInterpreter, exename);

Parrot_PMC box = "This is a parrot string".ToParrotStringPMC(parrot);
Assert.AreEqual("This is a parrot string", box.ToString(), "Can't box string into a PMC");
}

[Test()]
public void InvokeMethod() {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(Parrot_Test.ParentInterpreter, exename);

Parrot_PMC pmc_string = "This is a parrot string".ToParrotStringPMC(parrot);
IPMCFactory<CallContext> sign_factory = CallContext.GetFactory(parrot);
CallContext sign = sign_factory.Instance();
sign.Signature = "PiSS->".ToParrotString(parrot);
sign.AddArgument(pmc_string);
sign.AddArgument("string".ToParrotStringPMC(parrot));
sign.AddArgument("pmc".ToParrotStringPMC(parrot));

pmc_string.InvokeMethod("replace".ToParrotString(parrot), sign);
Assert.AreEqual("This is a parrot pmc", pmc_string.ToString(), "Error when invoking a method");
}

}
}
Expand Up @@ -3,12 +3,12 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D5EE4663-DB60-4B96-825A-D05842A9F8D0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ParrotTest</RootNamespace>
<AssemblyName>ParrotTest</AssemblyName>
<ProjectGuid>{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ParrotSharpTest</RootNamespace>
<AssemblyName>ParrotSharpTest</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -18,25 +18,27 @@
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.core, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Package>mono-nunit</Package>
</Reference>
<Reference Include="nunit.framework, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Package>mono-nunit</Package>
</Reference>
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="PMC_Test.cs" />
<Compile Include="Parrot_Test.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ParrotSharp.csproj">
Expand Down
31 changes: 31 additions & 0 deletions ParrotSharpTest/Parrot_Test.cs
@@ -0,0 +1,31 @@
using NUnit.Framework;
using ParrotSharp;
using ParrotSharp.Pmc;
using System;

namespace ParrotSharpTest
{
[TestFixture()]
public class Parrot_Test {

static private Parrot ParrotParent = null;

static public Parrot ParentInterpreter {
get {
if(ParrotParent != null) return ParrotParent;
else {
ParrotParent = new Parrot();
return ParrotParent;
}
}
}

[Test()]
public void CreateParrot() {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(ParentInterpreter, exename);
Assert.AreNotEqual(IntPtr.Zero, parrot.RawPointer, "Unable to create a new Parrot interpreter");
}

}
}
27 changes: 0 additions & 27 deletions ParrotTest/AssemblyInfo.cs

This file was deleted.

56 changes: 0 additions & 56 deletions ParrotTest/Main.cs

This file was deleted.

15 changes: 0 additions & 15 deletions ParrotTest/test.pir

This file was deleted.

0 comments on commit 866cc2b

Please sign in to comment.