Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventQueue"/> class.
        /// </summary>
        public EventQueue(
            IDataGatherer dataGatherer,
            IRandomCallGenerator generator,
            uint numberOfStations,
            uint highwayLength,
            uint channelsPerStation,
            uint reservedChannelsPerStation)
        {
            if (dataGatherer == null)
            {
                throw new ArgumentNullException("dataGatherer");
            }
            if (generator == null)
            {
                throw new ArgumentNullException("generator");
            }

            _dataGatherer = dataGatherer;
            _generator    = generator;
            _stations     = new StationList(
                numberOfStations,
                highwayLength,
                channelsPerStation,
                reservedChannelsPerStation);
            _innerQueue           = new SortedList <uint, IEvent>();
            _stationRangeDiameter = highwayLength / numberOfStations;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventQueueFactory"/> class.
 /// </summary>
 /// <param name="generator">The generator.</param>
 /// <param name="stationCount">The station count.</param>
 /// <param name="highwayLength">Length of the highway.</param>
 /// <param name="channels">The channels.</param>
 /// <param name="reservedChannels">The reserved channels.</param>
 public EventQueueFactory(
     IRandomCallGenerator generator,
     uint stationCount,
     uint highwayLength,
     uint channels,
     uint reservedChannels)
 {
     _generator        = generator;
     _stationCount     = stationCount;
     _highwayLength    = highwayLength;
     _channels         = channels;
     _reservedChannels = reservedChannels;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventQueue"/> class.
        /// </summary>
        public EventQueue(
			IDataGatherer dataGatherer,
			IRandomCallGenerator generator,
			uint numberOfStations,
			uint highwayLength,
			uint channelsPerStation,
			uint reservedChannelsPerStation )
        {
            if( dataGatherer == null )
                throw new ArgumentNullException( "dataGatherer" );
            if( generator == null )
                throw new ArgumentNullException( "generator" );

            _dataGatherer = dataGatherer;
            _generator = generator;
            _stations = new StationList(
                numberOfStations,
                highwayLength,
                channelsPerStation,
                reservedChannelsPerStation );
            _innerQueue = new SortedList<uint, IEvent>();
            _stationRangeDiameter = highwayLength / numberOfStations;
        }
Ejemplo n.º 4
0
        public void RandomFactoryCreatesSameSequencOfGeneratorsForSameSeed()
        {
            int seed = 42;

            var f0 = new RandomFactory(seed, 10, 2, 1, 10, 1, 1, 1);
            IRandomCallGenerator r01 = f0.Create();
            IRandomCallGenerator r02 = f0.Create();

            var f1 = new RandomFactory(seed, 10, 2, 1, 10, 1, 1, 1);
            IRandomCallGenerator r11 = f1.Create();
            IRandomCallGenerator r12 = f1.Create();

            Assert.AreEqual(r11.GenerateRandomCall(0), r01.GenerateRandomCall(0));
            Assert.AreEqual(r11.GenerateRandomCall(50), r01.GenerateRandomCall(50));
            Assert.AreNotEqual(r11.GenerateRandomCall(1120), r01.GenerateRandomCall(2203));
            Assert.AreEqual(r11.GenerateRandomCall(55), r01.GenerateRandomCall(55));

            Assert.AreEqual(r02.GenerateRandomCall(0), r12.GenerateRandomCall(0));
            Assert.AreEqual(r02.GenerateRandomCall(10), r12.GenerateRandomCall(10));
            Assert.AreEqual(r02.GenerateRandomCall(0), r12.GenerateRandomCall(0));
            Assert.AreEqual(r02.GenerateRandomCall(10), r12.GenerateRandomCall(10));

            Assert.AreNotEqual(r11.GenerateRandomCall(0), r12.GenerateRandomCall(0));
        }