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)); }
/// <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); }
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]); } }
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]); } }
public void Construction_InvalidQuantityArguments_WithBothPolicies(double capacity, double level) { Sim.Container(Env, capacity, level, WaitPolicy.Random, WaitPolicy.Random); }
public void Construction_InvalidQuantityArguments(double capacity, double level) { Sim.Container(Env, capacity, level); }
public void Construction_InvalidCapacity(double capacity) { Sim.Container(Env, capacity); }
public void Construction_RightType() { Assert.IsInstanceOf(typeof(Container), Sim.Container(Env)); }