Skip to content

Commit

Permalink
Fix rdMap unbind
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
Iliya-usov authored and ForNeVeR committed Jun 22, 2023
1 parent 030749e commit 31e18a0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ open class RdMap<K : Any, V : Any> private constructor(
(value != null).condstr { " :: value = ${value.printToString()}" }
}

override fun unbind() {
super.unbind()
bindDefinitions = null
}

override fun preInit(lifetime: Lifetime, proto: IProtocol) {
super.preInit(lifetime, proto)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class RdCollectionsTest : RdFrameworkTestBase() {
assertEquals(BindState.Bound, serverSet.bindState)

setSchedulerActive(SchedulerKind.Client) {
val oldProperty = clientProperty.value
clientProperty.value = null
clientProperty.value = oldProperty
clientProperty.value = null
}

Expand All @@ -184,6 +187,9 @@ class RdCollectionsTest : RdFrameworkTestBase() {
assertEquals(BindState.Bound, serverProperty.bindState)

setSchedulerActive(SchedulerKind.Client) {
val oldProperty = clientList[0]
clientList[0] = RdProperty(null)
clientList[0] = oldProperty
clientList[0] = RdProperty(null)
}

Expand Down Expand Up @@ -212,6 +218,9 @@ class RdCollectionsTest : RdFrameworkTestBase() {
assertEquals(BindState.Bound, serverList.bindState)

setSchedulerActive(SchedulerKind.Client) {
val oldValue = clientMap[clientMap.keys.single()]!!
clientMap[clientMap.keys.single()] = RdList()
clientMap[clientMap.keys.single()] = oldValue
clientMap[clientMap.keys.single()] = RdList()
}

Expand Down Expand Up @@ -239,6 +248,9 @@ class RdCollectionsTest : RdFrameworkTestBase() {
assertEquals(BindState.Bound, serverMap.bindState)

setSchedulerActive(SchedulerKind.Client) {
val oldValue = clientTopLevelProperty.value
clientTopLevelProperty.value = null
clientTopLevelProperty.value = oldValue
clientTopLevelProperty.value = null
}

Expand Down
12 changes: 12 additions & 0 deletions rd-net/Test.RdFramework/RdCollectionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ public void UnbindTest()

SetSchedulerActive(SchedulerKind.Client, () =>
{
var oldValue = clientProperty.Value;
clientProperty.Value = null;
clientProperty.Value = oldValue;
clientProperty.Value = null;
});

Expand All @@ -232,6 +235,9 @@ public void UnbindTest()

SetSchedulerActive(SchedulerKind.Client, () =>
{
var oldValue = clientList[0];
clientList[0] = NewRdProperty<RdSet<int>>();
clientList[0] = oldValue;
clientList[0] = NewRdProperty<RdSet<int>>();
});

Expand Down Expand Up @@ -262,6 +268,9 @@ public void UnbindTest()

SetSchedulerActive(SchedulerKind.Client, () =>
{
var oldValue = clientMap[clientMap.Keys.Single()];
clientMap[clientMap.Keys.Single()] = NewRdList<RdProperty<RdSet<int>>>();
clientMap[clientMap.Keys.Single()] = oldValue;
clientMap[clientMap.Keys.Single()] = NewRdList<RdProperty<RdSet<int>>>();
});

Expand Down Expand Up @@ -291,6 +300,9 @@ public void UnbindTest()

SetSchedulerActive(SchedulerKind.Client, () =>
{
var oldValue = clientTopLevelProperty.Value;
clientTopLevelProperty.Value = null;
clientTopLevelProperty.Value = oldValue;
clientTopLevelProperty.Value = null;
});

Expand Down

0 comments on commit 31e18a0

Please sign in to comment.