Beispiel #1
0
        public void Drop_EffectIsCopyAndTargetCollectionIsActiveSoundsAndDataIsAnEnumerableOfISounds_AddsAllSoundsToSoundService()
        {
            //Arrange
            Target = CreateTarget();

            ICollection <ISound> targetCollection = Target.SoundService.ActiveSounds;
            IEnumerable <ISound> droppedSounds    = new ISound[]
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                                 CommonStubsFactory.StubClonableSoundWithRandomName(),
                                 CommonStubsFactory.StubClonableSoundWithRandomName()
            };

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

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

            //Act
            Target.Drop(dropInfo);

            //Assert
            targetCollection.ShouldBeEquivalentTo(droppedSounds);
        }
Beispiel #2
0
        public void DragOver_DataIsAnEnumerableOfISoundsAndTargetCollectionContainsThoseSoundsAndIsReadOnly_SetsEffectsToNone()
        {
            //Arrange
            Target = CreateTarget();

            IEnumerable <ISound> droppedSounds = new ISound[]
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                                 CommonStubsFactory.StubClonableSoundWithRandomName(),
                                 CommonStubsFactory.StubClonableSoundWithRandomName()
            };
            ReadOnlyObservableCollection <ISound> targetCollection =
                new ReadOnlyObservableCollection <ISound>(
                    new ObservableCollection <ISound>(droppedSounds));

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

            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(droppedSounds);

            //Act
            Target.DragOver(dropInfo);

            //Assert
            dropInfo.Effects.ShouldBeEquivalentTo(DragDropEffects.None);
        }
Beispiel #3
0
        public void Drop_EffectIsCopyAndDataIsASingleISound_InsertsSoundIntoTargetCollection()
        {
            //Arrange
            Target = CreateTarget();

            ISound droppedSound = CommonStubsFactory.StubClonableSoundWithRandomName();
            ObservableCollection <ISound> targetCollection = new ObservableCollection <ISound>
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          CommonStubsFactory.StubClonableSoundWithRandomName(),
                                          CommonStubsFactory.StubClonableSoundWithRandomName(),
            };

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


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

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

            //Act
            Target.Drop(dropInfo);

            //Assert
            targetCollection.ShouldBeEquivalentTo(expectedCollection);
        }
Beispiel #4
0
        public void ToggleSoundIsLoopedCommandExecute_IsLoopedWasFalse_IsLoopedIsNowTrue()
        {
            ISound sound = CommonStubsFactory.StubClonableSoundWithRandomName();

            sound.IsLooped = false;
            Target         = CreateTarget();

            Target.Commands.ToggleSoundIsLoopedCommand.Execute(sound);

            sound.IsLooped.Should().BeTrue();
        }
Beispiel #5
0
        public void ActivateSingleSoundCommand_SelectedSoundIsNotNull_AddedSoundIsSelected()
        {
            //Arrange
            Target = CreateTarget();
            ISound sound = CommonStubsFactory.StubClonableSoundWithRandomName();

            //Act
            Target.Commands.ActivateSingleSoundCommand.Execute(sound);

            //Assert
            Target.SelectedActiveSound.ShouldBeEquivalentTo(sound);
        }
Beispiel #6
0
        public void ActivateSingleSoundCommand_ParameterIsNotNull_AddsCloneOfSoundToActiveSounds()
        {
            //Arrange
            ObservableCollection <ISound> activeSounds           = new ObservableCollection <ISound>();
            IObservableSoundService       observableSoundService = CommonStubsFactory.StubObservableSoundService(activeSounds);

            Target = CreateTarget(soundService: observableSoundService);
            ISound sound = CommonStubsFactory.StubClonableSoundWithRandomName();

            //Act
            Target.Commands.ActivateSingleSoundCommand.Execute(sound);

            //Assert
            activeSounds.Should().NotContain(s => ReferenceEquals(s, sound));
            activeSounds.Single().ShouldBeEquivalentTo(sound);
        }
Beispiel #7
0
        public void DragOver_TargetCollectionIsNull_SetsEffectsToNone()
        {
            //Arrange
            Target = CreateTarget();

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

            dropInfo.Effects = DragDropEffects.All;
            dropInfo.Stub(info => info.Data).Return(CommonStubsFactory.StubClonableSoundWithRandomName());
            dropInfo.Stub(info => info.TargetCollection).Return(null);

            //Act
            Target.DragOver(dropInfo);

            //Assert
            dropInfo.Effects.ShouldBeEquivalentTo(DragDropEffects.None);
        }
Beispiel #8
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());
        }
Beispiel #9
0
        public void DragOver_DataIsASingleSoundAndTargetCollectionDoesNotContainSound_SetsEffectsToCopy()
        {
            //Arrange
            Target = CreateTarget();

            ISound droppedSound = CommonStubsFactory.StubClonableSoundWithRandomName();
            ObservableCollection <ISound> targetCollection = new ObservableCollection <ISound>();
            IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>();

            dropInfo.Stub(info => info.TargetCollection).Return(targetCollection);
            dropInfo.Stub(info => info.Data).Return(droppedSound);

            //Act
            Target.DragOver(dropInfo);

            //Assert
            dropInfo.Effects.ShouldBeEquivalentTo(DragDropEffects.Copy);
        }
Beispiel #10
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);
        }
        public void ActivateSoundsCommandExecute_ParameterContainsIListWith3Sounds_Adds3EquivalentClonesToActiveSounds()
        {
            //Arrange
            List <ISound> selectedSounds = new List <ISound>
            {
                CommonStubsFactory.StubClonableSoundWithRandomName(),
                          CommonStubsFactory.StubClonableSoundWithRandomName(),
                          CommonStubsFactory.StubClonableSoundWithRandomName()
            };
            IMainWindowViewModel mainWindowViewModel = CommonStubsFactory.StubMainWindowViewModel();

            Target = CreateTargetWithDefaultStubs(mainWindowViewModel);

            //Act
            Target.ActivateSoundsCommand.Execute(selectedSounds);

            //Assert
            for (var i = 0; i < selectedSounds.Count; i++)
            {
                mainWindowViewModel.SoundService.ActiveSounds[i].ShouldBeEquivalentTo(selectedSounds[i],
                                                                                      "for each selected sound there must be an identical active sound");
                mainWindowViewModel.SoundService.ActiveSounds[i].Should().NotBeSameAs(selectedSounds[i], "it must be a clone, not the same reference");
            }
        }