Exemple #1
0
        public void TestOverTimingPoint()
        {
            MockMiscProvider.MockNow = (new DateTime(2004, 3, 5, 7, 12, 2, 0));
            ITiming t = new DayTiming(new TimeOfDayStructure(7, 12, 3));

            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 10));
            Assert.AreEqual(true, t.TimesUp());
        }
 public ActionResult Edit([Bind(Include = "id,Timing,created_at,edited_at")] DayTiming dayTiming)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dayTiming).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dayTiming));
 }
        public ActionResult Create([Bind(Include = "id,Timing,created_at,edited_at")] DayTiming dayTiming)
        {
            if (ModelState.IsValid)
            {
                db.DayTiming.Add(dayTiming);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dayTiming));
        }
Exemple #4
0
        public void TestIt()
        {
            var t1 = new MockTask();
            var t2 = new MockTask();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 0, 0, 0));
            ITiming ti1 = new DayTiming(new TimeOfDayStructure(1, 2, 3));
            ITiming ti2 = new DayTiming(new TimeOfDayStructure(1, 3, 5));
            var     ttc = new TimingTaskCollection(new TimingTask(t1, ti1), new TimingTask(t2, ti2));

            var mt         = new MockTimer();
            var controller = new TimingTaskController(ttc, mt);

            controller.Start();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2, 900));
            mt.RaiseElapsed();
            Assert.AreEqual(0, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 3));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 4));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);


            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 4));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 5));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 7));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);


            Assert.AreEqual(1, t1.Times);
        }
        // GET: DayTimings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DayTiming dayTiming = db.DayTiming.Find(id);

            if (dayTiming == null)
            {
                return(HttpNotFound());
            }
            return(View(dayTiming));
        }
Exemple #6
0
        public void TestIt2()
        {
            MockMiscProvider.MockNow = (new DateTime(2004, 3, 5, 10, 5, 10, 0));
            ITiming t = new DayTiming(new TimeOfDayStructure(7, 12, 3));

            MockMiscProvider.MockNow = (new DateTime(2004, 3, 6, 7, 12, 2));
            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(true, t.TimesUp());

            t.Reset();
            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(false, t.TimesUp());
        }