コード例 #1
0
ファイル: ProcessTests.cs プロジェクト: stuarthillary/Dessert
        IEvents Interrupted_YieldingGetToken()
        {
            Container.GetEvent getEv;
            Env.Process(Interrupter(Env.ActiveProcess, 5));
            yield return(getEv = Sim.Container(Env, 20, 10).Get(20));

            Assert.AreEqual(5, Env.Now);
            Assert.False(getEv.Disposed);
            Assert.True(Env.ActiveProcess.Interrupted());
            yield return(Env.Timeout(7));
        }
コード例 #2
0
ファイル: GasStation.cs プロジェクト: stuarthillary/Dessert
        /// <summary>
        ///   Sets up and starts the simulation.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("Gas Station refueling");

            // Creates the environment and starts processes.
            var env        = Sim.Environment(RandomSeed);
            var gasStation = Sim.Resource(env, 2);
            var fuelPump   = Sim.Container(env, GasStationSize, level: GasStationSize);

            env.Process(GasStationControl(env, fuelPump));
            env.Process(CarGenerator(env, gasStation, fuelPump));

            // Run!
            env.Run(until: SimTime);
        }
コード例 #3
0
        public void GetPolicy_Lifo(int eventCount)
        {
            const int quantity  = 10;
            var       container = Sim.Container(Env, quantity * eventCount, 0, WaitPolicy.LIFO, WaitPolicy.FIFO);
            var       list      = new List <int>();

            for (var i = 0; i < eventCount; ++i)
            {
                var tmpI = i;
                container.Get(quantity).Callbacks.Add(e => list.Add(tmpI));
            }
            container.Put(quantity * eventCount);
            Env.Run();
            Assert.AreEqual(eventCount, list.Count);
            for (var i = 0; i < eventCount; ++i)
            {
                Assert.AreEqual(i, list[eventCount - i - 1]);
            }
        }
コード例 #4
0
        public void PutPolicy_Priority_Increasing(int eventCount)
        {
            const int quantity  = 10;
            var       container = Sim.Container(Env, quantity * eventCount, quantity * eventCount, WaitPolicy.FIFO,
                                                WaitPolicy.Priority);
            var list = new List <int>();

            for (var i = 0; i < eventCount; ++i)
            {
                var tmpI = i;
                container.Put(quantity, i).Callbacks.Add(e => list.Add(tmpI));
            }
            container.Get(quantity * eventCount);
            Env.Run();
            Assert.AreEqual(eventCount, list.Count);
            for (var i = 0; i < eventCount; ++i)
            {
                Assert.AreEqual(i, list[i]);
            }
        }
コード例 #5
0
 public void Construction_InvalidQuantityArguments_WithBothPolicies(double capacity, double level)
 {
     Sim.Container(Env, capacity, level, WaitPolicy.Random, WaitPolicy.Random);
 }
コード例 #6
0
 public void Construction_InvalidQuantityArguments(double capacity, double level)
 {
     Sim.Container(Env, capacity, level);
 }
コード例 #7
0
 public void Construction_InvalidCapacity(double capacity)
 {
     Sim.Container(Env, capacity);
 }
コード例 #8
0
 public void Construction_RightType()
 {
     Assert.IsInstanceOf(typeof(Container), Sim.Container(Env));
 }