Created
September 23, 2010 19:36
-
-
Save Noxn/594204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
TDIR = "#{File.dirname(__FILE__)}" | |
require TDIR+'/lib' | |
require TDIR+'/client' | |
#Tests for lib.rb (Needs a name) | |
# Server.rb and Client.rb are needed for testing. | |
#The lone letters in test names are for order. | |
SERV = Thread.new { require TDIR+'/server' } | |
CLIENT = Client.new | |
CLIENT.connect | |
class TC_Telnet < Test::Unit::TestCase | |
def teardown | |
raise "Server crashed." unless SERV.alive? | |
end | |
def test_alive | |
assert(SERV.alive?, "Failed to run. Bad.") | |
end | |
def test_b_greeting #No idea how to implement yet. | |
CLIENT.rcv.chomp | |
assert_equal("--Test server", CLIENT.rcv.chomp) | |
end | |
def test_replies_a_simple | |
assert_equal("Echo", CLIENT.snd("echo").chomp) | |
end | |
def test_replies_b_arg | |
assert_equal("Text: Variable_Text", CLIENT.snd("text: Variable_Text").chomp) | |
end | |
def test_replies_c_continued_logic | |
assert_equal("1", CLIENT.snd("count").chomp) | |
assert_equal("2", CLIENT.snd("count").chomp) | |
assert_equal("3", CLIENT.snd("count").chomp) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment