summaryrefslogtreecommitdiff
path: root/DesignPatterns/src/test/DesignPatterns.Test
diff options
context:
space:
mode:
authormo.khan <mo.khan@a0a4a051-f042-0410-9e78-9fae330bdb64>2008-01-05 07:16:52 +0000
committermo.khan <mo.khan@a0a4a051-f042-0410-9e78-9fae330bdb64>2008-01-05 07:16:52 +0000
commit8c137f229c36a777ead5cacb3350cb8692646292 (patch)
tree92876c5da0ffd17767e38f94a44415ac27a3c73e /DesignPatterns/src/test/DesignPatterns.Test
parentcbdf42a6427eef7849d1ab7731f9185b410431d3 (diff)
git-svn-id: http://mokhan.googlecode.com/svn/trunk@9 a0a4a051-f042-0410-9e78-9fae330bdb64
Diffstat (limited to 'DesignPatterns/src/test/DesignPatterns.Test')
-rw-r--r--DesignPatterns/src/test/DesignPatterns.Test/BankAccountTest.cs53
-rw-r--r--DesignPatterns/src/test/DesignPatterns.Test/DesignPatterns.Test.csproj63
-rw-r--r--DesignPatterns/src/test/DesignPatterns.Test/MoneyTest.cs52
-rw-r--r--DesignPatterns/src/test/DesignPatterns.Test/PosTerminalTest.cs17
-rw-r--r--DesignPatterns/src/test/DesignPatterns.Test/Properties/AssemblyInfo.cs35
5 files changed, 220 insertions, 0 deletions
diff --git a/DesignPatterns/src/test/DesignPatterns.Test/BankAccountTest.cs b/DesignPatterns/src/test/DesignPatterns.Test/BankAccountTest.cs
new file mode 100644
index 0000000..0c7357a
--- /dev/null
+++ b/DesignPatterns/src/test/DesignPatterns.Test/BankAccountTest.cs
@@ -0,0 +1,53 @@
+using System;
+using DesignPatterns.Test;
+using MbUnit.Framework;
+
+namespace DesignPatterns.Factory {
+ [TestFixture]
+ public class BankAccountTest {
+ [Test]
+ public void Should_Create_A_Cibc_Chequing_Account( ) {
+ IBank bank = new CibcBank( );
+ IBankAccountFactory factory = bank.GetAccountFactory( );
+ IBankAccount chequingAccount = factory.CreateChequingAccount( );
+ Assert.IsTrue( chequingAccount.Balance.Amount == 0, "Should be zero but was: " + chequingAccount.Balance.Amount );
+ }
+
+ [Test]
+ public void Should_Create_A_Cibc_Savings_Account( ) {
+ IBank bank = new CibcBank( );
+ IBankAccountFactory factory = bank.GetAccountFactory( );
+ IBankAccount savingsAccount = factory.CreateSavingsAccount( );
+ Assert.IsTrue( savingsAccount.Balance.Amount == 0, "Should be zero but was: " + savingsAccount.Balance.Amount );
+ }
+
+ [Test]
+ public void Should_Create_A_Royal_Bank_Chequing_Account( ) {
+ IBank bank = new RoyalBank( );
+ IBankAccountFactory factory = bank.GetAccountFactory( );
+ IBankAccount chequingAccount = factory.CreateChequingAccount( );
+ Assert.IsTrue( chequingAccount.Balance.Amount == 0, "Should be zero but was: " + chequingAccount.Balance.Amount );
+ }
+
+ [Test]
+ public void Should_Create_A_Royal_Bank_Savings_Account( ) {
+ IBank bank = new RoyalBank( );
+ IBankAccountFactory factory = bank.GetAccountFactory( );
+ IBankAccount savingsAccount = factory.CreateSavingsAccount( );
+ Assert.IsTrue( savingsAccount.Balance.Amount == 0, "Should be zero but was: " + savingsAccount.Balance.Amount );
+ }
+
+ [Test]
+ public void _Should_Have_A_Balance( ) {
+ IBankAccount account = new BankAccount( new Money( 5 ) );
+ Assert.IsTrue( account.Balance.Equals( new Money( 5 ) ) );
+ }
+
+ [Test]
+ public void Should_Have_Account_Number( ) {
+ string accountNumber = Guid.NewGuid( ).ToString( );
+ IBankAccount account = new BankAccount( new Money( 500 ), accountNumber );
+ Assert.IsTrue( accountNumber == account.AccountNumber );
+ }
+ }
+} \ No newline at end of file
diff --git a/DesignPatterns/src/test/DesignPatterns.Test/DesignPatterns.Test.csproj b/DesignPatterns/src/test/DesignPatterns.Test/DesignPatterns.Test.csproj
new file mode 100644
index 0000000..afd60e7
--- /dev/null
+++ b/DesignPatterns/src/test/DesignPatterns.Test/DesignPatterns.Test.csproj
@@ -0,0 +1,63 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{51D18D95-959C-499E-8363-7FEFF817797F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DesignPatterns.Test</RootNamespace>
+ <AssemblyName>DesignPatterns.Test</AssemblyName>
+ </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>
+ </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="MbUnit.Framework, Version=1.0.2700.29885, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\tools\MbUnit\MbUnit.Framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="BankAccountTest.cs" />
+ <Compile Include="MoneyTest.cs" />
+ <Compile Include="PosTerminalTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\app\DesignPatterns.Factory\DesignPatterns.Factory.csproj">
+ <Project>{0AAEDFE4-421D-4B3B-8629-5A20EC13F379}</Project>
+ <Name>DesignPatterns.Factory</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\app\DesignPatterns.State\DesignPatterns.State.csproj">
+ <Project>{21E02E54-3D4F-457A-B521-D2472ABC55CE}</Project>
+ <Name>DesignPatterns.State</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/DesignPatterns/src/test/DesignPatterns.Test/MoneyTest.cs b/DesignPatterns/src/test/DesignPatterns.Test/MoneyTest.cs
new file mode 100644
index 0000000..4f999e5
--- /dev/null
+++ b/DesignPatterns/src/test/DesignPatterns.Test/MoneyTest.cs
@@ -0,0 +1,52 @@
+using DesignPatterns.Factory;
+using MbUnit.Framework;
+
+namespace DesignPatterns.Test {
+ [TestFixture]
+ public class MoneyTest {
+ [Test]
+ public void Should_Be_Equal( ) {
+ Assert.IsTrue( new Money( 5 ).Equals( new Money( 5 ) ) );
+ }
+
+ [Test]
+ public void _Should_Be_Able_To_Add_Two_Monies_Together( ) {
+ IMoney sum = new Money( 5 ).Add( new Money( 5 ) );
+ Assert.IsTrue( sum.Equals( new Money( 10 ) ) );
+ }
+
+ [Test]
+ public void _Should_Be_Able_To_Subtract_Two_Monies( ) {
+ IMoney balance = new Money( 5 ).Subtract( new Money( 3 ) );
+ Assert.IsTrue( balance.Equals( new Money( 2 ) ), "Should have a 2 monies" );
+ }
+
+ [Test]
+ public void _Should_Be_Able_To_Subtract_Many_Monies( ) {
+ IMoney balance = new Money( 5 ).Subtract( new Money( 3 ) ).Subtract( new Money( 1 ) );
+ Assert.IsTrue( balance.Equals( new Money( 1 ) ), "Should have 1 monies" );
+ }
+
+ [Test]
+ public void Should_Have_A_Currency( ) {
+ new Money( 5, Currency.Canadian );
+ }
+
+ [Test]
+ [ExpectedException( typeof( CannotAddMoniesException ) )]
+ public void Should_Only_Add_Monies_Of_The_Same_Currency( ) {
+ new Money( 5, Currency.Canadian ).Add( new Money( 5, Currency.American ) );
+ }
+
+ [Test]
+ [ExpectedException( typeof( NegativeMoneyException ) )]
+ public void Should_Not_Be_Able_To_Construct_Negative_Money( ) {
+ new Money( -5 );
+ }
+
+ [Test]
+ public void Should_Return_5_Monies( ) {
+ Assert.IsTrue( new Money( 5 ).Equals( new Money( 5 ).Add( null ) ) );
+ }
+ }
+} \ No newline at end of file
diff --git a/DesignPatterns/src/test/DesignPatterns.Test/PosTerminalTest.cs b/DesignPatterns/src/test/DesignPatterns.Test/PosTerminalTest.cs
new file mode 100644
index 0000000..f69e45c
--- /dev/null
+++ b/DesignPatterns/src/test/DesignPatterns.Test/PosTerminalTest.cs
@@ -0,0 +1,17 @@
+using DesignPatterns.State;
+using MbUnit.Framework;
+
+namespace DesignPatterns.Test {
+ [TestFixture]
+ public class PosTerminalTest {
+ [Test]
+ public void Should_( ) {
+ IPosTerminal terminal = new PosTerminal( );
+ terminal.SwipeCard( "6278080000008205" );
+ terminal.EnterAmount( 99.99 );
+ terminal.EnterPin( "8012" );
+ terminal.ProcessTransaction( );
+ terminal.PrintReceipt( );
+ }
+ }
+} \ No newline at end of file
diff --git a/DesignPatterns/src/test/DesignPatterns.Test/Properties/AssemblyInfo.cs b/DesignPatterns/src/test/DesignPatterns.Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bcb5b5d
--- /dev/null
+++ b/DesignPatterns/src/test/DesignPatterns.Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+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("DesignPatterns.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DesignPatterns.Test")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a9a41066-98c3-4ecf-b37f-3fdfb035b12d")]
+
+// 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")]