How to use containExactly method of io.kotest.matchers.collections.containExactly class

Best Kotest code snippet using io.kotest.matchers.collections.containExactly.containExactly

ShouldContainExactlyTest.kt

Source:ShouldContainExactlyTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.collections2import io.kotest.assertions.shouldFail3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.WordSpec5import io.kotest.matchers.collections.containExactly6import io.kotest.matchers.collections.containExactlyInAnyOrder7import io.kotest.matchers.collections.shouldContainExactly8import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder9import io.kotest.matchers.collections.shouldNotContainExactly10import io.kotest.matchers.collections.shouldNotContainExactlyInAnyOrder11import io.kotest.matchers.should12import io.kotest.matchers.shouldBe13import io.kotest.matchers.shouldNot14import io.kotest.matchers.throwable.shouldHaveMessage15import java.io.File16import java.nio.file.Path17import java.nio.file.Paths18class ShouldContainExactlyTest : WordSpec() {19 init {20 "containExactly" should {21 "test that an array contains given elements exactly" {22 val actual = arrayOf(1, 2, 3)23 actual.shouldContainExactly(1, 2, 3)24 actual shouldContainExactly arrayOf(1, 2, 3)25 actual.shouldNotContainExactly(3, 2, 1)26 actual shouldNotContainExactly arrayOf(3, 2, 1)27 shouldThrow<AssertionError> {28 actual.shouldContainExactly(3, 2, 1)29 }30 shouldThrow<AssertionError> {31 actual shouldContainExactly arrayOf(3, 2, 1)32 }33 shouldThrow<AssertionError> {34 actual.shouldNotContainExactly(1, 2, 3)35 }36 shouldThrow<AssertionError> {37 actual shouldNotContainExactly arrayOf(1, 2, 3)38 }39 val actualNull: Array<Int>? = null40 shouldThrow<AssertionError> {41 actualNull.shouldContainExactly(1, 2, 3)42 }.shouldHaveMessage("Expecting actual not to be null")43 shouldThrow<AssertionError> {44 actualNull.shouldNotContainExactly()45 }.shouldHaveMessage("Expecting actual not to be null")46 }47 "test that a collection contains given elements exactly" {48 val actual = listOf(1, 2, 3)49 emptyList<Int>() should containExactly()50 actual should containExactly(1, 2, 3)51 actual.shouldContainExactly(1, 2, 3)52 actual.toSet().shouldContainExactly(linkedSetOf(1, 2, 3))53 actual shouldNot containExactly(1, 2)54 actual.shouldNotContainExactly(3, 2, 1)55 actual.shouldNotContainExactly(listOf(5, 6, 7))56 shouldThrow<AssertionError> {57 actual should containExactly(1, 2)58 }59 shouldThrow<AssertionError> {60 actual should containExactly(1, 2, 3, 4)61 }62 shouldThrow<AssertionError> {63 actual.shouldContainExactly(3, 2, 1)64 }65 }66 "test contains exactly for byte arrays" {67 listOf("hello".toByteArray()) shouldContainExactly listOf("hello".toByteArray())68 listOf("helloworld".toByteArray()) shouldNotContainExactly listOf("hello".toByteArray())69 }70 "print errors unambiguously" {71 shouldThrow<AssertionError> {72 listOf<Any>(1L, 2L).shouldContainExactly(listOf<Any>(1, 2))73 } shouldHaveMessage74 """75 |Expecting: [1, 2] but was: [1L, 2L]76 |Some elements were missing: [1, 2] and some elements were unexpected: [1L, 2L]77 |expected:<[1, 2]> but was:<[1L, 2L]>78 """.trimMargin()79 }80 "informs user of illegal comparisons" {81 shouldFail {82 HashSet(setOf(1, 2, 3)) shouldContainExactly listOf(1, 2, 3)83 }.message shouldBe """Disallowed: Set can be compared only to Set84 |May not compare HashSet with ArrayList85 |expected:<*> but was:<*>86 |87 |""".trimMargin()88 }89 "print dataclasses" {90 shouldThrow<AssertionError> {91 listOf(92 Blonde("foo", true, 23423, inputPath),93 Blonde("woo", true, 97821, inputPath),94 Blonde("goo", true, 51984, inputPath)95 ).shouldContainExactly(96 Blonde("foo", true, 23423, inputPath),97 Blonde("woo", true, 97821, inputPath)98 )99 }.message?.trim() shouldBe100 """101 |Expecting: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]102 |Some elements were unexpected: [Blonde(a=goo, b=true, c=51984, p=$expectedPath)]103 |expected:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]>104 """.trimMargin()105 }106 "include extras when too many" {107 shouldThrow<AssertionError> {108 listOf(109 Blonde("foo", true, 23423, inputPath)110 ).shouldContainExactly(111 Blonde("foo", true, 23423, inputPath),112 Blonde("woo", true, 97821, inputPath)113 )114 }.message?.trim() shouldBe115 """116 |Expecting: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath)]117 |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)]118 |expected:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath)]>119 """.trimMargin()120 }121 "include missing when too few" {122 shouldThrow<AssertionError> {123 listOf(124 Blonde("foo", true, 23423, inputPath),125 Blonde("hoo", true, 96915, inputPath)126 ).shouldContainExactly(127 Blonde("woo", true, 97821, inputPath)128 )129 }.message?.trim() shouldBe130 """131 |Expecting: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]132 |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath)] and some elements were unexpected: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]133 |expected:<[Blonde(a=woo, b=true, c=97821, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]>134 """.trimMargin()135 }136 "include missing and extras when not the right amount" {137 shouldThrow<AssertionError> {138 listOf(139 Blonde("foo", true, 23423, inputPath),140 Blonde("hoo", true, 96915, inputPath)141 ).shouldContainExactly(142 Blonde("woo", true, 97821, inputPath),143 Blonde("goo", true, 51984, inputPath)144 )145 }.message?.trim() shouldBe146 """147 |Expecting: [Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)] but was: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]148 |Some elements were missing: [Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)] and some elements were unexpected: [Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]149 |expected:<[Blonde(a=woo, b=true, c=97821, p=$expectedPath), Blonde(a=goo, b=true, c=51984, p=$expectedPath)]> but was:<[Blonde(a=foo, b=true, c=23423, p=$expectedPath), Blonde(a=hoo, b=true, c=96915, p=$expectedPath)]>150 """.trimMargin()151 }152 }153 "containExactlyInAnyOrder" should {154 "test that a collection contains given elements exactly in any order" {155 val actual = listOf(1, 2, 3)156 actual should containExactlyInAnyOrder(1, 2, 3)157 actual.shouldContainExactlyInAnyOrder(3, 2, 1)158 actual.shouldContainExactlyInAnyOrder(linkedSetOf(2, 1, 3))159 actual shouldNot containExactlyInAnyOrder(1, 2)160 actual.shouldNotContainExactlyInAnyOrder(1, 2, 3, 4)161 actual.shouldNotContainExactlyInAnyOrder(listOf(5, 6, 7))162 actual.shouldNotContainExactlyInAnyOrder(1, 1, 1)163 actual.shouldNotContainExactlyInAnyOrder(listOf(2, 2, 3))164 actual.shouldNotContainExactlyInAnyOrder(listOf(1, 1, 2, 3))165 val actualDuplicates = listOf(1, 1, 2)166 actualDuplicates.shouldContainExactlyInAnyOrder(1, 2, 1)167 actualDuplicates.shouldContainExactlyInAnyOrder(2, 1, 1)168 actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2)169 actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2, 2)170 actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 1, 2, 2)171 actualDuplicates.shouldNotContainExactlyInAnyOrder(1, 2, 7)172 shouldThrow<AssertionError> {173 actual should containExactlyInAnyOrder(1, 2)174 }175 shouldThrow<AssertionError> {176 actual should containExactlyInAnyOrder(1, 2, 3, 4)177 }178 shouldThrow<AssertionError> {179 actual should containExactlyInAnyOrder(1, 1, 1)180 }181 shouldThrow<AssertionError> {182 actual should containExactlyInAnyOrder(1, 1, 2, 3)183 }184 shouldThrow<AssertionError> {185 actualDuplicates should containExactlyInAnyOrder(1, 2, 2)186 }187 }188 "print errors unambiguously" {189 shouldThrow<AssertionError> {190 listOf<Any>(1L, 2L).shouldContainExactlyInAnyOrder(listOf<Any>(1, 2))191 }.shouldHaveMessage("Collection should contain [1, 2] in any order, but was [1L, 2L]")192 }193 "disambiguate when using optional expected value" {194 val actual: List<String> = listOf("A", "B", "C")195 val expected: List<String>? = listOf("A", "B", "C")196 actual.shouldContainExactlyInAnyOrder(expected)197 }198 }199 }...

Full Screen

Full Screen

LogSpyExtensionsTest.kt

Source:LogSpyExtensionsTest.kt Github

copy

Full Screen

...3import io.kotest.core.spec.style.FreeSpec4import io.kotest.inspectors.forAll5import io.kotest.matchers.Matcher6import io.kotest.matchers.MatcherResult7import io.kotest.matchers.collections.containExactly8import io.kotest.matchers.should9internal class LogSpyExtensionsTest : FreeSpec() {10 init {11 "spy by type" - {12 "creates spy for type" - {13 useFakeSpyProvider { provider ->14 val spy = spyOn<TestObject> { provider.addEvent(TestObject::class, event()) }15 spy.events() should containExactly(event())16 }17 }18 "closes underlying spy after block" - {19 useFakeSpyProvider { provider ->20 spyOn<TestObject> {}21 provider.allInstancesFor(TestObject::class).forAll { it.shouldBeClosed() }22 }23 }24 "closes underlying spy after faulty block" - {25 useFakeSpyProvider { provider ->26 shouldThrow<java.lang.RuntimeException> {27 spyOn<TestObject> { throw RuntimeException("Test exception") }28 }29 provider.allInstancesFor(TestObject::class).forAll { it.shouldBeClosed() }30 }31 }32 "takes snapshot of recorded events" - {33 useFakeSpyProvider { provider ->34 val spy = spyOn<TestObject> { provider.addEvent(TestObject::class, event1()) }35 provider.addEvent(TestObject::class, event2())36 spy.events() should containExactly(event1())37 }38 }39 "creates new spy for each request" - {40 useFakeSpyProvider { provider ->41 spyOn<TestObject> {42 provider.addEvent(TestObject::class, event1())43 val spy =44 spyOn<TestObject> { provider.addEvent(TestObject::class, event2()) }45 spy.events() should containExactly(event2())46 }47 }48 }49 "delayed spying" - {50 "creates spy for block" - {51 useFakeSpyProvider { provider ->52 val spy = spyForLogger<TestObject>()53 provider.addEvent(TestObject::class, event1())54 val sectionSpy = spy { provider.addEvent(TestObject::class, event2()) }55 sectionSpy.events() should containExactly(event2())56 }57 }58 }59 }60 "spy by literal" - {61 "creates spy for literal" - {62 useFakeSpyProvider { provider ->63 val spy = spyOn("a") { provider.addEvent("a", event()) }64 spy.events() should containExactly(event())65 }66 }67 "closes underlying spy" - {68 useFakeSpyProvider { provider ->69 spyOn("a") {}70 provider.allInstancesFor("a").forAll { it.shouldBeClosed() }71 }72 }73 "closes underlying spy after faulty block" - {74 useFakeSpyProvider { provider ->75 shouldThrow<java.lang.RuntimeException> {76 spyOn("a") { throw RuntimeException("Test exception") }77 }78 provider.allInstancesFor("a").forAll { it.shouldBeClosed() }79 }80 }81 "takes snapshot of recorded events" - {82 useFakeSpyProvider { provider ->83 val spy = spyOn("a") { provider.addEvent("a", event1()) }84 provider.addEvent("a", event2())85 spy.events() should containExactly(event1())86 }87 }88 "creates new spy for each request" - {89 useFakeSpyProvider { provider ->90 spyOn("a") {91 provider.addEvent("a", event1())92 val spy = spyOn("a") { provider.addEvent("a", event2()) }93 spy.events() should containExactly(event2())94 }95 }96 }97 "delayed spying" - {98 "creates spy for block" - {99 useFakeSpyProvider { provider ->100 val spy = spyForLogger("a")101 provider.addEvent("a", event1())102 val sectionSpy = spy { provider.addEvent("a", event2()) }103 sectionSpy.events() should containExactly(event2())104 }105 }106 }107 }108 }109}110private fun useFakeSpyProvider(block: (FakeSpyProvider) -> Unit) {111 val provider = FakeSpyProvider()112 ServiceLoaderWrapper.predefine<SpyProvider>(provider)113 block(provider)114}115private fun event() = SpiedEvent("Test", SpiedEvent.Level.DEBUG, null, emptyMap())116private fun event1() = SpiedEvent("Test 1", SpiedEvent.Level.DEBUG, null, emptyMap())117private fun event2() = SpiedEvent("Test 2", SpiedEvent.Level.DEBUG, null, emptyMap())...

Full Screen

Full Screen

SyncFeatureSpec.kt

Source:SyncFeatureSpec.kt Github

copy

Full Screen

1package io.github.mishkun.puerh.core2import io.kotest.core.spec.style.FreeSpec3import io.kotest.matchers.collections.beEmpty4import io.kotest.matchers.collections.containExactly5import io.kotest.matchers.should6import io.kotest.matchers.shouldBe7class SyncFeatureSpec : FreeSpec({8 "describe current state" - {9 "it should be initialized with state" {10 val testFeature = createTestFeature()11 testFeature.currentState shouldBe SyncTestFeature.State(0)12 }13 "it should update state on message" {14 val testFeature = createTestFeature()15 testFeature.accept(SyncTestFeature.Msg)16 testFeature.currentState shouldBe SyncTestFeature.State(1)17 }18 }19 "describe state subscription" - {20 "it should get first state on subscription" {21 val testFeature = createTestFeature()22 var gotState: SyncTestFeature.State? = null23 val subscriber: (SyncTestFeature.State) -> Unit = { gotState = it }24 testFeature.listenState(subscriber)25 gotState shouldBe SyncTestFeature.State(0)26 }27 "it should always get exactly one latest state on subscription" {28 val testFeature = createTestFeature()29 val states = mutableListOf<SyncTestFeature.State>()30 val subscriber: (SyncTestFeature.State) -> Unit = { states.add(it) }31 testFeature.accept(SyncTestFeature.Msg)32 testFeature.listenState(subscriber)33 states should containExactly(SyncTestFeature.State(1))34 }35 "it should subscribe to state updates" {36 val testFeature = createTestFeature()37 val states = mutableListOf<SyncTestFeature.State>()38 val subscriber: (SyncTestFeature.State) -> Unit = { states.add(it) }39 testFeature.listenState(subscriber)40 testFeature.accept(SyncTestFeature.Msg)41 states should containExactly(SyncTestFeature.State(0), SyncTestFeature.State(1))42 }43 }44 "describe effects subscription" - {45 "it should subscribe to effects" {46 val testFeature = createTestFeature()47 val effects = mutableListOf<SyncTestFeature.Eff>()48 val subscriber: (SyncTestFeature.Eff) -> Unit = { effects.add(it) }49 testFeature.listenEffect(subscriber)50 testFeature.accept(SyncTestFeature.Msg)51 effects should containExactly(SyncTestFeature.Eff)52 }53 "it should not get any effects on subscription" {54 val testFeature = createTestFeature()55 val effects = mutableListOf<SyncTestFeature.Eff>()56 val subscriber: (SyncTestFeature.Eff) -> Unit = { effects.add(it) }57 testFeature.accept(SyncTestFeature.Msg)58 testFeature.listenEffect(subscriber)59 effects should beEmpty()60 }61 }62 "describe feature disposal" - {63 "it should not get any effects after calling cancel method" {64 val testFeature = createTestFeature()65 val effects = mutableListOf<SyncTestFeature.Eff>()66 val subscriber: (SyncTestFeature.Eff) -> Unit = { effects.add(it) }67 testFeature.listenEffect(subscriber)68 testFeature.cancel()69 testFeature.accept(SyncTestFeature.Msg)70 effects should beEmpty()71 }72 "it should not get any new states after calling cancel method" {73 val testFeature = createTestFeature()74 val states = mutableListOf<SyncTestFeature.State>()75 val subscriber: (SyncTestFeature.State) -> Unit = { states.add(it) }76 testFeature.listenState(subscriber)77 testFeature.cancel()78 testFeature.accept(SyncTestFeature.Msg)79 states should containExactly(SyncTestFeature.State(0))80 }81 }82})83private fun createTestFeature() = SyncFeature(SyncTestFeature.State(0), SyncTestFeature::reducer)84private object SyncTestFeature {85 fun reducer(msg: Msg, state: State): Pair<State, Set<Eff>> =86 state.copy(counter = state.counter + 1) to setOf(Eff)87 object Msg88 object Eff89 data class State(val counter: Int)90}...

Full Screen

Full Screen

containExactly.kt

Source:containExactly.kt Github

copy

Full Screen

...7import io.kotest.matchers.should8import io.kotest.matchers.shouldNot9import kotlin.jvm.JvmName10@JvmName("shouldContainExactly_iterable")11infix fun <T> Iterable<T>?.shouldContainExactly(expected: Iterable<T>) = this?.toList() should containExactly(expected.toList())12@JvmName("shouldContainExactly_array")13infix fun <T> Array<T>?.shouldContainExactly(expected: Array<T>) = this?.asList() should containExactly(*expected)14fun <T> Iterable<T>?.shouldContainExactly(vararg expected: T) = this?.toList() should containExactly(*expected)15fun <T> Array<T>?.shouldContainExactly(vararg expected: T) = this?.asList() should containExactly(*expected)16infix fun <T, C : Collection<T>> C?.shouldContainExactly(expected: C) = this should containExactly(expected)17fun <T> Collection<T>?.shouldContainExactly(vararg expected: T) = this should containExactly(*expected)18fun <T> containExactly(vararg expected: T): Matcher<Collection<T>?> = containExactly(expected.asList())19/** Assert that a collection contains exactly the given values and nothing else, in order. */20fun <T, C : Collection<T>> containExactly(expected: C): Matcher<C?> = neverNullMatcher { actual ->21 val passed = actual.size == expected.size && actual.zip(expected).all { (a, b) -> a == b }22 val failureMessage = {23 val missing = expected.filterNot { actual.contains(it) }24 val extra = actual.filterNot { expected.contains(it) }25 val sb = StringBuilder()26 sb.append("Expecting: ${expected.printed().value} but was: ${actual.printed().value}")27 sb.append("\n")28 if (missing.isNotEmpty()) {29 sb.append("Some elements were missing: ")30 sb.append(missing.printed().value)31 if (extra.isNotEmpty()) {32 sb.append(" and some elements were unexpected: ")33 sb.append(extra.printed().value)34 }35 } else if (extra.isNotEmpty()) {36 sb.append("Some elements were unexpected: ")37 sb.append(extra.printed().value)38 }39 sb.toString()40 }41 MatcherResult(42 passed,43 failureMessage44 ) { "Collection should not be exactly ${expected.printed().value}" }45}46@JvmName("shouldNotContainExactly_iterable")47infix fun <T> Iterable<T>?.shouldNotContainExactly(expected: Iterable<T>) = this?.toList() shouldNot containExactly(expected.toList())48@JvmName("shouldNotContainExactly_array")49infix fun <T> Array<T>?.shouldNotContainExactly(expected: Array<T>) = this?.asList() shouldNot containExactly(*expected)50fun <T> Iterable<T>?.shouldNotContainExactly(vararg expected: T) = this?.toList() shouldNot containExactly(*expected)51fun <T> Array<T>?.shouldNotContainExactly(vararg expected: T) = this?.asList() shouldNot containExactly(*expected)52infix fun <T, C : Collection<T>> C?.shouldNotContainExactly(expected: C) = this shouldNot containExactly(expected)53fun <T> Collection<T>?.shouldNotContainExactly(vararg expected: T) = this shouldNot containExactly(*expected)54fun <T, C : Collection<T>> C.printed(): Printed {55 val expectedPrinted = take(20).joinToString(",\n ", prefix = "[\n ", postfix = "\n]") { it.show().value }56 val expectedMore = if (size > 20) " ... (plus ${size - 20} more)" else ""57 return Printed("$expectedPrinted$expectedMore")58}...

Full Screen

Full Screen

TextChannelTests.kt

Source:TextChannelTests.kt Github

copy

Full Screen

...7import dev.discordkt.models.permissions.Permission8import dev.discordkt.snowflake.Snowflake9import io.kotest.core.spec.style.StringSpec10import io.kotest.matchers.collections.beEmpty11import io.kotest.matchers.collections.containExactly12import io.kotest.matchers.should13import io.kotest.matchers.shouldBe14class TextChannelTests : StringSpec({15 "Text Channel With Perms" {16 """{17 "id": "761287705354567680",18 "last_message_id": "762021898447487038",19 "type": 0,20 "name": "githook",21 "position": 21,22 "parent_id": null,23 "topic": null,24 "guild_id": "455265814191276037",25 "permission_overwrites": [],26 "nsfw": false,27 "rate_limit_per_user": 028}29""".deserializes<Channel> {30 it.longId shouldBe 761287705354567680L31 it.lastMessageId?.longId shouldBe 762021898447487038L32 it.type shouldBe ChannelType.GUILD_TEXT33 it.name shouldBe "githook"34 it.position shouldBe 2135 it.parentId shouldBe null36 it.topic shouldBe null37 it.guildId?.longId shouldBe 455265814191276037L38 it.permissionOverwrites!! should beEmpty()39 it.nsfw shouldBe false40 it.rateLimitPerUser shouldBe 041 }42 }43 "Overwrite channel"{44 """{45 "id": "479635335760969748",46 "last_message_id": "504016397509328908",47 "type": 0,48 "name": "test-cazgirl",49 "position": 4,50 "parent_id": "455265814191276038",51 "topic": null,52 "guild_id": "455265814191276037",53 "permission_overwrites": [54 {55 "id": "455265814191276037",56 "type": "role",57 "allow": "0",58 "deny": "1024"59 },60 {61 "id": "467792830786699286",62 "type": "role",63 "allow": "1024",64 "deny": "0"65 }66 ],67 "nsfw": false,68 "rate_limit_per_user": 069}""".deserializes<Channel> {70 it.longId shouldBe 479635335760969748L71 it.lastMessageId?.longId shouldBe 50401639750932890872 it.type shouldBe ChannelType.GUILD_TEXT73 it.name shouldBe "test-cazgirl"74 it.position shouldBe 475 it.parentId?.longId shouldBe 455265814191276038L76 it.topic shouldBe null77 it.guildId?.longId shouldBe 455265814191276037L78 it.permissionOverwrites should containExactly(79 Overwrite(80 Snowflake.of(455265814191276037L),81 OverwriteType.ROLE, Permission.BitField(listOf()), Permission.BitField(listOf(Permission.VIEW_CHANNEL))),82 Overwrite(83 Snowflake.of(467792830786699286L),84 OverwriteType.ROLE, Permission.BitField(listOf(Permission.VIEW_CHANNEL)), Permission.BitField(listOf())85 )86 )87 it.nsfw shouldBe false88 it.rateLimitPerUser shouldBe 089 }90 }91})...

Full Screen

Full Screen

ActiveStatesTest.kt

Source:ActiveStatesTest.kt Github

copy

Full Screen

1package ru.nsk.kstatemachine2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.collections.containExactly4import io.kotest.matchers.collections.shouldContainExactly5import io.kotest.matchers.should6class ActiveStatesTest : StringSpec({7 "activeStates()" {8 lateinit var state1: State9 lateinit var state2: State10 lateinit var state21: State11 lateinit var state211: State12 val machine = createStateMachine {13 state1 = initialState("state1") {14 transitionOn<SwitchEvent> {15 targetState = { state2 }16 }17 }18 state2 = state("state2") {19 state21 = initialState("state21") {20 state211 = addInitialState(createStateMachine(start = false) {21 // should not be included22 initialState("state2111")23 })24 }25 }26 }27 machine.activeStates(true) should containExactly(machine, state1)28 machine.activeStates() should containExactly(state1)29 machine.processEvent(SwitchEvent)30 machine.activeStates(true) should containExactly(machine, state2, state21, state211)31 machine.activeStates() should containExactly(state2, state21, state211)32 state2.activeStates(true) should containExactly(state2, state21, state211)33 state2.activeStates() should containExactly(state21, state211)34 }35 "activeStates() in parallel child mode" {36 lateinit var state1: State37 lateinit var state2: State38 val machine = createStateMachine(childMode = ChildMode.PARALLEL) {39 state1 = state()40 state2 = state()41 }42 machine.activeStates(true) should containExactly(machine, state1, state2)43 machine.activeStates() should containExactly(state1, state2)44 }45 "activeStates() do not include nested machines states" {46 lateinit var initialState: State47 lateinit var nestedMachine: State48 val machine = createStateMachine {49 initialState = initialState {50 nestedMachine = addInitialState(createStateMachine {51 initialState()52 })53 }54 }55 val s = DefaultState()56 s.recursiveEnterInitialStates()57 machine.activeStates().shouldContainExactly(initialState, nestedMachine)...

Full Screen

Full Screen

UserTest.kt

Source:UserTest.kt Github

copy

Full Screen

...3import dev.discordkt.models.user.User4import dev.discordkt.models.user.UserFlag5import io.kotest.core.spec.style.StringSpec6import io.kotest.matchers.collections.beEmpty7import io.kotest.matchers.collections.containExactly8import io.kotest.matchers.should9import io.kotest.matchers.shouldBe10class UserTest : StringSpec({11 "User Serialization" {12 """13{14 "id": "80351110224678912",15 "username": "Nelly",16 "discriminator": "1337",17 "avatar": "8342729096ea3675442027381ff50dfe",18 "verified": true,19 "email": "nelly@discord.com",20 "flags": 64,21 "premium_type": 1,22 "public_flags": 6423}24 """.deserializes<User> {25 it.longId shouldBe 80351110224678912L26 it.username shouldBe "Nelly"27 it.discriminator shouldBe "1337"28 it.avatarHash shouldBe "8342729096ea3675442027381ff50dfe"29 it.verified shouldBe true30 it.email shouldBe "nelly@discord.com"31 it.flags should containExactly(UserFlag.HOUSE_BRAVERY)32 it.publicFlags should containExactly(UserFlag.HOUSE_BRAVERY)33 it.premiumType shouldBe PremiumType.NITRO_CLASSIC34 }35 """{"id": "364009534722801665", "username": "Postfix-Bot", "avatar": "8957c49f91481c041d46951a665f8c60", "discriminator": "9450", "public_flags": 0, "flags": 0, "bot": true, "email": null, "verified": true, "locale": "en-US", "mfa_enabled": true}""".deserializes<User> {36 it.longId shouldBe 364009534722801665L37 it.username shouldBe "Postfix-Bot"38 it.avatarHash shouldBe "8957c49f91481c041d46951a665f8c60"39 it.publicFlags!! should beEmpty()40 it.bot shouldBe true41 it.locale shouldBe "en-US"42 it.verified shouldBe true43 it.email shouldBe null44 it.discriminator shouldBe "9450"45 }46 }...

Full Screen

Full Screen

EmojiTest.kt

Source:EmojiTest.kt Github

copy

Full Screen

1package dev.discordkt.models.emoji2import dev.discordkt.snowflake.Snowflake3import io.kotest.core.spec.style.StringSpec4import io.kotest.matchers.collections.containExactly5import io.kotest.matchers.should6import io.kotest.matchers.shouldBe7import kotlinx.serialization.decodeFromString8import kotlinx.serialization.json.Json9class EmojiTest : StringSpec({10 "should parse" {11 val json = Json {}12 val emojiJsonText = """13 {14 "id": "41771983429993937",15 "name": "LUL",16 "roles": ["41771983429993000", "41771983429993111"],17 "user": {18 "username": "Luigi",19 "discriminator": "0002",20 "id": "96008815106887111",21 "avatar": "5500909a3274e1812beb4e8de6631111"22 },23 "require_colons": true,24 "managed": false,25 "animated": false26 }27 """28 val emoji = json.decodeFromString<Emoji>(emojiJsonText)29 emoji.longId shouldBe 41771983429993937L30 emoji.name shouldBe "LUL"31 emoji.roles should containExactly(32 Snowflake.of(41771983429993000L), Snowflake.of(41771983429993111L)33 )34 emoji.user!!.username shouldBe "Luigi"35 emoji.user!!.discriminator shouldBe "0002"36 emoji.user!!.longId shouldBe 96008815106887111L37 emoji.user!!.avatarHash shouldBe "5500909a3274e1812beb4e8de6631111"38 emoji.requireColons shouldBe true39 emoji.managed shouldBe false40 emoji.animated shouldBe false41 }42})...

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1val list = listOf(1, 2, 3, 4, 5)2list should containExactly(1, 2, 3, 4, 5)3val list = listOf(1, 2, 3, 4, 5)4val list = listOf(1, 2, 3, 4, 5)5list shouldNotContainExactly(1, 2, 3, 4, 5)6val list = listOf(1, 2, 3, 4, 5)7list shouldContainAll listOf(1, 2, 3)8val list = listOf(1, 2, 3, 4, 5)9list shouldContainAllInOrder listOf(1, 2, 3)10val list = listOf(1, 2, 3, 4, 5)11list shouldContainNone listOf(6, 7, 8)12val list = listOf(1, 2, 3, 4, 5)13list shouldContainExactlyInAnyOrder listOf(5, 4, 3, 2, 1)14val list = listOf(1, 2, 3, 4, 5)15list shouldContainInOrder listOf(1, 2, 3)16val list = listOf(1, 2, 3, 4, 5)17list shouldContainSame listOf(1, 2, 3, 4,

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1val list = listOf(2, 4, 6, 8)2list should containExactly(2, 4, 6, 8)3val list = listOf(2, 4, 6, 8)4list should containExactlyInAnyOrder(2, 4, 6, 8)5val list = listOf(2, 4, 6, 8)6list should containExactlyInAnyOrder(2, 4, 6, 8)7val list = listOf(2, 4, 6, 8)8list should containExactlyInAnyOrder(2, 4, 6, 8)9val list = listOf(2, 4, 6, 8)10list should containExactlyInAnyOrder(2, 4, 6, 8)11val list = listOf(2, 4, 6, 8)12list should containExactlyInAnyOrder(2, 4, 6, 8)13val list = listOf(2, 4, 6, 8)14list should containExactlyInAnyOrder(2, 4, 6, 8)15val list = listOf(2, 4, 6, 8)16list should containExactlyInAnyOrder(2, 4, 6, 8)17val list = listOf(2, 4, 6,

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.collections.* val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )2val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )3val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )4val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )5val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )6val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )7val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )8val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )9val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )10val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly ( 5 , 4 , 3 , 2 , 1 )11val list = listOf ( 1 , 2 , 3 , 4 , 5 ) list . should . containExactly (

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1val list = listOf("a", "b", "c", "d")2list should containExactly("a", "b", "c", "d")3list shouldNotBe listOf("a", "b", "c", "d")4list shouldBe listOf("a", "b", "c", "d")5list shouldNotBe listOf("a", "b", "c", "d")6list shouldNotBe listOf("a", "b", "c", "d")7list shouldNotBe listOf("a", "b", "c", "d")8list shouldNotBe listOf("a", "b", "c", "d")9list shouldNotBe listOf("a", "b", "c", "d")10list shouldNotBe listOf("a", "b", "c", "d")11list shouldNotBe listOf("a", "b", "c", "d")12list shouldNotBe listOf("a", "b", "c", "d")13list shouldNotBe listOf("a", "b", "c", "d")14list shouldNotBe listOf("a", "b", "c", "d")15list shouldNotBe listOf("a

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.collections.containExactly2class TestClass {3fun test1() {4val list = listOf(1, 2, 3, 4)5list should containExactly(1, 2, 3, 4)6}7}8import io.kotest.matchers.collections.containExactlyInAnyOrder9class TestClass {10fun test1() {11val list = listOf(1, 2, 3, 4)12list should containExactlyInAnyOrder(4, 3, 2, 1)13}14}15import io.kotest.matchers.collections.containAll16class TestClass {17fun test1() {18val list = listOf(1, 2, 3, 4)19list should containAll(1, 2)20}21}22import io.kotest.matchers.collections.containInAnyOrder23class TestClass {24fun test1() {25val list = listOf(1, 2, 3, 4)26list should containInAnyOrder(4, 3, 2, 1)27}28}29import io.kotest.matchers.collections.contain30class TestClass {31fun test1() {32val list = listOf(1, 2, 3, 4)33list should contain(1)34}35}36import io.kotest.matchers.collections.containOnly37class TestClass {38fun test1() {39val list = listOf(1, 2, 3, 4)40list should containOnly(1, 2, 3, 4)41}42}43import io.kotest.matchers.collections.containNone44class TestClass {45fun test1() {46val list = listOf(1, 2, 3

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1fun containExactly ( vararg expected : T ) : Matcher < Collection < T >> fun containExactly ( vararg expected : T ) : Matcher < Collection < T >>2Kotlin Test containExactly() method3Recommended Posts: Kotlin | Test assertNotEquals() method4Kotlin | Test assertEquals() method5Kotlin | Test assertNotSame() method6Kotlin | Test assertSame() method7Kotlin | Test assertAll() method8Kotlin | Test assertThrows() method9Kotlin | Test assertFails() method10Kotlin | Test assertFailsWith() method11Kotlin | Test assertSoftly() method12Kotlin | Test assertNotSame() method13Kotlin | Test assertSame() method14Kotlin | Test assertAll() method15Kotlin | Test assertThrows() method16Kotlin | Test assertFails() method17Kotlin | Test assertFailsWith() method18Kotlin | Test assertSoftly() method19Kotlin | Test assertNotSame() method20Kotlin | Test assertSame() method21Kotlin | Test assertAll() method22Kotlin | Test assertThrows() method23Kotlin | Test assertFails() method24Kotlin | Test assertFailsWith() method25Kotlin | Test assertSoftly() method26Kotlin | Test assertNotSame() method27Kotlin | Test assertSame() method28Kotlin | Test assertAll() method29Kotlin | Test assertThrows() method

Full Screen

Full Screen

containExactly

Using AI Code Generation

copy

Full Screen

1@DisplayName ( "Test the list of strings" )2fun testList () {3val list = listOf ( "a" , "b" , "c" )4list should containExactly ( "a" , "b" , "c" )5}6@DisplayName ( "Test the list of strings" )7fun testList () {8val list = listOf ( "a" , "b" , "c" )9list should containExactlyInAnyOrder ( "c" , "b" , "a" )10}11@DisplayName ( "Test the list of strings" )12fun testList () {13val list = listOf ( "a" , "b" , "c" )14list should containExactlyInAnyOrder ( "c" , "b" , "a" )15}16@DisplayName ( "Test the list of strings" )17fun testList () {18val list = listOf ( "a" , "b" , "c" )19list should containExactlyInAnyOrder ( "c" , "b" , "a" )20}21@DisplayName ( "Test the list of strings" )22fun testList () {23val list = listOf ( "a" , "b" , "c" )24list should containExactlyInAnyOrder ( "c" , "b" , "a" )25}26@DisplayName ( "Test the list of strings" )27fun testList () {28val list = listOf ( "a" , "b" , "c" )29list should containExactlyInAnyOrder ( "c" , "b" , "a" )30}31@DisplayName ( "Test the list of strings" )32fun testList () {33val list = listOf (

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in containExactly

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful