# File tests/test_ajaxim.rb, line 116
  def test_send
    msg 'Testing send'
    # here we need next params:
    # from, recipient, message, and font params:
    # font, font_size, font_color, font_bold, font_italic, font_underline
    
    # testing not_online case: recipient is not online and is not a room
    from = 'admin'
    recipient = 'valcker'
    ajaxIM = AjaxIM.new(@db, from, recipient, '')
    responce = ajaxIM.send(Hash.new)
    assert_match('not_online', responce, 'User must be offline')
    
    # testing case when message.size == 0
    @db.query("INSERT INTO {ajaxim_status} SET status=100, uid=1, last_ping=#{Time.now.to_i.to_s}, last_status=0")
    from = 'valcker'
    recipient = 'admin'
    ajaxIM = AjaxIM.new(@db, from, recipient, '')
    responce = ajaxIM.send(Hash.new)
    assert(responce.nil?, 'Responce should be nil for empty messages')
    #
    # testing too_long case: message.size > 1500
    ajaxIM = AjaxIM.new(@db, from, recipient, 'a'*1501)
    responce = ajaxIM.send(Hash.new)
    assert_match('too_long', responce, 'Responce should be too_long for messages > 1500')
    #
    # testing for 'sent' return value when everything is ok
    ajaxIM = AjaxIM.new(@db, from, recipient, 'Hello world')
    responce = ajaxIM.send(Hash.new)
    assert_match('sent', responce, 'All params are OK, responce should be "sent"')
    #
    # testing for correct message sending
    params = {
      'font'           => 'tahoma',
      'font_size'      => 20,
      'font_color'     => 'black',
      'font_bold'      => false,
      'font_italic'    => false,
      'font_underline' => true
    }
    ajaxIM = AjaxIM.new(@db, from, recipient, 'Hi there')
    responce = ajaxIM.send(params)
    puts responce
    res = @db.query('SELECT * FROM {ajaxim_messages} ORDER BY id DESC').fetch_hash
    puts res['message']
  end