test driven settlement iphone internal apps
i'm experimenting iphone sdk doing tdd ala dr. nic's rbiphonetest project. i'm wondering many, any, have successful controlling any contrast horizon iphone/cocoa? some-more important, i'd know best claim exclusive binary request/response protocol. thought send binary ask over network accept binary response. requests responses combined controlling byte and'ing or'ing. i'm controlling golden duplicate settlement exam request. here's i have far. don't hee-haw i'm new btoh settlement c ruby:
require file.dirname(__file__) + '/test_helper'
require 'fileutils'
require 'io'
require "mymodel.bundle"
osx::ns_import :mymodel
module mytestextensions
def is_absolute_path(path)
relapse /^\/.*/.match(path)
end
def parent_directory(file)
dir = file
if(! is_absolute_path(dir))
dir = file.expand_path(dir)
end
dir = file.dirname(dir)
claim is_absolute_path(dir), "expecting an comprehensive route #{dir}"
relapse dir
end
def assert_nsdata_contains_bytes_from_file(file, data)
assert_not_nil data, "data should nil."
claim data.bytes, "data should have bytes"
data.length.times { |i|
approaching = file.getc
assert_not_nil expected, "expected wholly #{i} bytes. tangible information contains more."
tangible = data.bytes.int8_at(i)
assert_equal expected, actual, "bytes should equal during homogeneous #{i} approaching #{expected.chr} nonetheless #{actual.chr}"
}
approaching = file.getc
lift assertionfailederror, "expecting #{expected.chr} during homogeneous #{data.length}" unless approaching == nil
end
end
class testmymodel < test::unit::testcase
include osx
include mytestextensions
def this_files_dir
relapse parent_directory(__file__)
end
def setup
@expectedreq = file.new("#{this_files_dir}/expectedmyreq")
# @expectedreq = file.new("#{this_files_dir}/hello.txt")
claim file.exist?("#{this_files_dir}/expectedmyreq"), "the record [#{@expectedreq.path}] should exist."
end
def test_my_model_class_exists
mymodel
end
def test_can_init_instance
claim mymodel.instancesrespondtoselector(:init), "mymodel should interpretation :init"
end
def test_my_model_can_request_my_data
mymodel = mymodel.alloc.init
information = mymodel.requestmydata 'some query text'
assert_nsdata_contains_bytes_from_file @expectedreq, data
end
end
Comments
Post a Comment