當前位置: 首頁>>代碼示例>>C#>>正文


C# Environment.RunD方法代碼示例

本文整理匯總了C#中System.Environment.RunD方法的典型用法代碼示例。如果您正苦於以下問題:C# Environment.RunD方法的具體用法?C# Environment.RunD怎麽用?C# Environment.RunD使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Environment的用法示例。


在下文中一共展示了Environment.RunD方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestAndConditionBlocked

 public void TestAndConditionBlocked()
 {
     var env = new Environment();
       env.Process(TestAndConditionBlockedProcess(env));
       env.RunD(5);
       Assert.AreEqual(5, env.NowD);
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:7,代碼來源:ConditionTest.cs

示例2: TestEventQueueEmptyDApi

 public void TestEventQueueEmptyDApi()
 {
     /*The simulation should stop if there are no more events, that means, no
     more active process.*/
       var log = new List<string>();
       var env = new Environment(defaultStep: TimeSpan.FromMinutes(1));
       env.Process(AProcess(env, log));
       env.RunD(10);
       Assert.IsTrue(log.SequenceEqual(new[] { "00", "01" }));
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:10,代碼來源:EnvironmentDApiTests.cs

示例3: TestRunNegativeUntilDApi

 public void TestRunNegativeUntilDApi()
 {
     /*Test passing a negative time to run.*/
       var env = new Environment(defaultStep: TimeSpan.FromMinutes(1));
       var errorThrown = false;
       try {
     env.RunD(-1);
       } catch (InvalidOperationException) {
     errorThrown = true;
       }
       Assert.IsTrue(errorThrown);
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:12,代碼來源:EnvironmentDApiTests.cs

示例4: TestRunResumeDApi

        public void TestRunResumeDApi()
        {
            /* Stopped simulation can be resumed. */
              var env = new Environment(defaultStep: TimeSpan.FromMinutes(1));
              var events = new List<Event>() {
            env.TimeoutD(5),
            env.TimeoutD(10),
            env.TimeoutD(15),
            env.TimeoutD(20)
              };

              Assert.AreEqual(env.NowD, 0);
              Assert.AreEqual(env.PeekD(), 5);
              Assert.IsFalse(events.Any(x => x.IsProcessed));

              env.RunD(10);
              Assert.AreEqual(env.NowD, 10);
              Assert.AreEqual(env.PeekD(), 10);
              Assert.IsTrue(events[0].IsProcessed);
              Assert.IsFalse(events[1].IsProcessed);
              Assert.IsFalse(events[2].IsProcessed);

              env.RunD(5);
              Assert.AreEqual(env.NowD, 15);
              Assert.AreEqual(env.PeekD(), 15);
              Assert.IsTrue(events[0].IsProcessed);
              Assert.IsTrue(events[1].IsProcessed);
              Assert.IsFalse(events[2].IsProcessed);

              env.RunD(1);
              Assert.AreEqual(env.NowD, 16);
              Assert.AreEqual(env.PeekD(), 20);
              Assert.IsTrue(events[0].IsProcessed);
              Assert.IsTrue(events[1].IsProcessed);
              Assert.IsTrue(events[2].IsProcessed);

              env.RunD();
              Assert.AreEqual(env.NowD, 20);
              Assert.AreEqual(env.PeekD(), double.MaxValue);
        }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:40,代碼來源:EnvironmentDApiTests.cs

示例5: TestContinuousStatisticsSimple

 public void TestContinuousStatisticsSimple()
 {
     var env = new Environment();
       var times = new double[] { 0, 1, 1, 1, 1, 1 };
       var values = new double[] { 6, 2, 3, 5, -1, -4 };
       var stat = new ContinuousStatistics(env);
       foreach (var v in times.Zip(values, Tuple.Create)) {
     if (v.Item1 > 0) env.RunD(v.Item1);
     stat.Update(v.Item2);
       }
       Assert.AreEqual(-4, stat.Min);
       Assert.AreEqual(6, stat.Max);
       Assert.AreEqual(3, stat.Mean, 1e-12);
       Assert.AreEqual(6, stat.Variance, 1e-12);
       Assert.AreEqual(15, stat.Area);
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:16,代碼來源:ContinuousStatisticsTest.cs

示例6: TestContinuousStatisticsComplex2

 public void TestContinuousStatisticsComplex2()
 {
     var env = new Environment();
       var times = new double[] { 1, 1, 1, 2, 0, 0, 4, 7, 4 };
       var values = new double[] { 3, -2, 5, 6, -4, 1, 0, -2, 3 };
       var stat = new ContinuousStatistics(env);
       foreach (var v in times.Zip(values, Tuple.Create)) {
     if (v.Item1 > 0) env.RunD(v.Item1);
     stat.Update(v.Item2);
       }
       Assert.AreEqual(-4, stat.Min);
       Assert.AreEqual(6, stat.Max);
       Assert.AreEqual(0.3684210526315789, stat.Mean, 1e-12);
       Assert.AreEqual(4.232686980609418, stat.Variance, 1e-12);
       Assert.AreEqual(7, stat.Area);
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:16,代碼來源:ContinuousStatisticsTest.cs

示例7: TestRunUntilValueDApi

 public void TestRunUntilValueDApi()
 {
     /* Anything that can be converted to a float is a valid until value. */
       var env = new Environment(defaultStep: TimeSpan.FromMinutes(1));
       env.RunD(100);
       Assert.AreEqual(env.NowD, 100);
 }
開發者ID:hsz-develop,項目名稱:abeham--SimSharp,代碼行數:7,代碼來源:EnvironmentDApiTests.cs


注:本文中的System.Environment.RunD方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。