MockFriendGroupsTest.kt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2019-2022 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  8. */
  9. package net.mamoe.mirai.mock.test.mock
  10. import net.mamoe.mirai.mock.test.MockBotTestBase
  11. import org.junit.jupiter.api.Test
  12. import kotlin.test.assertEquals
  13. internal class MockFriendGroupsTest : MockBotTestBase() {
  14. @Test
  15. internal fun testFriendGroupsDefaultEmpty() = runTest {
  16. assertEquals(1, bot.friendGroups.asCollection().size)
  17. assertEquals(bot.friendGroups.default, bot.friendGroups[0])
  18. assertEquals(bot.friendGroups.default, bot.friendGroups.asCollection().iterator().next())
  19. }
  20. @Test
  21. internal fun testFriendGroupCreating() = runTest {
  22. val group = bot.friendGroups.create("Test")
  23. println(group.id)
  24. assertEquals(2, bot.friendGroups.asCollection().size)
  25. assertEquals(group, bot.friendGroups[group.id])
  26. }
  27. @Test
  28. internal fun testFriendGroupReferences() = runTest {
  29. val group = bot.friendGroups.create("Test")
  30. val friend = bot.addFriend(5, "Test")
  31. assertEquals(bot.friendGroups.default, friend.friendGroup)
  32. assertEquals(0, friend.mockApi.friendGroupId)
  33. group.moveIn(friend)
  34. assertEquals(group, friend.friendGroup)
  35. assertEquals(group.id, friend.mockApi.friendGroupId)
  36. group.delete()
  37. assertEquals(bot.friendGroups.default, friend.friendGroup)
  38. assertEquals(0, friend.mockApi.friendGroupId)
  39. }
  40. }