コード例 #1
0
        public void ClockDataCollectionTest_SortByClosestRingingMoment()
        {
            // Arrange
            var f = new MainForm();

            var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer)
            {
                Tag             = "t1",
                GroupName       = "test",
                CurrentTimeSpan = TimeSpan.FromMinutes(60)
            };

            var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer)
            {
                Tag             = "t2",
                CurrentTimeSpan = TimeSpan.FromMinutes(50)
            };

            var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer)
            {
                Tag             = "t3",
                CurrentTimeSpan = TimeSpan.FromMinutes(20)
            };

            var ad4 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer)
            {
                Tag             = "a4",
                CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(40)
            };

            var ad5 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer)
            {
                Tag             = "a5",
                CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(1000)
            };

            // Act
            f.MyDataFile.ClockMCollection.IsUnsavedLocked = true;
            f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3, ad4, ad5);
            f.MyDataFile.ClockMCollection.IsUnsavedLocked = false;

            td1.StartOrStop();
            td2.StartOrStop();
            td3.StartOrStop();
            ad4.ActivateOrDeactivate();

            f.MyDataFile.ClockMCollection.AutosortMode = AutosortMode.ClosestRingingMoment;
            f.MyDataFile.ClockMCollection.SortByClosestRingingMoment();

            // order changed
            Assert.AreEqual(td3, f.MyDataFile.ClockMCollection.Ms[0]);
            Assert.AreEqual(ad4, f.MyDataFile.ClockMCollection.Ms[1]);
            Assert.AreEqual(td2, f.MyDataFile.ClockMCollection.Ms[2]);
            Assert.AreEqual(td1, f.MyDataFile.ClockMCollection.Ms[3]);
            Assert.AreEqual(ad5, f.MyDataFile.ClockMCollection.Ms[4]);
            Assert.IsTrue(f.MyDataFile.ClockMCollection.IsUnsaved);
        }