Ejemplo n.º 1
0
        public void Given_a_CommandManager_When_calling_Completed_multiple_times_Should_fire_only_once()
        {
            int               timesCalledCompleted = 0;
            var               aggregator           = new Mock <IEventAggregator>();
            CommandManager    manager = new CommandManager(aggregator.Object, SynchronizationContext.Current);
            CompletingCommand cmd     = new CompletingCommand(5);

            manager.Do(Execute.The(cmd).AndWhenCompletedCall(state => timesCalledCompleted++));

            Assert.IsTrue(timesCalledCompleted == 1, "Completed was called multiple times.");
        }
Ejemplo n.º 2
0
        public void Given_a_CommandManager_After_Execution_of_Command_Should_call_Completed_Automagically()
        {
            int               timesCalledCompleted = 0;
            var               aggregator           = new Mock <IEventAggregator>();
            CommandManager    manager = new CommandManager(aggregator.Object, SynchronizationContext.Current);
            CompletingCommand cmd     = new CompletingCommand(0);

            manager.Do(Execute.The(cmd).AndWhenCompletedCall(state => timesCalledCompleted++));

            Assert.IsTrue(timesCalledCompleted == 1, "Completed was never called automatically.");
        }