-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swap between two List for the UnityBatchScheduler queues instead of a…
…llocating a new one each time (closes #19) Also add tests for the case of one binding scheduling another
- Loading branch information
Showing
4 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using NUnit.Framework; | ||
using TinkState; | ||
|
||
namespace Test | ||
{ | ||
// NOTE: this is not an intended usage for bindings, as one shouldn't | ||
// trigger bindings from other bindings (e.g. by changing a State) and | ||
// instead make use of auto-Observables and such, but we still test | ||
// that this works as expected and doesn't hang | ||
class TestTriggerBindingFromBinding : BaseTest | ||
{ | ||
[Test] | ||
public void Test() | ||
{ | ||
var s = Observable.State(2); | ||
var s2 = Observable.State(2); | ||
|
||
var bindingCalls = 0; | ||
var expectedValue = 2; | ||
void BindCallback(int value) | ||
{ | ||
bindingCalls++; | ||
Assert.That(value, Is.EqualTo(expectedValue)); | ||
} | ||
|
||
s2.Bind(BindCallback); | ||
Assert.That(bindingCalls, Is.EqualTo(1)); | ||
|
||
expectedValue = 4; | ||
s.Bind(v => s2.Value = v * 2); | ||
Assert.That(bindingCalls, Is.EqualTo(2)); | ||
|
||
expectedValue = 6; | ||
s.Value = 3; | ||
Assert.That(bindingCalls, Is.EqualTo(3)); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.