本文整理汇总了C#中PlayList.UpdateProbability方法的典型用法代码示例。如果您正苦于以下问题:C# PlayList.UpdateProbability方法的具体用法?C# PlayList.UpdateProbability怎么用?C# PlayList.UpdateProbability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayList
的用法示例。
在下文中一共展示了PlayList.UpdateProbability方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NoSelection4Music2Classic
public void NoSelection4Music2Classic()
{
var musicA = new Music("A") { Priority = 1 };
musicA[Constants.Tags.Genre] = "Classic";
var musicB = new Music("B") { Priority = 2 };
var musicC = new Music("C") { Priority = 3 };
musicC[Constants.Tags.Genre] = "Classic";
var musicD = new Music("D") { Priority = 4 };
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
var playList = new PlayList(_musicLibrary) { "A", "B", "C", "D" };
playList.UpdateProbability();
const double totalPriority = 10d;
const double unitProbability = 1d / totalPriority;
_store.VerifyAll();
AreEqual(unitProbability * musicA.Priority, playList["A"].Probability);
AreEqual(unitProbability * musicB.Priority, playList["B"].Probability);
AreEqual(unitProbability * musicC.Priority, playList["C"].Probability);
AreEqual(unitProbability * musicD.Priority, playList["D"].Probability);
AreEqual(unitProbability * 1, playList["A"].CumulativeProbability);
AreEqual(unitProbability * 3, playList["B"].CumulativeProbability);
AreEqual(unitProbability * 6, playList["C"].CumulativeProbability);
AreEqual(unitProbability * 10, playList["D"].CumulativeProbability);
}
示例2: NoSelection4MusicHasPriority1
public void NoSelection4MusicHasPriority1()
{
var musicA = new Music("A") { Priority = 1 };
var musicB = new Music("B") { Priority = 1 };
var musicC = new Music("C") { Priority = 1 };
var musicD = new Music("D") { Priority = 1 };
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
var playList = new PlayList(_musicLibrary) {"A","B","C","D"};
playList.UpdateProbability();
const double unitProbability = 1d / 4d;
Assert.AreEqual(unitProbability, playList["A"].Probability);
Assert.AreEqual(unitProbability, playList["B"].Probability);
Assert.AreEqual(unitProbability, playList["C"].Probability);
Assert.AreEqual(unitProbability, playList["D"].Probability);
Assert.AreEqual(unitProbability * 1, playList["A"].CumulativeProbability);
Assert.AreEqual(unitProbability * 2, playList["B"].CumulativeProbability);
Assert.AreEqual(unitProbability * 3, playList["C"].CumulativeProbability);
Assert.AreEqual(unitProbability * 4, playList["D"].CumulativeProbability);
}
示例3: NoSelection4MusicHasPriority1OneHas2
public void NoSelection4MusicHasPriority1OneHas2()
{
var musicA = new Music("A") { Priority = 1 };
var musicB = new Music("B") { Priority = 1 };
var musicC = new Music("C") { Priority = 1 };
var musicD = new Music("D") { Priority = 1 };
var musicE = new Music("E") { Priority = 2 };
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_store.SetupGetMusic(musicE);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
_musicLibrary.Add(musicE);
var playList = new PlayList(_musicLibrary) {"A","B","C","D","E"};
playList.UpdateProbability();
const double unitProbability = 1d / 6d;
Assert.AreEqual(unitProbability, playList["A"].Probability);
Assert.AreEqual(unitProbability, playList["B"].Probability);
Assert.AreEqual(unitProbability, playList["C"].Probability);
Assert.AreEqual(unitProbability, playList["D"].Probability);
Assert.AreEqual(2*unitProbability, playList["E"].Probability);
}
示例4: TwoClassic2RockClassicIsPlayingRepeatPriorityZero
public void TwoClassic2RockClassicIsPlayingRepeatPriorityZero()
{
_store.SetupGetTags(new[]
{
new MusicTag {Id = Constants.Tags.Genre, Priority = 2},
new MusicTag {Id = Constants.Tags.Album, Priority = 3}
});
_store.Setup(s => s.GetRepeatPriority()).Returns(0);
var musicA = new Music("A") { Priority = 1 };
musicA[Constants.Tags.Genre] = "Classic";
var musicB = new Music("B") { Priority = 2 };
musicB[Constants.Tags.Genre] = "Rock";
var musicC = new Music("C") { Priority = 3 };
musicC[Constants.Tags.Genre] = "Classic";
var musicD = new Music("D") { Priority = 4 };
musicD[Constants.Tags.Genre] = "Rock";
_store.SetupGetMusic(musicA);
_store.SetupGetMusic(musicB);
_store.SetupGetMusic(musicC);
_store.SetupGetMusic(musicD);
_musicLibrary.Add(musicA);
_musicLibrary.Add(musicB);
_musicLibrary.Add(musicC);
_musicLibrary.Add(musicD);
var playList = new PlayList(_musicLibrary) { "A", "B", "C", "D" };
playList.SetPlaying("A");
playList.UpdateProbability();
const double totalPriority = 13d;
const double unitProbability = 1d / totalPriority;
_store.VerifyAll();
AreEqual(0, playList["A"].Probability);
AreEqual(unitProbability * musicB.Priority, playList["B"].Probability);
AreEqual(unitProbability * (musicC.Priority + 4d), playList["C"].Probability);
AreEqual(unitProbability * musicD.Priority, playList["D"].Probability);
AreEqual(0, playList["A"].CumulativeProbability);
AreEqual(unitProbability * 2, playList["B"].CumulativeProbability);
AreEqual(unitProbability * 9, playList["C"].CumulativeProbability);
AreEqual(unitProbability * 13, playList["D"].CumulativeProbability);
}