本文整理汇总了C#中System.Net.Player.Next方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Next方法的具体用法?C# Player.Next怎么用?C# Player.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Player
的用法示例。
在下文中一共展示了Player.Next方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestNext
public async void TestNext(NextCommandType type)
{
var playList = _defaultPlayList.DeepClone();
string reportType = GetReportTypeStringByNextCommandType(type);
var serverConnectionMock = new Mock<IServerConnection>();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist")
&& (u.GetQueries().Contains(new KeyValuePair<string, string>("type", "n"))
|| u.GetQueries().Contains(new KeyValuePair<string, string>("type", reportType)))
&& !u.GetQueries().ContainsKey("start")),
It.IsAny<Action<HttpWebRequest>>())).Returns(() => Task.FromResult(playList.ToString())).Callback(
() =>
{
if (type == NextCommandType.CurrentSongEnded)
{
playList["song"] = new JArray();
}
else
{
var first = playList["song"][0];
first.Remove();
playList["song"].Last.AddAfterSelf(first);
}
}).Verifiable();
var session = new Session(serverConnectionMock.Object);
var player = new Player(session);
await player.ChangeChannel(new Channel(0));
var originalSong = player.CurrentSong;
for (var i = 0; i < 5; ++i)
{
await player.Next(type);
var newSong = player.CurrentSong;
Assert.AreNotEqual(newSong, originalSong);
originalSong = newSong;
}
serverConnectionMock.Verify();
}
示例2: TestNoAvailableSongs_Next
public async void TestNoAvailableSongs_Next(NextCommandType type)
{
var emptyPlayList = _defaultPlayList.DeepClone();
emptyPlayList["song"] = new JArray();
var serverConnectionMock = new Mock<IServerConnection>();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "n"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(Resource.PlayList).Verifiable();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", GetReportTypeStringByNextCommandType(type)))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(emptyPlayList.ToString()).Verifiable();
var player = new Player(new Session(serverConnectionMock.Object));
await player.ChangeChannel(new Channel(0));
await AssertEx.ThrowsAsync<NoAvailableSongsException>(async () => await player.Next(type));
serverConnectionMock.Verify();
}
示例3: TestChannelNotSelectedException
public async void TestChannelNotSelectedException()
{
var serverConnectionMock = new Mock<IServerConnection>();
var session = new Session(serverConnectionMock.Object);
var player = new Player(session);
await AssertEx.ThrowsAsync<ChannelNotSelectedException>(async () => await player.Next(NextCommandType.SkipCurrentSong));
}
示例4: TestSongNotSelectedException
public async void TestSongNotSelectedException()
{
var playList = _defaultPlayList.DeepClone();
var emptyPlayList = _defaultPlayList.DeepClone();
emptyPlayList["song"] = new JArray();
var serverConnectionMock = new Mock<IServerConnection>();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "n"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(playList.ToString()).Verifiable();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "p"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(playList.ToString()).Verifiable();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "s"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(emptyPlayList.ToString()).Verifiable();
var session = new Session(serverConnectionMock.Object);
var player = new Player(session);
await player.ChangeChannel(new Channel(0));
await AssertEx.ThrowsAsync<NoAvailableSongsException>(async () => await player.Next(NextCommandType.SkipCurrentSong));
Assert.IsNotNull(player.CurrentChannel);
Assert.IsNull(player.CurrentSong);
await AssertEx.ThrowsAsync<SongNotSelectedException>(async () => await player.SetRedHeart(true));
}
示例5: TestSongEnded
public async void TestSongEnded()
{
var playList = _defaultPlayList.DeepClone();
var emptyPlayList = _defaultPlayList.DeepClone();
emptyPlayList["song"] = new JArray();
var serverConnectionMock = new Mock<IServerConnection>();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "n"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(playList.ToString()).Verifiable();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "p"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(playList.ToString()).Verifiable();
serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist") && u.GetQueries().Contains(new KeyValuePair<string, string>("type", "e"))),
It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(emptyPlayList.ToString()).Verifiable();
var session = new Session(serverConnectionMock.Object);
var player = new Player(session);
await player.ChangeChannel(new Channel(0));
var songCount = playList["song"].Count();
for (var i = 0; i < songCount*2; ++i)
{
await player.Next(NextCommandType.CurrentSongEnded);
}
serverConnectionMock.Verify();
}