public void TestAtCanExecuteReturnererFalseHvisCanExecuteOnCommandsReturnererFalse()
        {
            var fixture = new Fixture();

            fixture.Customize <ICommand>(e => e.FromFactory(() =>
            {
                var mock = MockRepository.GenerateMock <ICommand>();
                mock.Expect(m => m.CanExecute(Arg <object> .Is.Anything))
                .Return(false)
                .Repeat.Any();
                return(mock);
            }));

            var commandMockCollection = fixture.CreateMany <ICommand>(25).ToList();

            Assert.That(commandMockCollection, Is.Not.Null);
            Assert.That(commandMockCollection, Is.Not.Empty);

            var command = new CommandCollectionExecuterCommand(commandMockCollection);

            Assert.That(command, Is.Not.Null);

            var parameter = fixture.Create <object>();
            var result    = command.CanExecute(parameter);

            Assert.That(result, Is.False);

            foreach (var commandMock in commandMockCollection)
            {
                commandMock.AssertWasCalled(m => m.CanExecute(Arg <object> .Is.Equal(parameter)));
            }
        }
        public void TestAtConstructorInitiererCommandCollectionExecuterCommand()
        {
            var fixture = new Fixture();

            fixture.Customize <ICommand>(e => e.FromFactory(() => MockRepository.GenerateMock <ICommand>()));

            var command = new CommandCollectionExecuterCommand(fixture.CreateMany <ICommand>().ToList());

            Assert.That(command, Is.Not.Null);
        }
        public void TestAtCanExecuteReturnererFalseHvisCommandCollectionErEmpty()
        {
            var fixture = new Fixture();

            var commandMockCollection = new List <ICommand>(0);

            Assert.That(commandMockCollection, Is.Not.Null);
            Assert.That(commandMockCollection, Is.Empty);

            var command = new CommandCollectionExecuterCommand(commandMockCollection);

            Assert.That(command, Is.Not.Null);

            Assert.That(command.CanExecute(fixture.Create <object>()), Is.False);
        }
        public void TestAtExecuteExecutesExecutableCommands()
        {
            var fixture = new Fixture();

            fixture.Customize <ICommand>(e => e.FromFactory(() =>
            {
                var mock = MockRepository.GenerateMock <ICommand>();
                mock.Expect(m => m.CanExecute(Arg <object> .Is.Anything))
                .Return(false)
                .Repeat.Any();
                return(mock);
            }));

            var executeableCommand = MockRepository.GenerateMock <ICommand>();

            executeableCommand.Expect(m => m.CanExecute(Arg <object> .Is.Anything))
            .Return(true)
            .Repeat.Any();

            var commandMockCollection = fixture.CreateMany <ICommand>(24).ToList();

            commandMockCollection.Add(executeableCommand);
            Assert.That(commandMockCollection, Is.Not.Null);
            Assert.That(commandMockCollection, Is.Not.Empty);

            var command = new CommandCollectionExecuterCommand(commandMockCollection);

            Assert.That(command, Is.Not.Null);

            var parameter = fixture.Create <object>();

            command.Execute(parameter);

            foreach (var commandMock in commandMockCollection)
            {
                commandMock.AssertWasCalled(m => m.CanExecute(Arg <object> .Is.Equal(parameter)));
            }
            for (var commandNo = 0; commandNo < commandMockCollection.Count - 1; commandNo++)
            {
                commandMockCollection.ElementAt(commandNo).AssertWasNotCalled(m => m.Execute(Arg <object> .Is.Anything));
            }
            executeableCommand.AssertWasCalled(m => m.Execute(Arg <object> .Is.Equal(parameter)));
        }