You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ISupportProcessorTest.kt 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.dmdirc.ktirc.messages
  2. import com.dmdirc.ktirc.io.CaseMapping
  3. import com.dmdirc.ktirc.io.IrcMessage
  4. import com.dmdirc.ktirc.state.ServerFeature
  5. import com.dmdirc.ktirc.state.ServerState
  6. import com.nhaarman.mockitokotlin2.mock
  7. import com.nhaarman.mockitokotlin2.verify
  8. import org.junit.jupiter.api.Assertions.*
  9. import org.junit.jupiter.api.Test
  10. internal class ISupportProcessorTest {
  11. private val state = mock<ServerState>()
  12. private val processor = ISupportProcessor(state)
  13. @Test
  14. fun `ISupportProcessor can handle 005s`() {
  15. assertTrue(processor.commands.contains("005")) { "ISupportProcessor should handle 005 messages" }
  16. }
  17. @Test
  18. fun `ISupportProcessor handles multiple numeric arguments`() {
  19. processor.process(IrcMessage(null, "server.com".toByteArray(), "005",
  20. listOf("nickname", "CHANLIMIT=123", "CHANNELLEN=456", "are supported blah blah").map { it.toByteArray() }))
  21. verify(state).setFeature(ServerFeature.MaximumChannels, 123)
  22. verify(state).setFeature(ServerFeature.MaximumChannelNameLength, 456)
  23. }
  24. @Test
  25. fun `ISupportProcessor handles string arguments`() {
  26. processor.process(IrcMessage(null, "server.com".toByteArray(), "005",
  27. listOf("nickname", "CHANMODES=abcd", "are supported blah blah").map { it.toByteArray() }))
  28. verify(state).setFeature(ServerFeature.ChannelModes, "abcd")
  29. }
  30. @Test
  31. fun `ISupportProcessor handles resetting arguments`() {
  32. processor.process(IrcMessage(null, "server.com".toByteArray(), "005",
  33. listOf("nickname", "-CHANMODES", "are supported blah blah").map { it.toByteArray() }))
  34. verify(state).resetFeature(ServerFeature.ChannelModes)
  35. }
  36. @Test
  37. fun `ISupportProcessor handles case mapping arguments`() {
  38. processor.process(IrcMessage(null, "server.com".toByteArray(), "005",
  39. listOf("nickname", "CASEMAPPING=rfc1459-strict", "are supported blah blah").map { it.toByteArray() }))
  40. verify(state).setFeature(ServerFeature.ServerCaseMapping, CaseMapping.RfcStrict)
  41. }
  42. }