public void SignalCommandContainer_UnbindLifeTime_AreEqual() { // Arrange var container = new DiContainer(); var commandContainer = new SignalCommandContainer(container); var expected = commandContainer.Bind <SignalTest>(); var unused = expected.InGlobal() .InParallel() .To <CommandTest>(); // Act commandContainer.Unbind(LifeTime.Local); var actual = commandContainer.Bind <SignalTest>(); //Assert Assert.AreEqual(expected, actual); }
public void SignalCommandContainer_Bind() { // Arrange var container = new DiContainer(); // Act var signalCommandContainer = new SignalCommandContainer(container); var actual = signalCommandContainer.Bind <SignalTest>(); //Assert Assert.IsNotNull(actual); }
public void SignalCommandContainer_Unbind_ReturnTrue() { // Arrange var container = new DiContainer(); var commandContainer = new SignalCommandContainer(container); commandContainer.Bind <SignalTest>() .InGlobal() .InParallel() .To <CommandTest>(); // Act var actual = commandContainer.Unbind <SignalTest>(); //Assert Assert.IsTrue(actual); }
public void SignalCommandContainer_UnbindLifeTime_SignalRelease() { // Arrange var container = new DiContainer(); var commandContainer = new SignalCommandContainer(container); var signal = container.GetInstance <SignalTest>(); var unused = commandContainer.Bind <SignalTest>() .InLocal() .InParallel() .To <CommandTest>(); // Act commandContainer.Unbind(LifeTime.Local); var actual = signal.Dispatch(); //Assert Assert.IsFalse(actual); }
public void SignalCommandContainer_ReactTo() { // Arrange var actual = 0; var container = new DiContainer(); var commandContainer = new SignalCommandContainer(container); CommandTest.Callback = () => actual++; // Act commandContainer.Bind <SignalTest>() .InGlobal() .InParallel() .To <CommandTest>() .To <CommandTest>() .Execute(); //Assert Assert.AreEqual(2, actual); }
public void SignalCommandContainer_Bind_Exception() { // Arrange var actual = false; var container = new DiContainer(); var signalCommandContainer = new SignalCommandContainer(container); // Act try { var unused = signalCommandContainer.Bind <SignalFakeTest>(); } catch (InvalidOperationException) { actual = true; } //Assert Assert.IsNotNull(actual); }