public override License GetLicense(
            LicenseContext context, Type type,
            object instance, bool allowExceptions)
        {
            if (DateTime.Today < new DateTime(2020, 5, 31))
            {
                return(new DRTLicense());
            }
            // Do some logic to go figure out if this type or instance
            // is licensed. This can be implemented however you want.
            bool licenseIsValid = true;

            string lkeyenc   = GetLicenseKey(type, instance);
            var    key_bytes = LimitQueue.SimpleDecrypt(
                LimitQueue.GetBytes(lkeyenc),
                LimitQueue.GetBytes(ekey),
                LimitQueue.GetBytes(akey));
            string lkey = LimitQueue.GetString(key_bytes);

            licenseIsValid = IsLicenseValid(lkey);
            // If license check isn’t successful:
            if (!licenseIsValid)
            {
                throw new LicenseException(type, instance, "Invalid license.");
            }
            else
            {
                return(new DRTLicense());
            }
        }
Beispiel #2
0
        public void AddingItemToFullQueueKeepsSameSize()
        {
            // Arrange
            var queue = new LimitQueue(limit: limit);

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);

            // Act
            queue.Enqueue(4);

            // Assert
            Assert.AreEqual(queue.Count, limit);
        }
Beispiel #3
0
        public void AddingItemToFullQueueGetsRidOfItemFromFrontOfQueue()
        {
            // Arrange
            var toBeDropped = 1;
            var toBeFront   = 2;
            var queue       = new LimitQueue(limit: limit);

            queue.Enqueue(toBeDropped);
            queue.Enqueue(toBeFront);
            queue.Enqueue(3);

            // Act
            queue.Enqueue(4);
            var front = (int)queue.Dequeue();

            // Assert
            Assert.AreEqual(front, toBeFront);
            Assert.AreNotEqual(front, toBeDropped);
            Assert.AreEqual(queue.Count, limit - 1);
        }