Ejemplo n.º 1
0
        public void SetUp()
        {
            _container = SupportContainer.Reset();

            _service = new SchedulingServiceImpl(
                new TimeSourceServiceImpl(), _container.Resolve <ILockManager>());
            _mgmtService = new SchedulingMgmtServiceImpl();

            // 2-by-2 table of buckets and slots
            var buckets = new ScheduleBucket[3];

            _slots = new long[buckets.Length][];
            for (int i = 0; i < buckets.Length; i++)
            {
                buckets[i] = _mgmtService.AllocateBucket();
                _slots[i]  = new long[2];
                for (int j = 0; j < _slots[i].Length; j++)
                {
                    _slots[i][j] = buckets[i].AllocateSlot();
                }
            }

            _callbacks = new SupportScheduleCallback[5];
            for (int i = 0; i < _callbacks.Length; i++)
            {
                _callbacks[i] = new SupportScheduleCallback();
            }
        }
Ejemplo n.º 2
0
        public void TestCompare()
        {
            long[] slots = new long[10];
            slots[0] = ScheduleBucket.ToLong(1, 1);
            slots[1] = ScheduleBucket.ToLong(1, 2);
            slots[2] = ScheduleBucket.ToLong(2, 1);
            slots[3] = ScheduleBucket.ToLong(2, 2);

            Assert.AreEqual(-1, slots[0].CompareTo(slots[1]));
            Assert.AreEqual(1, slots[1].CompareTo(slots[0]));
            Assert.AreEqual(0, slots[0].CompareTo(slots[0]));

            Assert.AreEqual(-1, slots[0].CompareTo(slots[2]));
            Assert.AreEqual(-1, slots[1].CompareTo(slots[2]));
            Assert.AreEqual(1, slots[2].CompareTo(slots[0]));
            Assert.AreEqual(1, slots[2].CompareTo(slots[1]));
        }