示例#1
0
        public void TestMonthObserver()
        {
            List <IObserverPull> observers = new List <IObserverPull>();
            PersonRegister       pr        = new PersonRegister();
            IObserverPull        mnthob    = new MonthObserver(pr);

            pr.p.GrowUp();
            pr.p.GrowUp();
            int expectedresult = 24;

            pr.Notify();
            Assert.AreEqual(expectedresult, mnthob.ToForm());
        }
示例#2
0
        /// <summary>
        /// 解析cron表达式
        /// </summary>
        /// <param name="cron">cron表达式字符串</param>
        /// <returns></returns>
        public static CronExpression ResolveCron(string cron)
        {
            CronResolve resolve = new CronResolve(new CronExpression());// cron解析器

            // 注册解析成员
            SecondObserver    secondObserver    = new SecondObserver(resolve);    // 秒
            MinuteObserver    minuteObserver    = new MinuteObserver(resolve);    // 分
            HourObserver      hourObserver      = new HourObserver(resolve);      // 小时
            DayObserver       dayObserver       = new DayObserver(resolve);       // 天
            MonthObserver     monthObserver     = new MonthObserver(resolve);     // 月
            DayOfWeekObserver dayOfWeekObserver = new DayOfWeekObserver(resolve); // 星期
            YearObserver      yearObserver      = new YearObserver(resolve);      // 年

            return(resolve.Resolve(cron));                                        // 解析
        }
示例#3
0
        public void TestMonthObserver()
        {
            PersonRegister pr = new PersonRegister();
            IObserverPush  o  = new MonthObserver(pr);

            pr.p.GrowUp();
            pr.p.GrowUp();
            pr.p.GrowUp();
            List <IObserverPush> observers = new List <IObserverPush>();

            pr.Notify();
            int expectedresult = 36;

            Assert.AreEqual(expectedresult, o.ToForm());
        }