Commit 266f252
Changed files (13)
product
service
domain
payroll
specs
unit
service
domain
hierarchy
property_bag
product/service/domain/payroll/Money.cs
@@ -5,15 +5,15 @@ namespace solidware.financials.service.domain.payroll
{
public class Money : IEquatable<Money>
{
- double value;
+ decimal value;
static public Money Zero = new Money(0);
- Money(double value)
+ Money(decimal value)
{
this.value = value;
}
- static public implicit operator Money(double raw)
+ static public implicit operator Money(decimal raw)
{
return new Money(raw);
}
@@ -53,7 +53,7 @@ namespace solidware.financials.service.domain.payroll
return "{0:C}".format(value);
}
- public Units at_price(double price)
+ public Units at_price(decimal price)
{
return Units.New((int)(value / price));
}
product/service/domain/payroll/UnitPrice.cs
@@ -2,14 +2,14 @@ namespace solidware.financials.service.domain.payroll
{
public class UnitPrice
{
- readonly double price;
+ readonly decimal price;
- UnitPrice(double price)
+ UnitPrice(decimal price)
{
this.price = price;
}
- static public implicit operator UnitPrice(double raw)
+ static public implicit operator UnitPrice(decimal raw)
{
return new UnitPrice(raw);
}
product/service/domain/payroll/Units.cs
@@ -10,7 +10,7 @@ namespace solidware.financials.service.domain.payroll
return new Units {units = units};
}
- public Money value_at(double price)
+ public Money value_at(decimal price)
{
return price*units;
}
product/specs/unit/service/domain/accounting/CurrencySpecs.cs
@@ -5,9 +5,10 @@ namespace specs.unit.service.domain.accounting
{
public class CurrencySpecs
{
- public abstract class concern : runner<Currency>
+ public abstract class concern
{
- Cleanup clean = () => {
+ Cleanup clean = () =>
+ {
SimpleUnitOfMeasure.provide_rate((x, y) => ConversionRatio.Default);
};
}
@@ -22,13 +23,8 @@ namespace specs.unit.service.domain.accounting
It should_return_the_correct_amount = () =>
{
- sut.convert(1, Currency.CAD).should_be_equal_to(1.05690034);
+ Currency.USD.convert(1, Currency.CAD).should_be_equal_to(1.05690034);
};
-
- protected override Currency create_sut()
- {
- return Currency.USD;
- }
}
[Concern(typeof (Currency))]
@@ -41,13 +37,8 @@ namespace specs.unit.service.domain.accounting
It should_return_the_correct_amount = () =>
{
- sut.convert(1.05690034d, Currency.USD).should_be_equal_to(1.0046577561938002d);
+ Currency.CAD.convert(1.05690034d, Currency.USD).should_be_equal_to(1.0046577561938002d);
};
-
- protected override Currency create_sut()
- {
- return Currency.CAD;
- }
}
}
}
\ No newline at end of file
product/specs/unit/service/domain/accounting/DetailAccountSpecs.cs
@@ -5,12 +5,14 @@ namespace specs.unit.service.domain.accounting
{
public class DetailAccountSpecs
{
- public abstract class concern : runner<DetailAccount>
+ public abstract class concern
{
- protected override DetailAccount create_sut()
+ Establish context = () =>
{
- return DetailAccount.New(Currency.CAD);
- }
+ sut = DetailAccount.New(Currency.CAD);
+ };
+
+ static protected DetailAccount sut;
}
[Concern(typeof (DetailAccount))]
product/specs/unit/service/domain/accounting/SummaryAccountSpecs.cs
@@ -5,12 +5,14 @@ namespace specs.unit.service.domain.accounting
{
public class SummaryAccountSpecs
{
- public abstract class concern : runner<SummaryAccount>
+ public abstract class concern
{
- protected override SummaryAccount create_sut()
+ Establish context = () =>
{
- return SummaryAccount.New(Currency.CAD);
- }
+ sut = SummaryAccount.New(Currency.CAD);
+ };
+
+ static protected SummaryAccount sut;
}
[Concern(typeof (SummaryAccount))]
@@ -18,7 +20,7 @@ namespace specs.unit.service.domain.accounting
{
Establish c = () =>
{
- cash = DetailAccount.New(Currency.CAD);
+ cash = DetailAccount.New(Currency.CAD);
credit = DetailAccount.New(Currency.CAD);
cash.deposit(50, Currency.CAD);
product/specs/unit/service/domain/hierarchy/HierarchySpecs.cs
@@ -6,12 +6,14 @@ namespace specs.unit.service.domain.hierarchy
{
public class HierarchySpecs
{
- public abstract class concern : runner<Hierarchy>
+ public abstract class concern
{
- protected override Hierarchy create_sut()
+ Establish context = () =>
{
- return new Hierarchy();
- }
+ sut = new Hierarchy();
+ };
+
+ static protected Hierarchy sut;
}
[Concern(typeof (Hierarchy))]
product/specs/unit/service/domain/payroll/CompensationSpecs.cs
@@ -7,12 +7,14 @@ namespace specs.unit.service.domain.payroll
{
public class CompensationSpecs
{
- public abstract class concern : runner<Compensation>
+ public abstract class concern
{
- protected override Compensation create_sut()
+ Establish context = () =>
{
- return new Compensation();
- }
+ sut = new Compensation();
+ };
+
+ static protected Compensation sut;
}
[Concern(typeof (Compensation))]
@@ -23,10 +25,10 @@ namespace specs.unit.service.domain.payroll
//Calendar.stop(() => new DateTime(2009, 06, 07));
//sut.increase_salary_to(65500);
Calendar.stop(() => new DateTime(2009, 09, 15));
- sut.issue_grant(4500.00, 10.00, new One<Third>(), new Annually());
+ sut.issue_grant(4500.00m, 10.00m, new One<Third>(), new Annually());
Calendar.start();
- sut.grant_for(new DateTime(2009, 09, 15)).change_unit_price_to(20.00);
+ sut.grant_for(new DateTime(2009, 09, 15)).change_unit_price_to(20.00m);
};
It should_indicate_that_nothing_has_vested_before_the_first_anniversary = () =>
product/specs/unit/service/domain/payroll/DateSpecs.cs
@@ -6,20 +6,14 @@ namespace specs.unit.service.domain.payroll
{
public class DateSpecs
{
- public abstract class concern : runner<Date> {}
-
[Concern(typeof (Date))]
- public class when_two_dates_are_the_same : concern
+ public class when_two_dates_are_the_same
{
It should_be_equal = () =>
{
+ Date sut = new DateTime(2009, 01, 01, 01, 00, 00);
sut.Equals(new DateTime(2009, 01, 01, 09, 00, 01)).should_be_true();
};
-
- protected override Date create_sut()
- {
- return new DateTime(2009, 01, 01, 01, 00, 00);
- }
}
}
}
\ No newline at end of file
product/specs/unit/service/domain/payroll/GrantSpecs.cs
@@ -7,13 +7,20 @@ namespace specs.unit.service.domain.payroll
{
public class GrantSpecs
{
- public abstract class concern : runner<Grant>
+ public abstract class concern
{
- protected override Grant create_sut()
+ Establish context = () =>
{
Calendar.stop(() => new DateTime(2010, 01, 01));
- return Grant.New(120, 10, new One<Twelfth>(), new Monthly());
- }
+ sut = Grant.New(120, 10, new One<Twelfth>(), new Monthly());
+ };
+
+ Cleanup clean = () =>
+ {
+ Calendar.reset();
+ };
+
+ static protected Grant sut;
}
[Concern(typeof (Grant))]
product/specs/unit/service/domain/payroll/MoneySpecs.cs
@@ -5,20 +5,14 @@ namespace specs.unit.service.domain.payroll
{
public class MoneySpecs
{
- public abstract class concern : runner<Money> {}
-
[Concern(typeof (Money))]
- public class when_two_monies_are_the_same : concern
+ public class when_two_monies_are_the_same
{
It should_be_equal = () =>
{
- sut.Equals(100.00);
+ Money sut = 100.00m;
+ sut.Equals(100.00m);
};
-
- protected override Money create_sut()
- {
- return 100.00;
- }
}
}
}
\ No newline at end of file
product/specs/unit/service/domain/property_bag/PropertyBagSpecs.cs
@@ -8,20 +8,19 @@ namespace specs.unit.service.domain.property_bag
{
public class PropertyBagSpecs
{
- public abstract class concern : runner<PropertyBag>
+ public abstract class concern
{
- Establish c = () => Console.Out.WriteLine("init concern");
-
- protected override PropertyBag create_sut()
+ Establish context = () =>
{
- return Bag.For<TargetType>();
- }
+ sut = Bag.For<TargetType>();
+ };
+
+ static protected PropertyBag sut;
}
[Concern(typeof (PropertyBag))]
public class when_creating_a_property_bag_from_a_known_type : concern
{
-
It should_include_each_property_from_the_target_type = () =>
{
sut.property_named("name").should_not_be_null();
product/specs/unit/service/domain/runner.cs
@@ -1,6 +1,4 @@
-using Machine.Specifications;
-
-namespace specs.unit.service.domain
+namespace specs.unit.service.domain
{
public class runner<T>
{