# frozen_string_literal: true

require "test_helper"
require "ibr"

class IBRTest < Minitest::Test
	property(:registered) { boolean }
	def registered(val)
		ibr = IBR.new
		ibr.registered = val
		assert_equal val, ibr.registered?
	end

	{
		instructions: :string,
		username: :string,
		nick: :string,
		password: :string,
		name: :string,
		first: :string,
		last: :string,
		email: :string,
		address: :string,
		city: :string,
		state: :string,
		zip: :string,
		phone: [:string, :digit],
		url: :string,
		date: ->(*) { Time.at(range(0, 4294967295)).iso8601 }
	}.each do |prop, type|
		property("prop_#{prop}") { call(type) }
		define_method("prop_#{prop}") do |val|
			ibr = IBR.new
			ibr.public_send("#{prop}=", val)
			assert_equal val, ibr.public_send(prop)
		end
	end
end
