Exemplo n.º 1
0
 public MessageComposer(IContainer container)
 {
     serializer    = container.Resolve <ISerializer>();
     compression   = container.Resolve <ICompression>();
     encryption    = container.Resolve <IEncryption>();
     commandHolder = container.Resolve <ICommandHolder>();
     arrayPool     = container.Resolve <IArrayPool>();
 }
        public CommandRaiser(IContainerConfig config)
        {
            this.config = config;

            using (var container = config.Create())
            {
                commandHolder = container.Resolve <ICommandHolder>();
            }
        }
Exemplo n.º 3
0
        public void InvokeCommandAgainstICommandInTargetRespectsCanExecuteWindow()
        {
            var executed = false;
            var canExecute = new BehaviorSubject<bool>(false);
            var fixture = new ICommandHolder();
            var source = new Subject<Unit>();
            source.InvokeCommand(fixture, x => x.TheCommand);
            fixture.TheCommand = ReactiveCommand.Create(() => executed = true, canExecute);

            source.OnNext(Unit.Default);
            Assert.False(executed);

            // The execution window re-opens, but the above execution request should not be instigated because
            // it occurred when the window was closed. Execution requests do not queue up when the window is closed.
            canExecute.OnNext(true);
            Assert.False(executed);
        }
Exemplo n.º 4
0
        public void InvokeCommandAgainstICommandInTargetRespectsCanExecute()
        {
            var executed = false;
            var canExecute = new BehaviorSubject<bool>(false);
            var fixture = new ICommandHolder();
            var source = new Subject<Unit>();
            source.InvokeCommand(fixture, x => x.TheCommand);
            fixture.TheCommand = ReactiveCommand.Create(() => executed = true, canExecute);

            source.OnNext(Unit.Default);
            Assert.False(executed);

            canExecute.OnNext(true);
            source.OnNext(Unit.Default);
            Assert.True(executed);
        }
Exemplo n.º 5
0
        public void InvokeCommandAgainstICommandInTargetPassesTheSpecifiedValueToCanExecuteAndExecute()
        {
            var fixture = new ICommandHolder();
            var source = new Subject<int>();
            source.InvokeCommand(fixture, x => x.TheCommand);
            var command = new FakeCommand();
            fixture.TheCommand = command;

            source.OnNext(42);
            Assert.Equal(42, command.CanExecuteParameter);
            Assert.Equal(42, command.ExecuteParameter);
        }
Exemplo n.º 6
0
        public void InvokeCommandAgainstICommandInTargetInvokesTheCommand()
        {
            var executionCount = 0;
            var fixture = new ICommandHolder();
            var source = new Subject<Unit>();
            source.InvokeCommand(fixture, x => x.TheCommand);
            fixture.TheCommand = ReactiveCommand.Create(() => ++executionCount);

            source.OnNext(Unit.Default);
            Assert.Equal(1, executionCount);

            source.OnNext(Unit.Default);
            Assert.Equal(2, executionCount);
        }