main
1using System;
2using System.Timers;
3using developwithpassion.bdd.contexts;
4using Gorilla.Commons.Testing;
5
6namespace momoney.service.infrastructure.threading
7{
8 [Concern(typeof (TimerFactory))]
9 public abstract class behaves_like_a_timer_factory : concerns_for<ITimerFactory, TimerFactory>
10 {
11 public override ITimerFactory create_sut()
12 {
13 return new TimerFactory();
14 }
15 }
16
17 [Concern(typeof (TimerFactory))]
18 public class when_creating_a_timer : behaves_like_a_timer_factory
19 {
20 it should_return_a_timer_with_the_correct_interval = () => result.Interval.should_be_equal_to(1000);
21
22 because b = () => { result = sut.create_for(new TimeSpan(0, 0, 1)); };
23
24 static Timer result;
25 }
26
27 [Concern(typeof (TimerFactory))]
28 public class when_creating_a_timer_with_an_interval_in_milliseconds : behaves_like_a_timer_factory
29 {
30 it should_return_a_timer_with_the_correct_polling_interval =
31 () => result.Interval.should_be_equal_to(milliseconds);
32
33 because b = () =>
34 {
35 var timer_interval = new TimeSpan(50);
36 milliseconds = 50;
37 result = sut.create_for(timer_interval);
38 };
39
40 static Timer result;
41 static double milliseconds;
42 }
43}