public void MusicPlayer_Play_Do_NotPlay_UnderEdit() { //arrange IMusicFactory imf = Substitute.For<IMusicFactory>(); IInternalPlayer iip = Substitute.For<IInternalPlayer>(); imf.GetInternalPlayer().Returns(iip); iip.FileSource = null; IReadOnlyPlayList irop = Substitute.For<IReadOnlyPlayList>(); IInternalTrack it = Substitute.For<IInternalTrack>(); it.Path.Returns("MyPath"); it.InternalState.Returns(ObjectState.UnderEdit); irop.CurrentTrack.Returns(it); // act MusicPlayer target = new MusicPlayer(imf); target.MonitorEvents(); target.PlayList = irop; //assert target.PlayList.Should().Be(irop); target.MusicTrackSource.Should().Be(it); target.Mode.Should().Be(PlayMode.Stopped); target.ShouldRaisePropertyChangeFor(t => t.PlayList); target.ShouldRaisePropertyChangeFor(t => t.MusicTrackSource); iip.FileSource.Should().Be("MyPath"); iip.DidNotReceive().Play(); irop.DidNotReceive().Init(); iip.Listener.Should().Be(target); //act2 target.Pause(); //assert2 target.Mode.Should().Be(PlayMode.Stopped); iip.DidNotReceive().Pause(); //act3 target.Stop(); //assert3 target.Mode.Should().Be(PlayMode.Stopped); iip.DidNotReceive().Play(); //act4 IInternalMusicPlayer iimp = target; it.UpdatedState.Returns(ObjectState.Available); it.InternalState.Returns(ObjectState.Available); iimp.OnLockEvent(it, new ObjectStateChangeArgs(it, ObjectState.UnderEdit, ObjectState.Available)); target.Play(); //assert4 target.Mode.Should().Be(PlayMode.Play); }
public void MusicPlayer_Play_Do_NotPlay_Broken() { //arrange IMusicFactory imf = Substitute.For<IMusicFactory>(); IInternalPlayer iip = Substitute.For<IInternalPlayer>(); imf.GetInternalPlayer().Returns(iip); iip.FileSource = null; IReadOnlyPlayList irop = Substitute.For<IReadOnlyPlayList>(); IInternalTrack it = Substitute.For<IInternalTrack>(); it.Path.Returns("MyPath"); it.IsBroken.Returns(true); irop.CurrentTrack.Returns(it); // act MusicPlayer target = new MusicPlayer(imf); target.MonitorEvents(); target.PlayList = irop; //assert target.PlayList.Should().Be(irop); target.MusicTrackSource.Should().Be(it); target.Mode.Should().Be(PlayMode.Stopped); target.ShouldRaisePropertyChangeFor(t => t.PlayList); target.ShouldRaisePropertyChangeFor(t => t.MusicTrackSource); iip.FileSource.Should().Be("MyPath"); iip.DidNotReceive().Play(); irop.DidNotReceive().Init(); iip.Listener.Should().Be(target); //act2 target.Pause(); //assert2 target.Mode.Should().Be(PlayMode.Stopped); iip.DidNotReceive().Pause(); //act2 target.Stop(); //assert2 target.Mode.Should().Be(PlayMode.Stopped); }