forked from connamara/quickfixn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixParserTestCase.rb
46 lines (36 loc) · 974 Bytes
/
FixParserTestCase.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'FixParser'
require 'runit/testcase'
require "thread"
require 'SocketServer'
class FixParserTestCase < RUNIT::TestCase
def test_readFixMessage
fixMsg1 = "8=FIX.4.2\0019=12\00135=A\001108=30\00110=31\001"
fixMsg2 = "8=FIX.4.2\0019=17\00135=4\00136=88\001123=Y\00110=34\001"
server = SocketServer.new
def server.message=(m)
@message = m
end
def server.connectAction(s)
end
def server.receiveAction(s)
s.write(@message)
end
def server.disconnectAction(s)
end
server.message = fixMsg1 + fixMsg2
Thread.start do
server.listen(RUNIT::TestCase.port)
end
server.wait
s = TCPSocket.open("localhost", RUNIT::TestCase.port)
parser = FixParser.new(s)
begin
assert_equals(fixMsg1, parser.readFixMessage)
assert_equals(fixMsg2, parser.readFixMessage)
rescue IOError
# I have no idea why this is being thrown
end
s.close
server.stop()
end
end