monthtimingtest.cs

来自「基于LINQ和.NET 3.5 的数据库源码」· CS 代码 · 共 42 行

CS
42
字号
using System;
using Lephone.Util.TimingTask;
using Lephone.Util.TimingTask.Timings;
using NUnit.Framework;

namespace Lephone.UnitTest.util.timingTask
{
	[TestFixture]
	public class MonthTimingTest
	{
		[Test]
		public void TestIt()
		{
			MockNowTimeProvider ntp = new MockNowTimeProvider(new DateTime(2004,1,7,7,10,2,0));
			ITiming t = new MonthTiming(new TimeOfDayStructure(8, 0, 0), 8, ntp);

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

			ntp.SetNow(new DateTime(2004,1,7,8,0,0,0));
			Assert.AreEqual(false, t.TimesUp());

			ntp.SetNow(new DateTime(2004,1,8,7,59,59,0));
			Assert.AreEqual(false, t.TimesUp());

			ntp.SetNow(new DateTime(2004,1,8,8,0,0,0));
			Assert.AreEqual(true, t.TimesUp());

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

			ntp.SetNow(new DateTime(2004,1,8,8,0,0,0));
			Assert.AreEqual(false, t.TimesUp());

			ntp.SetNow(new DateTime(2004,1,9,7,59,59,0));
			Assert.AreEqual(false, t.TimesUp());

			ntp.SetNow(new DateTime(2004,1,9,8,0,0,0));
			Assert.AreEqual(false, t.TimesUp());
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?