Esempio n. 1
0
        public void Drop_EffectIsMoveAndDataIsAnEnumerableOfISounds_MovesAllSoundsToCorrectPositionInExistingOrder()
        {
            //Arrange
            Target = CreateTarget();

            ISound[] droppedSounds =
            {
                CommonStubsFactory.StubClonableSound("FirstMovedSound"),
                CommonStubsFactory.StubClonableSound("SecondMovedSound"),
                CommonStubsFactory.StubClonableSound("ThirdMovedSound"),
            };

            ObservableCollection <ISound> targetCollection = new ObservableCollection <ISound>
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          droppedSounds[0],
                                          droppedSounds[1],
                                          droppedSounds[2],
            };

            ISound[] expectedCollection =
            {
                targetCollection[0],
                droppedSounds[0],
                droppedSounds[1],
                droppedSounds[2],
                targetCollection[1],
                targetCollection[2]
            };

            IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>();

            dropInfo.Effects = DragDropEffects.Move;
            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(droppedSounds);
            dropInfo.Stub(info => info.InsertIndex).Return(1);

            //Act
            Target.Drop(dropInfo);

            //Assert
            targetCollection.ShouldBeEquivalentTo(expectedCollection, options => options.WithStrictOrdering());
        }
        public void RenameSoundCommandExecute_DialogReturnsNull_OldNameIsRetained()
        {
            //Arrange
            const string expected = "Old Name";

            ISound         selectedSound = CommonStubsFactory.StubClonableSound("Old Name");
            IDialogService stub          = MockRepository.GenerateStub <IDialogService>();

            Target = CreateTargetWithDefaultStubs(dialogService: stub);

            stub.Stub(service => service.NameDialog(null, null, null, null)).IgnoreArguments().Return(null);

            //Act
            Target.RenameSoundCommand.Execute(new Collection <ISound> {
                selectedSound
            });

            //Assert
            selectedSound.Name.Should().Be(expected);
        }
        public void RenameSoundCommandExecute__NameDialogIsCalledWithTitlePromptAndInitialName()
        {
            ISound         selectedSound = CommonStubsFactory.StubClonableSound("Old Name");
            IDialogService mock          = MockRepository.GenerateMock <IDialogService>();

            Target = CreateTargetWithDefaultStubs(dialogService: mock);

            mock.Expect(service => service.NameDialog(
                            Arg <Window> .Is.Anything,
                            Arg <string> .Is.Anything,
                            Arg <string> .Is.Anything,
                            Arg <string> .Is.Equal(selectedSound.Name)))
            .Return(null);

            //Act
            Target.RenameSoundCommand.Execute(new Collection <ISound> {
                selectedSound
            });

            //Assert
            mock.VerifyAllExpectations();
        }
Esempio n. 4
0
        public void Drop_EffectIsMoveAndDataIsASingleISound_MovesSoundToCorrectPosition()
        {
            //Arrange
            const int moveTargetIndex = 2;

            Target = CreateTarget();

            ISound movedSound = CommonStubsFactory.StubClonableSound("Index2");
            ObservableCollection <ISound> targetCollection = new ObservableCollection <ISound>
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          movedSound,
                                          CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          CommonStubsFactory.StubClonableSoundWithRandomName()
            };

            IEnumerable <ISound> expectedCollection = new ObservableCollection <ISound>
            {
                targetCollection[0],
                targetCollection[2],
                movedSound,                 // index 2
                targetCollection[3]
            };

            IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>();

            dropInfo.Effects = DragDropEffects.Move;
            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(movedSound);
            dropInfo.Stub(info => info.InsertIndex).Return(moveTargetIndex);

            //Act
            Target.Drop(dropInfo);

            //Assert
            targetCollection.ShouldBeEquivalentTo(expectedCollection);
        }