Permalink
Browse files

initial commit. includes bus rules kata from july 2011 meeting

  • Loading branch information...
0 parents commit f102566db186cd79085e6f195ee3d5420169c06a Ryan Cromwell committed Aug 1, 2011
Showing with 18,245 additions and 0 deletions.
  1. +11 −0 .gitignore
  2. +20 −0 BusinessRulesKataShared/BusinessRulesKataShared.sln
  3. +10 −0 BusinessRulesKataShared/BusinessRulesKataShared/BusinessRulesKataShared.crunchproject.local.xml
  4. +66 −0 BusinessRulesKataShared/BusinessRulesKataShared/BusinessRulesKataShared.csproj
  5. +154 −0 BusinessRulesKataShared/BusinessRulesKataShared/Class1.cs
  6. +36 −0 BusinessRulesKataShared/BusinessRulesKataShared/Properties/AssemblyInfo.cs
  7. +4 −0 BusinessRulesKataShared/BusinessRulesKataShared/packages.config
  8. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/Logo.ico
  9. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/NUnit.2.5.10.11092.nupkg
  10. +277 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/NUnitFitTests.html
  11. +342 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/fit-license.txt
  12. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/lib/nunit.framework.dll
  13. +10,407 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/lib/nunit.framework.xml
  14. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/lib/nunit.mocks.dll
  15. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/lib/pnunit.framework.dll
  16. +15 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/license.txt
  17. +124 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/NUnitTests.VisualState.xml
  18. +85 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/NUnitTests.config
  19. +14 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/NUnitTests.nunit
  20. +5,971 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/TestResult.xml
  21. +4 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/agent.conf
  22. +18 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/agent.log.conf
  23. +18 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/launcher.log.conf
  24. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/Failure.png
  25. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/Ignored.png
  26. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/Inconclusive.png
  27. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/Skipped.png
  28. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/Success.png
  29. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/fit.dll
  30. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/log4net.dll
  31. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit-console-runner.dll
  32. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit-gui-runner.dll
  33. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.core.dll
  34. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.core.interfaces.dll
  35. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.fixtures.dll
  36. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.uiexception.dll
  37. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.uikit.dll
  38. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/lib/nunit.util.dll
  39. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-agent-x86.exe
  40. +69 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-agent-x86.exe.config
  41. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-agent.exe
  42. +69 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-agent.exe.config
  43. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-console-x86.exe
  44. +69 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-console-x86.exe.config
  45. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-console.exe
  46. +69 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-console.exe.config
  47. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-x86.exe
  48. +83 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit-x86.exe.config
  49. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit.exe
  50. +83 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit.exe.config
  51. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/nunit.framework.dll
  52. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit-agent.exe
  53. +77 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit-agent.exe.config
  54. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit-launcher.exe
  55. +77 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit-launcher.exe.config
  56. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit.framework.dll
  57. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/pnunit.tests.dll
  58. BIN BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/runFile.exe
  59. +43 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/runFile.exe.config
  60. +2 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/runpnunit.bat
  61. +24 −0 BusinessRulesKataShared/packages/NUnit.2.5.10.11092/tools/test.conf
  62. +4 −0 BusinessRulesKataShared/packages/repositories.config
@@ -0,0 +1,11 @@
+*.suo
+*.csproj.user
+bin
+obj
+*.pdb
+_ReSharper*
+*.ReSharper.user
+*.ReSharper
+desktop.ini
+.eprj
+*.crunchsolution.*
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessRulesKataShared", "BusinessRulesKataShared\BusinessRulesKataShared.csproj", "{76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,10 @@
+<ProjectConfiguration>
+ <CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
+ <RunPreBuildEvents>false</RunPreBuildEvents>
+ <RunPostBuildEvents>false</RunPostBuildEvents>
+ <PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
+ <InstrumentAssembly>true</InstrumentAssembly>
+ <BuildOutputPath />
+ <DefaultTestTimeout>60000</DefaultTestTimeout>
+ <UseBuildConfiguration />
+</ProjectConfiguration>
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{76A1F1BD-9118-49AF-BCF2-26196F4FC6C7}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>BusinessRulesKataShared</RootNamespace>
+ <AssemblyName>BusinessRulesKataShared</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </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="nunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Class1.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </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>
@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+
+namespace Given_A_Payment
+{
+ [TestFixture]
+ public class When_For_Physical_Product
+ {
+ [Test]
+ public void Generates_Packing_Slip()
+ {
+ var packingSlipGenerator = new MockPackingSlipGenerator();
+
+ Payment payment = new Payment();
+ payment.ProductBeingPurchased = new Product();
+ payment.ProductBeingPurchased.IsPhysical = true;
+
+ OrderProcessor processor = new OrderProcessor(packingSlipGenerator);
+ PaymentResult result = processor.Process(payment);
+ Assert.IsTrue(result.GeneratePackingSlip);
+ }
+ }
+
+ [TestFixture]
+ public class When_For_A_Book
+ {
+ [Test]
+ public void Creates_A_Duplicate_PackingSlip_For_The_RoyaltyDepartment()
+ {
+ var packingSlipGenerator = new MockPackingSlipGenerator();
+
+ var payment = new Payment() { ProductBeingPurchased = new Book() };
+ var processor = new OrderProcessor(packingSlipGenerator);
+
+ var result = processor.Process(payment);
+
+ Assert.AreEqual(2, packingSlipGenerator.PackingSlipCount);
+ }
+ }
+ [TestFixture]
+ public class When_For_Membership
+ {
+ [Test]
+ public void should_activate_membership()
+ {
+
+ var payment = new Payment() { ProductBeingPurchased = new Membership() };
+ var processor = new OrderProcessor();
+
+ var result = processor.Process(payment);
+
+ Assert.IsTrue(((Membership)payment.ProductBeingPurchased).IsActivated);
+ }
+
+ [Test]
+ public void should_upgrade_membership()
+ {
+
+ var payment = new Payment() { ProductBeingPurchased = new UpgradeMembership() };
+ var processor = new OrderProcessor();
+
+ var result = processor.Process(payment);
+
+ Assert.IsTrue(((UpgradeMembership)payment.ProductBeingPurchased).IsUpgraded);
+ }
+ }
+
+ public class UpgradeMembership : Membership
+ {
+ public bool IsUpgraded { get; set; }
+ }
+
+
+ public class MockPackingSlipGenerator
+ {
+ public int PackingSlipCount { get; private set; }
+
+ public void CreatePackingSlip()
+ {
+ PackingSlipCount++;
+ }
+
+ public void CreateDuplicate()
+ {
+ PackingSlipCount++;
+ }
+ }
+
+ public class Payment
+ {
+ public Product ProductBeingPurchased { get; set; }
+
+ }
+
+ public class Membership : Product
+ {
+ public Membership()
+ {
+ IsPhysical = false;
+ }
+
+ public bool IsActivated { get; set; }
+ }
+ public class Book : Product
+ {
+ public Book()
+ {
+ IsPhysical = true;
+ }
+ }
+ public class Product
+ {
+ public bool IsPhysical { get; set; }
+
+ }
+
+ public class OrderProcessor
+ {
+ private readonly MockPackingSlipGenerator packingSlipGenerator;
+
+ public OrderProcessor(MockPackingSlipGenerator packingSlipGenerator)
+ {
+ this.packingSlipGenerator = packingSlipGenerator;
+ }
+
+ public OrderProcessor()
+ {
+ }
+
+ public PaymentResult Process(Payment payment)
+ {
+ var product = payment.ProductBeingPurchased;
+
+ if (product.IsPhysical)
+ packingSlipGenerator.CreatePackingSlip();
+
+ if (product is Book)
+ packingSlipGenerator.CreateDuplicate();
+ if (product is Membership)
+ ((Membership)product).IsActivated = true;
+
+ return new PaymentResult() {GeneratePackingSlip = true};
+ }
+
+ }
+
+ public class PaymentResult
+ {
+ public bool GeneratePackingSlip { get; set; }
+ }
+}
@@ -0,0 +1,36 @@
+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("BusinessRulesKataShared")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("BusinessRulesKataShared")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[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("01b1f8ad-0223-4c68-80de-16ba1130cbb2")]
+
+// 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.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NUnit" version="2.5.10.11092" />
+</packages>
Binary file not shown.
Oops, something went wrong.

0 comments on commit f102566

Please sign in to comment.