Beispiel #1
0
        public async Task Refresh_Works_NoEvent(FFXIVRole role)
        {
            var queue        = new TestQueue();
            var enqueuedSlot = new QueueSlot(UserId, "", new List <ulong>())
            {
                QueueTime = DateTime.UtcNow.AddHours(-4).AddMinutes(-45),
            };

            queue.AddSlot(enqueuedSlot, role);
            await Task.Delay(1000);

            var now = DateTime.UtcNow;

            queue.Refresh(UserId);
            var dequeuedSlot = queue.GetAllSlots().First();

            Assert.AreEqual(now.Hour, dequeuedSlot.QueueTime.Hour);
            Assert.AreEqual(now.Minute, dequeuedSlot.QueueTime.Minute);
        }
Beispiel #2
0
        public void QueryTimeout_NoIncludeEvents_Works()
        {
            var rand   = new Random(1234);
            var queue  = new TestQueue();
            var counts = new Dictionary <FFXIVRole, int>
            {
                { FFXIVRole.DPS, 0 },
                { FFXIVRole.Healer, 0 },
                { FFXIVRole.Tank, 0 },
            };

            for (ulong i = 0; i < 1000; i++)
            {
                var nextRole = rand.Next(0, 3) switch
                {
                    0 => FFXIVRole.DPS,
                    1 => FFXIVRole.Healer,
                    2 => FFXIVRole.Tank,
                    _ => throw new NotImplementedException(),
                };
                counts[nextRole]++;
                queue.AddSlot(new QueueSlot(i, EventId)
                {
                    QueueTime = DateTime.UtcNow.AddHours(-5),
                }, nextRole);
            }

            var roles    = new[] { FFXIVRole.DPS, FFXIVRole.Healer, FFXIVRole.Tank };
            var timeouts = new Dictionary <FFXIVRole, IEnumerable <ulong> >();

            foreach (var role in roles)
            {
                timeouts[role] = queue.TryQueryTimeout(role, 4 * Time.Hour);
            }
            Assert.That(timeouts[FFXIVRole.DPS].Concat(timeouts[FFXIVRole.Healer]).Concat(timeouts[FFXIVRole.Tank]).Count() == 1000);
            Assert.That(!queue.GetAllSlots().Any());
        }