question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing Signal bindings

See original GitHub issue

This is a question which originates from #551.

Is it also possible to use BindSignal instead of Subscribe ?
I would like to write a unit test that checks my bindings. Here is what I would like to do:

[Test]
public void Signal_SomeSignal_ShouldFireAllRelated()
{
  SignalBusInstaller.Install(Container);
  ProjectSignals.BindSignals(Container); // Binds all my signals for my project

  var someMock = new Mock<ISomeInterface>();
  Container.Bind<ISomeInterface>().FromInstance(someMock.Object);

  var target = Container.Resolve<SignalBus>();
  target.Fire<Signal_SomeSignal>();

  someMock .Verify(x => x.DoSomething(), Times.Exactly(1));
}

But this doesn’t work. No Subscriptions.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
batrandcommented, Mar 9, 2020

Was having the same issue where BindSignal does not get called in unit tests; dropping in to confirm that adding Container.ResolveRoots() solves the issue.

1reaction
shadhexcommented, Apr 30, 2019

Once you have your signaled binded, try calling Container.ResolveRoots(); Also make sure you don’t have a [Setup] method that injects or resolves the signalbus.

[Test]
public void Signal_SomeSignal_ShouldFireAllRelated()
{
  SignalBusInstaller.Install(Container);
  ProjectSignals.BindSignals(Container); // Binds all my signals for my project

  var someMock = new Mock<ISomeInterface>();
  Container.Bind<ISomeInterface>().FromInstance(someMock.Object);
  Container.ResolveRoots(); //This guy

  var target = Container.Resolve<SignalBus>();
  target.Fire<Signal_SomeSignal>();

  someMock .Verify(x => x.DoSomething(), Times.Exactly(1));
}

In [Setup] you can call the installer there if you’d like


       //[Inject] SignalBus _signalBus = null;
        [SetUp]
        public void Install()
        {
           SignalBusInstaller.Install(Container);
            //do not inject _signalBus since you might be installing specific binding
            //in [test] later on.  Resolve<SignalBus> in invidual [test] instead.
           //Container.Inject(this);
        }

The example above were all doing this, but it will fail if SignalBus was also injected in [SetUp].

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to measure and evaluate binding affinities
A simple way to test whether binding occurs when there is no binding signal is to carry out a competition experiment.
Read more >
Ligand binding assay
Ligand binding assays provide a measure of the interactions that occur between two molecules, such as protein-bindings, as well as the degree of...
Read more >
Binding Check - Definition and Relevance | Nanopedia
For a Binding Check assay, the TRIC signal of Target and Complex are compared to yield a qualitative yes/no answer to whether there...
Read more >
Analyzing Kinetic Binding Data - Assay Guidance Manual
Experimentally the rates are determined by measuring the time course of test compound binding to the target, directly or indirectly.
Read more >
Yes-No Binding
The first step in using Biacore ® instrumentation to measure binding is to determine if binding between two molecules can be detected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found