public void TestFeedCommandToSequence() { TestDelegate testDelegate = delegate { sequencer.Bind(SomeEnum.ONE).To <CommandWithExecute> (); }; //That the exception is thrown demonstrates that the last command ran SequencerException ex = Assert.Throws <SequencerException> (testDelegate); Assert.AreEqual(ex.type, SequencerExceptionType.COMMAND_USED_IN_SEQUENCE); }
public void TestMissingExecute() { ISequenceCommand command = new SequenceCommandWithoutExecute(); TestDelegate testDelegate = delegate() { command.Execute(); }; SequencerException ex = Assert.Throws <SequencerException> (testDelegate); Assert.That(ex.type == SequencerExceptionType.EXECUTE_OVERRIDE); }
public void TestSequence() { //CommandWithInjection requires an ISimpleInterface injectionBinder.Bind <ISimpleInterface>().To <SimpleInterfaceImplementer> ().ToSingleton(); //Bind the trigger to the command sequencer.Bind(SomeEnum.ONE).To <SequenceCommandWithInjection>().To <SequenceCommandWithExecute>().To <SequenceCommandWithoutExecute>(); TestDelegate testDelegate = delegate { sequencer.ReactTo(SomeEnum.ONE); }; //That the exception is thrown demonstrates that the last command ran SequencerException ex = Assert.Throws <SequencerException> (testDelegate); Assert.AreEqual(ex.type, SequencerExceptionType.EXECUTE_OVERRIDE); //That the value is 100 demonstrates that the first command ran ISimpleInterface instance = injectionBinder.GetInstance <ISimpleInterface>() as ISimpleInterface; Assert.AreEqual(100, instance.intValue); }