Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mokhan/cs_practice
base: d04bc81d09
...
head fork: mokhan/cs_practice
compare: 071efd4c0a
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 27 files changed
  • 0 commit comments
  • 1 contributor
View
1  .gitignore
@@ -3,3 +3,4 @@
*.suo
*.pidb
*.userprefs
+tags
View
3  continuous_testing
@@ -83,12 +83,15 @@ def notify(build_message)
#args.each {|key,value| command_line += " /#{key}:\"#{value}\""}
#`#{command_line} "#{build_message.message}"`
+ begin
GNTP.notify({
:app_name => 'c# practice',
:title => build_message.successful ? 'PASS' : 'FAIL',
:text => build_message.message,
:icon => build_message.successful ? 'green.jpg' : 'red.jpg'
})
+ rescue StandardError
+ end
end
def monitor
1  packages/RhinoMocks.3.6
@@ -0,0 +1 @@
+Subproject commit 097bec08df4d4c150eae472aaf314da9c7d5358e
View
46 src/domain/BOED.cs
@@ -0,0 +1,46 @@
+namespace domain
+{
+ public class BOED : IUnitOfMeasure
+ {
+ public decimal Convert(decimal amount, IUnitOfMeasure units)
+ {
+ return ( units is MCF ) ? amount * 6: amount;
+ }
+
+ public bool Equals(BOED other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return true;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (BOED)) return false;
+ return Equals((BOED) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return (name != null ? name.GetHashCode() : 0);
+ }
+
+ public override string ToString()
+ {
+ return name;
+ }
+
+ readonly string name = "BOED";
+ }
+
+ public class MCF : IUnitOfMeasure
+ {
+ public decimal Convert(decimal amount, IUnitOfMeasure units)
+ {
+ if(units is BOED) return amount/6;
+ return amount;
+ }
+ }
+}
View
15 src/domain/Clock.cs
@@ -0,0 +1,15 @@
+namespace domain
+{
+ using System;
+
+ public static class Clock
+ {
+ public static DateTime Now()
+ {
+ return time();
+ }
+
+ static Func<DateTime> defaultTime =()=> DateTime.Now;
+ static Func<DateTime> time = defaultTime;
+ }
+}
View
8 src/domain/DrillSchedule.cs
@@ -3,8 +3,9 @@ namespace domain
using System;
using System.Collections.Generic;
using System.Linq;
+ using utility;
- public class DrillSchedule
+ public class ProductionSchedule : IVisitable<IWell>
{
ICollection<IWell> wells = new List<IWell>();
@@ -33,6 +34,11 @@ public IQuantity EstimatedNetProductionFor<Commodity>(Month month) where Commodi
return result;
}
+ public void Accept(IVisitor<IWell> visitor )
+ {
+ Accept(visitor.Visit);
+ }
+
void Accept(Action<IWell> visitor )
{
wells.Each(well =>
View
26 src/domain/EstimatedNetProductionFor.cs
@@ -0,0 +1,26 @@
+namespace domain
+{
+ using utility;
+
+ public class EstimatedNetProductionFor<T> : IValueReturningVisitor<IWell, IQuantity> where T : ICommodity, new()
+ {
+ Month month;
+ IQuantity result;
+
+ public EstimatedNetProductionFor(Month month)
+ {
+ this.month = month;
+ result = new Quantity(0, new BOED());
+ }
+
+ public void Visit(IWell well)
+ {
+ result = result.Plus(well.NetProductionFor<T>(month));
+ }
+
+ public IQuantity Result()
+ {
+ return this.result;
+ }
+ }
+}
View
127 src/domain/GasPlant.cs
@@ -0,0 +1,127 @@
+namespace domain
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+ using utility;
+
+ public class GasPlant
+ {
+ IList<IWell> wells;
+ Capacity capacity;
+
+ public GasPlant()
+ {
+ this.wells = new List<IWell>();
+ this.capacity = new Capacity(0m.ToQuantity<MCF>());
+ }
+
+ public void IncreaseCapacityTo(IQuantity quantity, Month month)
+ {
+ this.capacity.IncreaseCapacity(quantity, month);
+ }
+
+ public void AcceptFlowFrom(IWell well)
+ {
+ this.wells.Add(well);
+ }
+
+ public IEnumerable<Month> MonthsOverAvailableCapacity()
+ {
+ return MonthsOverAvailableCapacity(Month.Now().UpTo(new Month(2099, 12)));
+ }
+
+ public IEnumerable<Month> MonthsOverAvailableCapacity(IRange<Month> months)
+ {
+ var results = new List<Month>();
+ months.Accept(month =>
+ {
+ if(IsOverCapacity(month)){
+ results.Add(month);
+ }
+ });
+ return results;
+ }
+
+ bool IsOverCapacity(Month month)
+ {
+ var production = TotalProductionFor(month);
+ if( capacity.AvailableFor(month).IsGreaterThan(production) ){
+ return true;
+ }
+ return false;
+ }
+ IQuantity TotalProductionFor(Month month)
+ {
+ IQuantity result = new Quantity(0, new BOED());
+ wells.Each(x =>
+ {
+ result = result.Plus( x.GrossProductionFor<Gas>(month));
+ });
+ return result;
+ }
+ }
+
+ public class Capacity
+ {
+ IList<Increase> increases;
+
+ public Capacity(IQuantity initialCapacity):this(initialCapacity, Month.Now())
+ {
+ }
+
+ public Capacity(IQuantity initialCapacity, Month month)
+ {
+ this.increases = new List<Increase>();
+ this.IncreaseCapacity(initialCapacity, month);
+ }
+
+ public void IncreaseCapacity(IQuantity quantity, Month month)
+ {
+ this.increases.Add(new Increase(quantity, month));
+ }
+
+ public IQuantity AvailableFor(Month month)
+ {
+ return new Quantity(0, new BOED());
+ //return this
+ //.increases
+ //.Where(x => x.IsBeforeOrOn(month))
+ //.Sum(x => x.IncreasedCapacity());
+ return null;
+ }
+
+ class Increase
+ {
+ IQuantity quantity;
+ Month month;
+
+ public Increase(IQuantity quantity, Month month)
+ {
+ this.quantity = quantity;
+ this.month = month;
+ }
+
+ public bool IsBeforeOrOn(Month other)
+ {
+ return month.IsBefore(other) || month.Equals(other);
+ }
+
+ public IQuantity IncreasedCapacity()
+ {
+ return this.quantity;
+ }
+ }
+ }
+ public static class Summation
+ {
+ static public IQuantity Sum(this IEnumerable<IQuantity> items)
+ {
+ var result = 0m.BOED();
+ foreach (var item in items) {
+ result = result.Plus(item);
+ }
+ return result;
+ }
+ }
+}
View
7 src/domain/IUnitOfMeasure.cs
@@ -0,0 +1,7 @@
+namespace domain
+{
+ public interface IUnitOfMeasure
+ {
+ decimal Convert(decimal amount, IUnitOfMeasure units);
+ }
+}
View
81 src/domain/Month.cs
@@ -0,0 +1,81 @@
+namespace domain
+{
+ using System;
+
+ public class Month : IComparable<Month>, IIncrementable<Month>
+ {
+ DateTime date;
+
+ public Month(int year, int month)
+ {
+ date = new DateTime(year, month, 01);
+ }
+
+ public Month Plus(int months)
+ {
+ return ToMonth(date.AddMonths(months));
+ }
+
+ public bool IsBefore(Month other)
+ {
+ return this.CompareTo(other) < 0;
+ }
+
+ Month ToMonth(DateTime date)
+ {
+ return new Month(date.Year, date.Month);
+ }
+
+ static public Month Now()
+ {
+ var now = Clock.Now();
+ return new Month(now.Year, now.Month);
+ }
+
+ public int CompareTo(Month other)
+ {
+ return this.date.CompareTo(other.date);
+ }
+
+ public Month Next()
+ {
+ return Plus(1);
+ }
+
+ public bool Equals(Month other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.date == date;
+ }
+
+ 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 (date.Year*397) ^ date.Month;
+ }
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0} {1}", date.Year, date.Month);
+ }
+ }
+
+ public static class Months
+ {
+ public static Month January(this int year)
+ {
+ return new Month(year,01);
+ }
+ }
+}
View
55 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);
+ }
+ }
+}
View
7 src/domain/Quantity.cs
@@ -4,6 +4,7 @@ public interface IQuantity
{
IQuantity Plus(IQuantity other);
IQuantity ConvertTo(IUnitOfMeasure units);
+ bool IsGreaterThan(IQuantity other);
decimal Amount { get; }
IUnitOfMeasure Units { get; }
}
@@ -22,6 +23,7 @@ public Quantity(decimal amount, IUnitOfMeasure units)
public IQuantity Plus(IQuantity other)
{
+ if(null == other) return this;
return new Quantity(Amount + other.ConvertTo(Units).Amount, Units);
}
@@ -30,6 +32,11 @@ public IQuantity ConvertTo(IUnitOfMeasure unitOfMeasure)
return new Quantity(unitOfMeasure.Convert(Amount, this.Units), unitOfMeasure);
}
+ public bool IsGreaterThan(IQuantity other)
+ {
+ return true;
+ }
+
public override string ToString()
{
return string.Format("{0} {1}", Amount, Units);
View
45 src/domain/Range.cs
@@ -0,0 +1,45 @@
+namespace domain
+{
+ using System;
+
+ public static class Ranges
+ {
+ public static IRange<T> UpTo<T>(this T start, T end) where T: IComparable<T>, IIncrementable<T>
+ {
+ return new Range<T>(start, end);
+ }
+ }
+
+ public interface IRange<T> where T : IComparable<T>
+ {
+ void Accept(Action<T> action);
+ }
+
+ public class Range<T> : IRange<T> where T : IComparable<T>, IIncrementable<T>
+ {
+ T start;
+ T end;
+
+ public Range(T start, T end)
+ {
+ this.start = start;
+ this.end = end;
+ }
+
+ public void Accept(Action<T> visitor)
+ {
+ var next = this.start;
+ var last = this.end.Next();
+ while(!next.Equals(last))
+ {
+ visitor(next);
+ next = next.Next();
+ }
+ }
+ }
+
+ public interface IIncrementable<T>
+ {
+ T Next();
+ }
+}
View
32 src/domain/Units.cs
@@ -0,0 +1,32 @@
+namespace domain
+{
+ using System;
+
+ public static class Units
+ {
+ public static Percent Percent(this decimal percentage)
+ {
+ return new Percent(percentage/100);
+ }
+
+ public static IQuantity BOED(this int quantity)
+ {
+ return BOED(Convert.ToDecimal(quantity));
+ }
+
+ public static IQuantity BOED(this decimal quantity)
+ {
+ return quantity.ToQuantity<BOED>();
+ }
+
+ static public IQuantity MCF(this decimal quantity)
+ {
+ return quantity.ToQuantity<MCF>();
+ }
+
+ static public IQuantity ToQuantity<T>(this decimal quantity) where T: IUnitOfMeasure,new()
+ {
+ return new Quantity(quantity, new T());
+ }
+ }
+}
View
166 src/domain/Well.cs
@@ -3,6 +3,7 @@ namespace domain
using System;
using System.Collections.Generic;
using System.Linq;
+ using utility;
public class Well : IWell
{
@@ -28,174 +29,9 @@ public IQuantity NetProductionFor<Commodity>(Month month) where Commodity : ICom
}
}
- 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)
- {
- return new Percent(percentage/100);
- }
-
- public static IQuantity BOED(this int quantity)
- {
- return BOED(Convert.ToDecimal(quantity));
- }
-
- public static IQuantity BOED(this decimal quantity)
- {
- return new Quantity(quantity, new BOED());
- }
- }
-
- public class BOED : IUnitOfMeasure
- {
- public decimal Convert(decimal amount, IUnitOfMeasure units)
- {
- // need to do actual conversion here;
- return amount;
- }
-
- public bool Equals(BOED other)
- {
- if (ReferenceEquals(null, other)) return false;
- if (ReferenceEquals(this, other)) return true;
- return true;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != typeof (BOED)) return false;
- return Equals((BOED) obj);
- }
-
- public override int GetHashCode()
- {
- return (name != null ? name.GetHashCode() : 0);
- }
-
- public override string ToString()
- {
- return name;
- }
-
- readonly string name = "BOED";
- }
-
- public interface IUnitOfMeasure
- {
- decimal Convert(decimal amount, IUnitOfMeasure units);
- }
-
- public static class Iterating
- {
- public static void Each<T>(this IEnumerable<T> items, Action<T> visitor){
- foreach (var item in items ?? Enumerable.Empty<T>())
- visitor(item);
- }
- }
}
View
11 src/domain/domain.csproj
@@ -41,15 +41,26 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Greeting.cs" />
+ <Compile Include="BOED.cs" />
+ <Compile Include="Clock.cs" />
<Compile Include="Commodity.cs" />
<Compile Include="CommoditySplits.cs" />
<Compile Include="DeclineCurve.cs" />
<Compile Include="DrillSchedule.cs" />
+ <Compile Include="EstimatedNetProductionFor.cs" />
+ <Compile Include="GasPlant.cs" />
+ <Compile Include="Month.cs" />
<Compile Include="Oppurtunity.cs" />
+ <Compile Include="Percent.cs" />
<Compile Include="Production.cs" />
<Compile Include="Quantity.cs" />
+ <Compile Include="Range.cs" />
<Compile Include="TypeCurve.cs" />
+ <Compile Include="Units.cs" />
<Compile Include="Well.cs" />
+ <Compile Include="IUnitOfMeasure.cs" />
+ <Compile Include="utility\IVisitor.cs" />
+ <Compile Include="utility\iterating.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(OS)' == 'Windows_NT' " />
View
23 src/domain/utility/IVisitor.cs
@@ -0,0 +1,23 @@
+namespace utility
+{
+ public interface IVisitor<T>
+ {
+ void Visit(T item);
+ }
+
+ public interface IVisitable<T>
+ {
+ void Accept(IVisitor<T> visitor);
+ }
+ public interface IValueReturningVisitor<T, TResult> : IVisitor<T>
+ {
+ TResult Result();
+ }
+ public static class Visiting{
+ public static TResult AcceptAndReturnResultFrom<T, TResult>(this IVisitable<T> visitable, IValueReturningVisitor<T, TResult> visitor)
+ {
+ visitable.Accept(visitor);
+ return visitor.Result();
+ }
+ }
+}
View
14 src/domain/utility/iterating.cs
@@ -0,0 +1,14 @@
+namespace utility
+{
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+
+ public static class Iterating
+ {
+ public static void Each<T>(this IEnumerable<T> items, Action<T> visitor){
+ foreach (var item in items ?? Enumerable.Empty<T>())
+ visitor(item);
+ }
+ }
+}
View
30 src/test/BOEDSpecs.cs
@@ -0,0 +1,30 @@
+namespace test
+{
+ using Machine.Specifications;
+ using domain;
+
+ public class BOEDSpecs
+ {
+ Establish context = ()=>
+ {
+ sut = new BOED();
+ };
+
+ static IUnitOfMeasure sut;
+
+ public class when_converting_one_BOE_to_MCF
+ {
+ It should_return_6_MCF=()=>
+ {
+ result.ShouldEqual(6m);
+ };
+
+ Because of = ()=>
+ {
+ result = sut.Convert(1, new MCF());
+ };
+
+ static decimal result;
+ }
+ }
+}
View
48 src/test/GasPlantSpecs.cs
@@ -0,0 +1,48 @@
+namespace test
+{
+ using System.Linq;
+ using System.Collections.Generic;
+ using Machine.Specifications;
+ using Rhino.Mocks;
+ using domain;
+ using utility;
+
+ public class GasPlantSpecs
+ {
+ Establish context = ()=>
+ {
+ sut = new GasPlant();
+ };
+
+ static GasPlant sut;
+
+ public class when_exceeding_a_plants_available_capacity
+ {
+ It should_indicate_the_month_that_the_plant_is_scheduled_to_be_over_capacity =() =>
+ {
+ results.ShouldContain(new Month(2013, 02));
+ };
+
+ Establish context = () =>
+ {
+ firstWell = Mock.An<IWell>();
+ secondWell = Mock.An<IWell>();
+ firstWell.Stub(x => x.GrossProductionFor<Gas>(2013.January())).Return(30m.MCF());
+ secondWell.Stub(x => x.GrossProductionFor<Gas>(2013.January())).Return(31m.MCF());
+ };
+
+ Because of = ()=>
+ {
+ sut.IncreaseCapacityTo(60m.MCF(),2013.January());
+
+ sut.AcceptFlowFrom(firstWell);
+ sut.AcceptFlowFrom(secondWell);
+ results = sut.MonthsOverAvailableCapacity().ToList();
+ };
+
+ static IEnumerable<Month> results;
+ static IWell firstWell;
+ static IWell secondWell;
+ }
+ }
+}
View
28 src/test/MCFSpecs.cs
@@ -0,0 +1,28 @@
+namespace test
+{
+ using Machine.Specifications;
+ using domain;
+ public class MCFSpecs{
+ Establish context = ()=>
+ {
+ sut = new MCF();
+ };
+
+ static MCF sut;
+
+ public class when_converting_6_mcf_to_boed
+ {
+ It should_return_one_boed=()=>
+ {
+ result.ShouldEqual(1m);
+ };
+
+ Because of = ()=>
+ {
+ result = sut.Convert(6m, new BOED());
+ };
+
+ static decimal result;
+ }
+ }
+}
View
12 src/test/Mock.cs
@@ -0,0 +1,12 @@
+namespace test
+{
+ using Rhino.Mocks;
+
+ public static class Mock
+ {
+ public static T An<T>() where T : class
+ {
+ return MockRepository.GenerateMock<T>();
+ }
+ }
+}
View
39 src/test/MonthSpecs.cs
@@ -0,0 +1,39 @@
+namespace test
+{
+ using Machine.Specifications;
+ using domain;
+
+ public class MonthSpecs
+ {
+ public class when_comparing_months
+ {
+ It should_return_a_positive_number_when_the_first_month_is_greater_than_the_second_month =()=>
+ {
+ new Month(2012, 05).CompareTo(new Month(2012, 04)).ShouldBeGreaterThan(0);
+ };
+ It should_return_a_negative_number_when_the_first_month_is_less_than_the_second_month =()=>
+ {
+ new Month(2012, 04).CompareTo(new Month(2012, 05)).ShouldBeLessThan(0);
+ };
+ It should_return_a_zero_when_the_first_month_is_equal_to_the_second_month =()=>
+ {
+ new Month(2012, 04).CompareTo(new Month(2012, 04)).ShouldEqual(0);
+ };
+ }
+ public class when_checking_if_a_month_is_before_another
+ {
+ It should_return_true_when_it_is =()=>
+ {
+ new Month(2012, 02).IsBefore(new Month(2012, 03)).ShouldBeTrue();
+ };
+ It should_return_false_when_it_is_not=()=>
+ {
+ new Month(2012, 03).IsBefore(new Month(2012, 02)).ShouldBeFalse();
+ };
+ It should_return_false_when_it_is_the_same_month=()=>
+ {
+ new Month(2012, 02).IsBefore(new Month(2012, 02)).ShouldBeFalse();
+ };
+ }
+ }
+}
View
118 src/test/ProductionScheduleSpecs.cs
@@ -0,0 +1,118 @@
+namespace test
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Machine.Specifications;
+ using domain;
+ using utility;
+
+ public class ProductionScheduleSpecs
+ {
+ public class when_estimating_production
+ {
+ Establish context = () =>
+ {
+ sut = new ProductionSchedule();
+ };
+
+ static ProductionSchedule sut;
+
+ public class when_100_percent_working_interest
+ {
+ 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
+ {
+ Establish context = ()=>
+ {
+ 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);
+ jan2013 = new Month(2013, 01);
+ };
+
+ Because of = ()=>
+ {
+ sut.Include(parkland75Percent.BringOnlineOn(jan2013));
+ };
+
+ It should_be_able_to_tell_the_estimated_net_total_production_for_any_month = () =>
+ {
+ sut.AcceptAndReturnResultFrom(new EstimatedNetProductionFor<All>(jan2013)).ShouldEqual(75.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_net_production_for_oil = ()=>
+ {
+ sut.EstimatedNetProductionFor<Oil>(jan2013).ShouldEqual(37.5m.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_net_production_for_gas = ()=>
+ {
+ sut.EstimatedNetProductionFor<Gas>(jan2013).ShouldEqual(37.5m.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_net_production_for_ngl = ()=>
+ {
+ sut.EstimatedNetProductionFor<NGL>(jan2013).ShouldEqual(0m.BOED());
+ };
+
+ It should_be_able_to_tell_the_estimated_net_production_for_condensate = ()=>
+ {
+ sut.EstimatedNetProductionFor<Condensate>(jan2013).ShouldEqual(0m.BOED());
+ };
+
+ static Month jan2013;
+ static Oppurtunity parkland75Percent;
+ }
+ }
+ }
+}
View
34 src/test/RangeSpecs.cs
@@ -0,0 +1,34 @@
+namespace test
+{
+ using System.Collections.Generic;
+ using Machine.Specifications;
+ using domain;
+
+ public class RangeSpecs
+ {
+ Establish context = () =>
+ {
+ sut = new Range<Month>(new Month(2012, 01), new Month(2012, 03));
+ };
+
+ static IRange<Month> sut;
+
+ public class when_iterating_through_each_item_in_a_range
+ {
+ It should_visit_each_item_in_the_range =()=>
+ {
+ results.ShouldContainOnly(new Month(2012, 01),new Month(2012, 02),new Month(2012, 03));
+ };
+
+ Because of = () =>
+ {
+ sut.Accept(x =>
+ {
+ results.Add(x);
+ });
+ };
+
+ static IList<Month> results = new List<Month>();
+ }
+ }
+}
View
51 src/test/WellSpecs.cs
@@ -1,51 +0,0 @@
-namespace test
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Machine.Specifications;
- using domain;
-
- public class WellSpecs
- {
- public class when_estimating_production
- {
- It should_be_able_to_tell_the_estimated_total_production_for_any_month= () =>
- {
- 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());
- };
-
- 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());
- };
- }
- }
-}
View
11 src/test/test.csproj
@@ -34,6 +34,9 @@
<Reference Include="Machine.Specifications">
<HintPath>..\..\packages\Machine.Specifications.0.5.3.0\lib\Machine.Specifications.dll</HintPath>
</Reference>
+ <Reference Include="Rhino.Mocks">
+ <HintPath>..\..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -45,8 +48,14 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GreetingSpecs.cs" />
+ <Compile Include="BOEDSpecs.cs" />
<Compile Include="CalculatorSpecs.cs" />
- <Compile Include="WellSpecs.cs" />
+ <Compile Include="MCFSpecs.cs" />
+ <Compile Include="Mock.cs" />
+ <Compile Include="MonthSpecs.cs" />
+ <Compile Include="ProductionScheduleSpecs.cs" />
+ <Compile Include="RangeSpecs.cs" />
+ <Compile Include="GasPlantSpecs.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

No commit comments for this range

Something went wrong with that request. Please try again.