Commit 8ce3b33

mo k <mo@mokhan.ca>
2012-04-26 22:59:48
implement Accept method on Production.
1 parent 3703a03
src/domain/Greeting.cs
@@ -1,13 +1,13 @@
-namespace domain
-{
-    public class Greeting
-    {
-      public string Hello()
-      {
-        return "hello";
-      }
-      public string Goodbye(){
-        return "goodbye";
-      }
-    }
-}
+namespace domain
+{
+    public class Greeting
+    {
+      public string Hello()
+      {
+        return "hello";
+      }
+      public string Goodbye(){
+        return "goodbye";
+      }
+    }
+}
src/domain/TypeCurve.cs
@@ -3,8 +3,9 @@ namespace domain
   using System;
   using System.Linq;
   using System.Collections.Generic;
+  using utility;
 
-  public class TypeCurve
+  public class TypeCurve : IVisitable<Production>
   {
     IEnumerable<Production> production;
 
@@ -22,6 +23,15 @@ namespace domain
 
     public virtual void Accept(Action<Production> visitor)
     {
+      this.production.Each(x => 
+      {
+        visitor(x);
+      });
+    }
+
+    public virtual void Accept(IVisitor<Production> visitor)
+    {
+      Accept(visitor.Visit);
     }
   }
 }
src/test/test.csproj
@@ -58,6 +58,7 @@
     <Compile Include="ProductionScheduleSpecs.cs" />
     <Compile Include="QuantitySpecs.cs" />
     <Compile Include="RangeSpecs.cs" />
+    <Compile Include="TypeCurveSpecs.cs" />
     <Compile Include="WellSpecs.cs" />
   </ItemGroup>
   <ItemGroup>
src/test/TypeCurveSpecs.cs
@@ -0,0 +1,40 @@
+namespace test
+{
+  using System.Collections.Generic;
+  using Machine.Specifications;
+  using domain;
+  using utility;
+
+  public class TypeCurveSpecs 
+  {
+    Establish context = () =>
+    {
+      production = new Production(Month.Now(), 0m.BOED(), null);
+      sut = new TypeCurve(new List<Production>()
+      {
+        production
+      });
+    };
+
+    static TypeCurve sut;
+    static Production production;
+
+    public class when_poking_at_the_production_for_each_month
+    {
+      It should_allow_visitors_to_visit_each_one = () => 
+      {
+        visitor.received(x => x.Visit(production));
+      };
+      Establish context = () =>
+      {
+        visitor = Mock.An<IVisitor<Production>>();
+      };
+      Because of = () =>
+      {
+        sut.Accept(visitor);
+      };
+
+      static IVisitor<Production> visitor;
+    }
+  }
+}