public void TestScheduleViewWithInit() { Schedule sched = new Schedule() { name = "TestSchedule", description = "Schedule for testing", localtime = "PT11:55:00", command = new Command { method = "PUT", address = @"/lights/1/state", body = new Body { bri = 254, sat = 254, hue = 0, } }, Id = "2" }; ScheduleView sl = new ScheduleView(sched, "thisisanapikeyfortest"); Assert.AreEqual(sched, sl.GetSchedule(), "Test Schedule Inititalisation"); Assert.IsNull(sl.Autodelete, "Test Autodelete get null"); sl.Autodelete = true; Assert.IsTrue((bool)sl.Autodelete, "Test Autodelete true"); sl.Autodelete = false; Assert.IsFalse((bool)sl.Autodelete, "Test Autodelete false"); Assert.IsTrue(sl.On, "Test On null True"); sl.On = false; Assert.IsFalse(sl.On, "Test On False"); Schedule sched2 = new Schedule() { name = "TestSchedule", description = "Schedule for testing", localtime = "W127/T11:55:00", command = new Command { method = "PUT", address = @"/lights/1/state", body = new Body { bri = 254, sat = 254, hue = 0, } }, Id = "2" }; ScheduleView sl2 = new ScheduleView(sched2, "thisisanapikeyfortest"); Assert.AreEqual("Mon,Tue,Wed,Thu,Fri,Sat,Sun", sl2.ScheduleMask); sl2.ScheduleMask = "Mon,Tue,Wed"; Assert.AreEqual("Mon,Tue,Wed", sl2.ScheduleMask); Assert.AreEqual(Visibility.Visible, sl2.IsAlarm, "Test Is Alarm get"); }
public void TestScheduleViewModel() { ScheduleView sl = new ScheduleView(new Light() { Id = "2" }, "thisisanapikeyfortest"); sl.Bri = 254; Assert.AreEqual(254, (int)sl.Bri, "Test Brightness set/get"); sl.Ct = 420; Assert.IsTrue(sl.Ct == 420 && sl.Hue == -1, "Test CT set/get and Hue set null"); sl.Hue = 23456D; Assert.IsTrue(sl.Hue == 23456D && sl.Ct == -1, "Test Hue set/get and CT set null"); sl.Sat = 243; Assert.AreEqual(243, (int)sl.Sat, "Test Sat set/get"); sl.Name = "Test"; Assert.AreEqual("Test", sl.Name, "Test Name set/get"); // sl.ScheduleMask = ""; // Assert.AreEqual("001", sl.ScheduleMask, "Test Schedule Mask get/set"); sl.Description = "Description Test"; Assert.AreEqual("Description Test", sl.Description, "Test Description get/set"); sl.Localtime = new DateTime(2015, 12, 31, 12, 34, 21); Assert.AreEqual(new DateTime(2015, 12, 31, 12, 34, 21), sl.Localtime, "Test Localtime set/get"); sl.Type = 1; DateTime dt = new DateTime(2015, 12, 31, 12, 34, 21); Assert.IsTrue(dt.Hour == sl.Localtime.Hour && dt.Minute == sl.Localtime.Minute && dt.Second == sl.Localtime.Second, "Test Change Type set/get"); sl.Type = 2; Assert.IsTrue(dt.Hour == sl.Localtime.Hour && dt.Minute == sl.Localtime.Minute && dt.Second == sl.Localtime.Second, "Test Change Type set/get"); sl.X = 0.234M; Assert.AreEqual(0.234M, sl.X, "Test set/get X"); sl.Y = 0.345M; Assert.AreEqual(0.345M, sl.Y, "Test set/get Y"); sl.X = -0.001M; Assert.AreEqual(-0.001M, sl.X, "Test set null"); Assert.AreEqual(-0.001M, sl.Y, "Test get null"); sl.X = 0.234M; sl.Y = 0.345M; sl.Y = -0.001M; Assert.AreEqual(-0.001M, sl.X, "Test set null"); Assert.AreEqual(-0.001M, sl.Y, "Test get null"); sl.X = 0.234M; Assert.AreEqual(0, sl.Y, "Test set X get Y = 0"); sl.X = -0.001M; sl.Y = 0.345M; Assert.AreEqual(0, sl.X, "Test set Y get X = 0"); sl.Randomize = true; Assert.IsTrue(sl.GetSchedule().localtime.Contains("A"), "Test randomize true"); sl.Randomize = false; Assert.IsFalse(sl.GetSchedule().localtime.Contains("A"), "Test randomize false"); sl.Transitiontime = 123D; Assert.AreEqual(123D, sl.Transitiontime, "Test transition time set/get"); sl.Transitiontime = -1D; Assert.AreEqual(-1D, sl.Transitiontime, "Test transition time null set/get"); ScheduleView sv = new ScheduleView(new Light() { Id = "1" }, "thisisanapikeyfortest"); Schedule ns = sv.GetSchedule(); // sl.Localtime = "2012-12-31 11:34:22"; // Assert.AreEqual("2012-12-31T11:34:22", sl.Localtime, "Test Localtime set/get"); // sl.Type = "W"; // Assert.AreEqual(sl.Localtime,$@"W{sl.Type}/T11:34:22"); }