コード例 #1
0
        public void TestAddFilesToHistory()
        {
            var firstFile = new HistoryItem()
            {
                Position = 0.1f,
                FilePath = "File1",
                Volume = 1d,
                PlayedDate = DateTime.Now
            };
            m_model.LastPlayedFile = firstFile;

            var secondFile = new HistoryItem()
            {
                Position = 0.1f,
                FilePath = "File2",
                Volume = 1d,
                PlayedDate = DateTime.Now
            };
            m_model.LastPlayedFile = secondFile;

            var historyItem = m_model.GetHistoryInfo(firstFile.FilePath);
            Assert.IsNotNull(historyItem);
            Assert2ItemsAreEqual(firstFile, historyItem);

            historyItem = m_model.GetHistoryInfo(secondFile.FilePath);
            Assert.IsNotNull(historyItem);
            Assert2ItemsAreEqual(secondFile, historyItem);
        }
コード例 #2
0
 public void SaveLastPlayInfo()
 {
     if (m_model.CurrentFilePath != null)
     {
         var item = new HistoryItem()
         {
             Position = m_model.Position,
             FilePath = m_model.CurrentFilePath,
             Volume = m_model.Volume,
             PlayedDate = DateTime.Now
         };
         HistoryModel.Instance.LastPlayedFile = item;
         HistoryModel.Instance.Save();
     }
 }
コード例 #3
0
ファイル: HistoryModel.cs プロジェクト: EbenZhang/EZPlayer
 private void AddItem(HistoryItem item)
 {
     if (m_historyItems.Count != 0)
     {
         Trace.Assert(item.PlayedDate >= m_historyItems[0].PlayedDate);
     }
     var matched = m_historyItems.Find(i => i.FilePath == item.FilePath);
     m_historyItems.RemoveAll(i => i.FilePath == item.FilePath);
     m_historyItems.Insert(0, item);
 }
コード例 #4
0
        public void TestPlaySameFileServalTimes()
        {
            var playedYesterday = new HistoryItem()
            {
                Position = 0.1f,
                FilePath = "File1",
                Volume = 1d,
                PlayedDate = DateTime.Now - TimeSpan.FromDays(1d)
            };

            m_model.LastPlayedFile = playedYesterday;

            var playedToday = new HistoryItem()
            {
                Position = 0.2f,
                FilePath = playedYesterday.FilePath,
                Volume = 0.5d,
                PlayedDate = DateTime.Now
            };
            m_model.LastPlayedFile = playedToday;

            var historyItem = m_model.GetHistoryInfo(playedToday.FilePath);
            Assert.IsNotNull(historyItem);
            Assert2ItemsAreEqual(playedToday, historyItem);
            Assert2ItemsAreEqual(playedToday, m_model.LastPlayedFile);
        }
コード例 #5
0
 private static void Assert2ItemsAreEqual(HistoryItem expected, HistoryItem historyItem)
 {
     Assert.AreEqual(expected.FilePath, historyItem.FilePath);
     Assert.AreEqual(expected.Position, historyItem.Position);
     Assert.AreEqual(expected.PlayedDate, historyItem.PlayedDate);
     Assert.AreEqual(expected.Volume, historyItem.Volume);
 }
コード例 #6
0
        public void TestSetLastPlayedFile()
        {
            var expected = new HistoryItem()
            {
                Position = 0.1f,
                FilePath = "DummyPath",
                Volume = 1d,
                PlayedDate = DateTime.Now
            };
            m_model.LastPlayedFile = expected;
            Assert2ItemsAreEqual(expected, m_model.LastPlayedFile);

            var historyItem = m_model.GetHistoryInfo(expected.FilePath);
            Assert.IsNotNull(historyItem);
            Assert2ItemsAreEqual(expected, historyItem);
        }
コード例 #7
0
 public HistoryItemUI(HistoryItem item)
 {
     m_item = item;
 }