public void DataFileTest_LoadClock() { var mf = new MainForm(); mf.Show(); var el = CreateTestAlarmClockXmlElement(); var acm = new List <ClockM>(); mf.MyDataFile.LoadClock(el, acm); ClockM cd = acm[acm.Count - 1]; Assert.IsInstanceOfType(cd, typeof(AlarmData)); Assert.AreEqual("abcdefghijklmnopqrstuvwxyz", cd.Tag); Assert.IsTrue(Utils.ColorsAreTheSame( Utils.StringToColor("#0055FF00"), cd.UserBackColor)); Assert.AreEqual(false, cd.ResetToValueLocked); Assert.AreEqual(Utils.ImageToBase64String(cd.Icon), el.GetAttribute("Icon")); Assert.AreEqual("gg", cd.GroupName); Assert.AreEqual(ClockM.ClockStyles.ShowIconAndID, cd.Style); Assert.AreEqual("", mf.MyDataFile.ErrorString); }
public void ClockDataCollectionTest_ChangeTypeOfClock() { // Arrange var f = new MainForm(); var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t1" }; var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t2" }; var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t3" }; // Act f.MyDataFile.ClockMCollection.IsUnsavedLocked = true; f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3); f.MyDataFile.ClockMCollection.AppliedFilter = new FilterM(f.MyDataFile.ClockMCollection, ""); f.MyDataFile.ClockMCollection.IsUnsavedLocked = false; string tag = td2.Tag; bool triggered = false; f.MyDataFile.ClockMCollection.ClockChangedType += delegate(object sender, ClockEventArgs e) { triggered = true; }; ClockM newClock = f.MyDataFile.ClockMCollection. ChangeTypeOfClock(td2, typeof(AlarmData)); Assert.IsTrue(triggered); Assert.AreEqual(f.MyDataFile.ClockMCollection.Ms[1], newClock); Assert.IsInstanceOfType(newClock, typeof(AlarmData)); Assert.AreEqual(tag, newClock.Tag); Assert.IsTrue(f.MyDataFile.ClockMCollection.IsUnsaved); Assert.IsTrue(f.MyDataFile.IsUnsaved); }
public void ClockControlTest_RemoveCustomBackColor() { // Arrange cs_timed_silver.Properties.Settings.Default.AutoOpenLastFile = "No"; var mf = new MainForm(); mf.Show(); Application.DoEvents(); // Act var c = mf.MyDataFile.ClockVMCollection.Model.Ms[0].MyTimerViews[0] as ClockControl; ClockM cd = c.MyClockData; cd.UserBackColor = Color.LightPink; // Assert Assert.IsTrue(Utils.ColorsAreTheSame(c.ActualBackColor, Color.LightPink)); c.RemoveCustomBackColor(); Assert.IsTrue(Utils.ColorsAreTheSame(c.ActualBackColor, c.BaseBackColor)); }
public void TestMethod2() { // Arrange cs_timed_silver.Properties.Settings.Default.AutoOpenLastFile = "No"; var mf = new MainForm(); mf.Show(); Application.DoEvents(); // Act var td = new TimerData(mf.MyDataFile, mf.MultiAudioPlayer) { Tag = "test tag 1" }; mf.MyDataFile.ClockVMCollection.Model.AddClock(td); Application.DoEvents(); mf.MyDataFile.ClockVMCollection.Model.MoveClockFromIndexToIndex(0, 1); // these ClockData-s are taken in the order after the move above ClockM td1 = mf.MyDataFile.ClockVMCollection.Model.Ms[0] as TimerData; ClockM td2 = mf.MyDataFile.ClockVMCollection.Model.Ms[1] as TimerData; td2.Tag = "test tag 2"; Application.DoEvents(); // Assert Assert.AreEqual("test tag 2", td2.Tag); Assert.AreEqual("test tag 1", td1.Tag); }