当前位置: 首页>>代码示例>>C#>>正文


C# Time.Execute方法代码示例

本文整理汇总了C#中Time.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Time.Execute方法的具体用法?C# Time.Execute怎么用?C# Time.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Time的用法示例。


在下文中一共展示了Time.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FormattedTime

        public void FormattedTime()
        {
            Time task = new Time();
            task.BuildEngine = new MockBuild();

            // test without the optional Format property
            Assert.IsNull(task.Format, @"Format not null");
            Assert.IsNull(task.FormattedTime, @"Formatted time not null");
            Assert.IsTrue(task.Execute(), @"Time task without Format failed");
            Assert.IsNull(task.Format, @"Format not null after executing task");
            DateTime time = task.DateTimeValue;
            Assert.IsNotNull(task.FormattedTime, @"Formatted time null after executing task");
            task.Log.LogMessage(MessageImportance.Low, "Time without format: \"{0}\" (local)", task.FormattedTime);
            Assert.AreEqual(time.ToString(DateTimeFormatInfo.InvariantInfo), task.FormattedTime,
                @"Wrong default local time");

            // the .Now property has a limited resolution
            // according to ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref2/html/P_System_DateTime_Now.htm
            // therefore wait some time to ensure we get a different value
            // when executing a second time
            Thread.Sleep(1000);

            // second execute must yield another time stamp
            Assert.IsTrue(task.Execute(), @"Time task without Format failed in second execution");
            task.Log.LogMessage(MessageImportance.Low, "Time without format: \"{0}\" (local)", task.FormattedTime);
            Assert.AreNotEqual(time, task.DateTimeValue, @"Time doesn't change with second execution");

            // specify the format
            task.Format = @"yyyyMMddHHmmss";
            task.Kind = System.DateTimeKind.Utc.ToString();
            Assert.IsTrue(task.Execute(), @"Time task with Format failed");
            task.Log.LogMessage(MessageImportance.Low, "Time with format: \"{0}\" (UTC)", task.FormattedTime);
            Assert.AreEqual(task.Format.Length, task.FormattedTime.Length, @"Wrong time length");
        }
开发者ID:jacderida,项目名称:JobSystem,代码行数:34,代码来源:TimeTest.cs

示例2: TimeExecute

 public void TimeExecute()
 {
     Time task = new Time();
     task.BuildEngine = new MockBuild();
     Assert.IsTrue(task.Execute(), "Execute Failed!");
 }
开发者ID:jacderida,项目名称:JobSystem,代码行数:6,代码来源:TimeTest.cs


注:本文中的Time.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。