Added Exception tests.

This commit is contained in:
Charles Betros 2015-11-04 22:26:57 -06:00
parent c746643255
commit f09ef07cca
4 changed files with 254 additions and 0 deletions

View file

@ -0,0 +1,36 @@
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using 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.
[assembly: AssemblyTitle("Package Name")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company")]
[assembly: AssemblyProduct("Package Name")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(false)]
[assembly: NeutralResourcesLanguage("en-US")]
// 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.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9DF5C0A9-B91C-4647-B939-E47513743A0C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cosmos.Compiler.Tests.Exceptions</RootNamespace>
<AssemblyName>Cosmos.Compiler.Tests.Exceptions</AssemblyName>
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Cosmos.System, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
<Reference Include="Cosmos.Debug.Kernel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Kernel.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj">
<Project>{E6D3B644-C487-472D-A978-C1A82D0C099B}</Project>
<Name>Cosmos.TestRunner.TestController</Name>
</ProjectReference>
</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>
-->
</Project>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{85e13410-c85a-4b0c-bee5-f9a120ecc94e}</ProjectGuid>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<Name>Cosmos.Compiler.Tests.ExceptionsBoot</Name>
<BinFormat>elf</BinFormat>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Profile>VMware</Profile>
<!-- Looks like this was a mispelled attribute. Replaced by DebugEnabled below.
<DebugEnable>true</DebugEnable>
-->
<DebugEnabled>true</DebugEnabled>
<DebugMode>Source</DebugMode>
<TraceMode>User</TraceMode>
<EnableGDB>False</EnableGDB>
<StartCosmosGDB>false</StartCosmosGDB>
<VMWareEdition>Player</VMWareEdition>
<OutputPath>bin\Debug\</OutputPath>
<Name>Cosmos.Compiler.Tests.ExceptionsBoot</Name>
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
<Deployment>ISO</Deployment>
<Launch>VMware</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include=".\Cosmos.Compiler.Tests.Exceptions.">
<Name>Cosmos.Compiler.Tests.Exceptions</Name>
<Project>{9df5c0a9-b91c-4647-b939-e47513743a0c}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/>
<Reference Include="Cosmos.System.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/>
<Reference Include="Cosmos.Debug.Kernel.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/>
</ItemGroup>
<!--<ItemGroup>
<Content Include="Cosmos.bxrc">
<SubType>Content</SubType>
</Content>
</ItemGroup>-->
<Import Project="$(MSBuildExtensionsPath)\Cosmos\Cosmos.targets" />
</Project>

View file

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace Cosmos.Compiler.Tests.Exceptions
{
using Cosmos.TestRunner;
public class Kernel : Sys.Kernel
{
private global::Cosmos.Debug.Kernel.Debugger mDebugger = new global::Cosmos.Debug.Kernel.Debugger("User", "Test");
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully, now start testing");
}
protected override void Run()
{
mDebugger.Send("Run");
TestSimpleException();
mDebugger.Send("START: Test throw Exception() in method and catch in caller.");
try
{
TestReturnSimpleException();
}
catch (Exception ex)
{
Console.WriteLine("Caught exception.");
mDebugger.Send("EXCEPTION: " + ex.Message);
}
finally
{
Console.WriteLine("Finally");
mDebugger.Send("EXCEPTION: Finally");
}
mDebugger.Send("END:");
mDebugger.Send("START: Test throw nested Exception() in method and catch in caller.");
try
{
TestThrowNestedException();
}
catch (Exception ex)
{
Console.WriteLine("Caught exception.");
mDebugger.Send("EXCEPTION: " + ex.Message);
}
finally
{
Console.WriteLine("Finally");
mDebugger.Send("EXCEPTION: Finally");
}
mDebugger.Send("END:");
TestController.Completed();
}
private void TestSimpleException()
{
mDebugger.Send("START: Test throw Exception() in method and catch in callee.");
try
{
throw new Exception("throw new Exception()");
}
catch (Exception ex)
{
Console.WriteLine("Caught exception.");
mDebugger.Send("EXCEPTION: " + ex.Message);
}
mDebugger.Send("END:");
}
private void TestReturnSimpleException()
{
throw new Exception("throw new Exception()");
}
private void TestThrowNestedException()
{
try
{
try
{
TestArgumentNullException(null);
}
catch (ArgumentNullException ex)
{
Console.WriteLine("Caught nested exception.");
mDebugger.Send("EXCEPTION: " + ex.Message);
}
TestReturnSimpleException();
}
catch (Exception ex)
{
Console.WriteLine("Caught exception.");
mDebugger.Send("EXCEPTION: " + ex.Message);
}
}
private void TestArgumentNullException(string arg)
{
if (arg == null)
{
throw new ArgumentNullException(arg, "arg can not be null.");
}
}
}
}