'Verify that the client repeats the L{IRCClient.setNick} method with a
new value when presented with an C{ERR_NICKNAMEINUSE} while trying to
register.'

def test_registerWithTakenNick(self):

    username = 'testuser'
    hostname = 'testhost'
    servername = 'testserver'
    self.protocol.realname = 'testname'
    self.protocol.password = 'testpass'
    self.protocol.register(username, hostname, servername)
    self.protocol.irc_ERR_NICKNAMEINUSE('prefix', ['param'])
    lastLine = self.getLastLine(self.transport)
    self.assertNotEqual(lastLine, ('NICK    %s' % (username,)))
    self.protocol.irc_ERR_NICKNAMEINUSE('prefix', ['param'])
    lastLine = self.getLastLine(self.transport)
    self.assertEqual(lastLine, ('NICK    %s' % ((username + '__'),)))
