public void MusicPlayer_Set_PlayList_CurrentTrack_Null()
        {
            //arrange
            IMusicFactory imf = Substitute.For<IMusicFactory>();
            IInternalPlayer iip = Substitute.For<IInternalPlayer>();
            imf.GetInternalPlayer().Returns(iip);

            MusicPlayer target = new MusicPlayer(imf);

            IReadOnlyPlayList irop = Substitute.For<IReadOnlyPlayList>();
            irop.CurrentTrack = null;

            target.MonitorEvents();           
            
            //act
            target.PlayList = irop;

            //assert
            target.PlayList.Should().Be(irop);
            target.ShouldRaisePropertyChangeFor(t => t.PlayList);
            target.Mode.Should().Be( PlayMode.Stopped);

            target.Dispose();
        }
        public void MusicPlayer_Set_PlayList_Change_Track()
        {
            //arrange
            IMusicFactory imf = Substitute.For<IMusicFactory>();
            IInternalPlayer iip = Substitute.For<IInternalPlayer>();
            imf.GetInternalPlayer().Returns(iip);

            MusicPlayer target = new MusicPlayer(imf);

            IReadOnlyPlayList irop = Substitute.For<IReadOnlyPlayList>();
            IInternalTrack it = Substitute.For<IInternalTrack>();
            it.Path.Returns("MyPath");
            irop.CurrentTrack = it;

            target.PlayList = irop;

            IInternalTrack it2 = Substitute.For<IInternalTrack>();
            it2.Path.Returns("MyPath2");

            target.MonitorEvents();

            //act

            irop.ChangeCurrent(it2);

            //assert
            iip.FileSource.Should().Be("MyPath2");
            iip.Received().Play();
            target.ShouldRaisePropertyChangeFor(t => t.MusicTrackSource);

            target.Mode.Should().Be(PlayMode.Play);
            target.MusicTrackSource.Should().Be(it2);

            //clean
            target.Dispose();
        }
        public void MusicPlayer_Volume_Change()
        {
            //arrange
            IMusicFactory imf = Substitute.For<IMusicFactory>();
            IInternalPlayer iip = Substitute.For<IInternalPlayer>();
            imf.GetInternalPlayer().Returns(iip);
            iip.Volume.Returns(0.5d);

            MusicPlayer target = new MusicPlayer(imf);
               
            //act-assert 1
            target.Volume.Should().Be(0.5d); 

            //act-assert 2
            target.MonitorEvents();
            target.Volume = 0.2;
            target.Volume.Should().Be(0.2d);
            iip.Volume.Should().Be(0.2d);
            //iip.Listener.OnVolumeChange();
            target.ShouldRaisePropertyChangeFor(t => t.Volume);

            //act-assert 3
            target.Volume = -1;
            target.Volume.Should().Be(0d);
            iip.Volume.Should().Be(0d);

            //act-assert 4
            target.Volume = 5;
            target.Volume.Should().Be(1d);
            iip.Volume.Should().Be(1d);

            //assert
            
            target.PlayList.Should().BeNull();

            target.Mode.Should().Be(PlayMode.Stopped);
            target.MusicTrackSource.Should().Be(null);

            //clean
            target.Dispose();
        }
        public void MusicPlayer_Position_Change()
        {
            //arrange
            IMusicFactory imf = Substitute.For<IMusicFactory>();
            IInternalPlayer iip = Substitute.For<IInternalPlayer>();
            imf.GetInternalPlayer().Returns(iip);
            iip.Position.Returns(TimeSpan.FromSeconds(9));

            MusicPlayer target = new MusicPlayer(imf);

            //act-assert 1
            target.Position.Should().Be(TimeSpan.FromSeconds(9));

            //act-assert 2
            target.MonitorEvents();
            target.Position = TimeSpan.FromSeconds(90);
            target.Position.Should().Be(TimeSpan.FromSeconds(90));
            iip.Position.Should().Be(TimeSpan.FromSeconds(90));

            //clean
            target.Dispose();
        }
        public void MusicPlayer_Set_PlayList_CurrentTrack_NotNull_ChangePlayList()
        {
            //arrange
            IMusicFactory imf = Substitute.For<IMusicFactory>();
            IInternalPlayer iip = Substitute.For<IInternalPlayer>();
            imf.GetInternalPlayer().Returns(iip);

            MusicPlayer target = new MusicPlayer(imf);

            IReadOnlyPlayList irop = Substitute.For<IReadOnlyPlayList>();
            IInternalTrack it = Substitute.For<IInternalTrack>();
            it.Path.Returns("MyPath");
            irop.CurrentTrack = it;

            target.PlayList = irop;

            //act
            target.MonitorEvents();
            target.PlayList = null;

            //assert
            target.ShouldRaisePropertyChangeFor(t => t.PlayList);
            target.PlayList.Should().BeNull();
            iip.Received().Stop();

            target.Mode.Should().Be(PlayMode.Stopped);
            target.MusicTrackSource.Should().Be(null);

            //clean
            target.Dispose();
        }