public async Task CommandBus_Subscribes_With_On() { var bus = new CommandBus(); var source = new TaskCompletionSource <bool>(); dynamic input = new InteropMock() { type = "SaveCommand", subscriber = (cmd) => { var saveCommand = (SaveCommand)cmd; Assert.That(saveCommand.DeviceId, Is.EqualTo("1234")); bus.RemoveAllSubscriptions(); source.SetResult(true); return(null); } }; bus.On(input); var command = new SaveCommand("1234"); await bus.Publish(command); await source.Task; }
public async Task CommandBus_Subscribes_With_On() { var bus = new CommandBus(); var source = new TaskCompletionSource<bool>(); dynamic input = new InteropMock() { type = "SaveCommand", subscriber = (cmd) => { var saveCommand = (SaveCommand)cmd; Assert.That(saveCommand.DeviceId, Is.EqualTo("1234")); bus.RemoveAllSubscriptions(); source.SetResult(true); return null; } }; bus.On(input); var command = new SaveCommand("1234"); await bus.Publish(command); await source.Task; }