OSDN Git Service

Refactored MockLogger class.
[shogi-server/shogi-server.git] / test / TC_floodgate_next_time_generator.rb
1 $:.unshift File.join(File.dirname(__FILE__), "..")
2 require 'test/unit'
3 require 'shogi_server'
4 require 'shogi_server/league/floodgate'
5
6 $topdir = File.expand_path File.dirname(__FILE__)
7
8 class TestNextTimeGenerator_900_0 < Test::Unit::TestCase
9   def setup
10     @next = ShogiServer::League::Floodgate::NextTimeGenerator_Floodgate_900_0.new
11   end
12
13   def test_0_min
14     now = Time.mktime(2009,12,25,22,0)
15     assert_equal(Time.mktime(2009,12,25,22,30), @next.call(now))
16   end
17
18   def test_20_min
19     now = Time.mktime(2009,12,25,22,20)
20     assert_equal(Time.mktime(2009,12,25,22,30), @next.call(now))
21   end
22
23   def test_30_min
24     now = Time.mktime(2009,12,25,22,30)
25     assert_equal(Time.mktime(2009,12,25,23,00), @next.call(now))
26   end
27
28   def test_50_min
29     now = Time.mktime(2009,12,25,22,50)
30     assert_equal(Time.mktime(2009,12,25,23,00), @next.call(now))
31   end
32
33   def test_50_min_next_day
34     now = Time.mktime(2009,12,25,23,50)
35     assert_equal(Time.mktime(2009,12,26,0,0), @next.call(now))
36   end
37
38   def test_50_min_next_month
39     now = Time.mktime(2009,11,30,23,50)
40     assert_equal(Time.mktime(2009,12,1,0,0), @next.call(now))
41   end
42
43   def test_50_min_next_year
44     now = Time.mktime(2009,12,31,23,50)
45     assert_equal(Time.mktime(2010,1,1,0,0), @next.call(now))
46   end
47 end
48
49 class TestNextTimeGenerator_3600_0 < Test::Unit::TestCase
50   def setup
51     @next = ShogiServer::League::Floodgate::NextTimeGenerator_Floodgate_3600_0.new
52   end
53
54   def test_22_00
55     now = Time.mktime(2009,12,25,22,0)
56     assert_equal(Time.mktime(2009,12,25,23,0), @next.call(now))
57   end
58
59   def test_22_30
60     now = Time.mktime(2009,12,25,22,0)
61     assert_equal(Time.mktime(2009,12,25,23,0), @next.call(now))
62   end
63
64   def test_23_00
65     now = Time.mktime(2009,12,25,23,0)
66     assert_equal(Time.mktime(2009,12,26,1,0), @next.call(now))
67   end
68
69   def test_23_30
70     now = Time.mktime(2009,12,25,23,30)
71     assert_equal(Time.mktime(2009,12,26,1,0), @next.call(now))
72   end
73
74   def test_00_00
75     now = Time.mktime(2009,12,26,0,0)
76     assert_equal(Time.mktime(2009,12,26,1,0), @next.call(now))
77   end
78
79   def test_23_30_next_month
80     now = Time.mktime(2009,11,30,23,30)
81     assert_equal(Time.mktime(2009,12,1,1,0), @next.call(now))
82   end
83
84   def test_23_30_next_year
85     now = Time.mktime(2009,12,31,23,30)
86     assert_equal(Time.mktime(2010,1,1,1,0), @next.call(now))
87   end
88 end
89