Commit 5b59051
Changed files (5)
src
domain
test
src/domain/domain.csproj
@@ -45,7 +45,9 @@
<Compile Include="CommoditySplits.cs" />
<Compile Include="DeclineCurve.cs" />
<Compile Include="DrillSchedule.cs" />
+ <Compile Include="Month.cs" />
<Compile Include="Oppurtunity.cs" />
+ <Compile Include="Percent.cs" />
<Compile Include="Production.cs" />
<Compile Include="Quantity.cs" />
<Compile Include="TypeCurve.cs" />
src/domain/Month.cs
@@ -0,0 +1,50 @@
+namespace domain
+{
+ using System;
+
+ public class Month
+ {
+ int year;
+ int month;
+
+ public Month(int year, int month)
+ {
+ this.year = year;
+ this.month = month;
+ }
+
+ public bool Equals(Month other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.year == year && other.month == month;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Month)) return false;
+ return Equals((Month) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return (year*397) ^ month;
+ }
+ }
+
+ public Month Plus(int months)
+ {
+ var newMonth = new DateTime(year, month, 01).AddMonths(months);
+ return new Month(newMonth.Year, newMonth.Month);
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0} {1}", year, month);
+ }
+ }
+}
src/domain/Percent.cs
@@ -0,0 +1,55 @@
+namespace domain
+{
+ using System;
+
+ public class Percent
+ {
+ public static Percent Zero = new Percent(0);
+ decimal percentage;
+
+ public Percent(decimal percentage)
+ {
+ this.percentage = percentage;
+ }
+
+ public bool Equals(Percent other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.percentage == percentage;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Percent)) return false;
+ return Equals((Percent) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return percentage.GetHashCode();
+ }
+
+ public IQuantity Reduce(IQuantity original)
+ {
+ return new Quantity(PortionOf(original.Amount), original.Units);
+ }
+
+ public Percent Plus(Percent other)
+ {
+ return new Percent(percentage + other.percentage);
+ }
+
+ public decimal PortionOf(decimal amount)
+ {
+ return amount*percentage;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0} %", percentage);
+ }
+ }
+}
src/domain/Well.cs
@@ -28,110 +28,12 @@ namespace domain
}
}
- public class Month
- {
- readonly int year;
- readonly int month;
-
- public Month(int year, int month)
- {
- this.year = year;
- this.month = month;
- }
-
- public bool Equals(Month other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return other.year == year && other.month == month;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Month)) return false;
- return Equals((Month) obj);
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- return (year*397) ^ month;
- }
- }
-
- public Month Plus(int months)
- {
- var newMonth = new DateTime(year, month, 01).AddMonths(months);
- return new Month(newMonth.Year, newMonth.Month);
- }
-
- public override string ToString()
- {
- return string.Format("{0} {1}", year, month);
- }
- }
-
public interface IWell
{
IQuantity GrossProductionFor<T>(Month month) where T : ICommodity, new();
IQuantity NetProductionFor<T>(Month month) where T : ICommodity, new();
}
- public class Percent
- {
- readonly decimal percentage;
- public static Percent Zero = new Percent(0);
-
- public Percent(decimal percentage)
- {
- this.percentage = percentage;
- }
-
- public bool Equals(Percent other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return other.percentage == percentage;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (Percent)) return false;
- return Equals((Percent) obj);
- }
-
- public override int GetHashCode()
- {
- return percentage.GetHashCode();
- }
-
- public IQuantity Reduce(IQuantity original)
- {
- //return new ProratedQuantity(original, this);
- return new Quantity(PortionOf(original.Amount), original.Units);
- }
-
- public Percent Plus(Percent other)
- {
- return new Percent(percentage + other.percentage);
- }
-
- public decimal PortionOf(decimal amount)
- {
- return amount*percentage;
- }
-
- public override string ToString()
- {
- return string.Format("{0} %", percentage);
- }
- }
-
public static class Units
{
public static Percent Percent(this decimal percentage)
src/test/WellSpecs.cs
@@ -10,42 +10,81 @@
{
public class when_estimating_production
{
- It should_be_able_to_tell_the_estimated_total_production_for_any_month= () =>
+ Establish context = () =>
{
- var parkland100Percent = new Oppurtunity();
- parkland100Percent.WorkingInterest(100m.Percent());
- var declineCurve = new DeclineCurve();
- declineCurve.Composition<Gas>(100m.Percent());
- declineCurve.Add(0, 100.BOED());
- parkland100Percent.DeclinesUsing(declineCurve);
-
- var schedule = new DrillSchedule();
- var jan2013 = new Month(2013, 01);
- schedule.Include(parkland100Percent.BringOnlineOn(jan2013));
- schedule.EstimatedGrossProductionFor<All>(jan2013).ShouldEqual(100.BOED());
- schedule.EstimatedGrossProductionFor<Gas>(jan2013).ShouldEqual(100.BOED());
- schedule.EstimatedGrossProductionFor<Oil>(jan2013).ShouldEqual(0.BOED());
- schedule.EstimatedGrossProductionFor<NGL>(jan2013).ShouldEqual(0.BOED());
- schedule.EstimatedGrossProductionFor<Condensate>(jan2013).ShouldEqual(0.BOED());
+ sut = new DrillSchedule();
};
- It should_be_able_to_tell_the_estimated_net_total_production_for_any_month = () =>
+ static DrillSchedule sut;
+
+ public class when_100_percent_working_interest
{
- var parkland75Percent = new Oppurtunity();
- parkland75Percent.WorkingInterest(75m.Percent());
- var declineCurve = new DeclineCurve();
- declineCurve.Composition<Gas>(50m.Percent());
- declineCurve.Composition<Oil>(50m.Percent());
- declineCurve.Add(0, 100.BOED());
- parkland75Percent.DeclinesUsing(declineCurve);
-
- var schedule = new DrillSchedule();
- var jan2013 = new Month(2013, 01);
- schedule.Include(parkland75Percent.BringOnlineOn(jan2013));
- schedule.EstimatedNetProductionFor<All>(jan2013).ShouldEqual(75.BOED());
- schedule.EstimatedNetProductionFor<Gas>(jan2013).ShouldEqual(37.5m.BOED());
- schedule.EstimatedNetProductionFor<Oil>(jan2013).ShouldEqual(37.5m.BOED());
- };
+ Establish context = ()=>
+ {
+ parkland100Percent = new Oppurtunity();
+ parkland100Percent.WorkingInterest(100m.Percent());
+ var declineCurve = new DeclineCurve();
+ declineCurve.Composition<Gas>(100m.Percent());
+ declineCurve.Add(0, 100.BOED());
+ parkland100Percent.DeclinesUsing(declineCurve);
+
+ jan2013 = new Month(2013, 01);
+ };
+
+ Because of = ()=>
+ {
+ sut.Include(parkland100Percent.BringOnlineOn(jan2013));
+ };
+
+ It should_be_able_to_tell_the_estimated_total_production_for_any_month= () =>
+ {
+ sut.EstimatedGrossProductionFor<All>(jan2013).ShouldEqual(100.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_production_for_gas=()=>
+ {
+ sut.EstimatedGrossProductionFor<Gas>(jan2013).ShouldEqual(100.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_production_for_oil=()=>
+ {
+ sut.EstimatedGrossProductionFor<Oil>(jan2013).ShouldEqual(0.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_production_for_ngl=()=>
+ {
+ sut.EstimatedGrossProductionFor<NGL>(jan2013).ShouldEqual(0.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_production_for_condensate=()=>
+ {
+ sut.EstimatedGrossProductionFor<Condensate>(jan2013).ShouldEqual(0.BOED());
+ };
+
+ static Oppurtunity parkland100Percent;
+ static Month jan2013;
+ }
+
+ public class when_reduced_working_interest
+ {
+ It should_be_able_to_tell_the_estimated_net_total_production_for_any_month = () =>
+ {
+ var parkland75Percent = new Oppurtunity();
+ parkland75Percent.WorkingInterest(75m.Percent());
+ var declineCurve = new DeclineCurve();
+ declineCurve.Composition<Gas>(50m.Percent());
+ declineCurve.Composition<Oil>(50m.Percent());
+ declineCurve.Add(0, 100.BOED());
+ parkland75Percent.DeclinesUsing(declineCurve);
+
+ var schedule = new DrillSchedule();
+ var jan2013 = new Month(2013, 01);
+ schedule.Include(parkland75Percent.BringOnlineOn(jan2013));
+ schedule.EstimatedNetProductionFor<All>(jan2013).ShouldEqual(75.BOED());
+ schedule.EstimatedNetProductionFor<Gas>(jan2013).ShouldEqual(37.5m.BOED());
+ schedule.EstimatedNetProductionFor<Oil>(jan2013).ShouldEqual(37.5m.BOED());
+ };
+ }
}
}
}