public void SetsTheObjectAsExpected()
        {
            var worker    = Mock.Of <Worker>();
            var timestamp = DateTime.Now;

            var target = new WorkerCacheEntry(worker, timestamp);

            Assert.AreEqual(worker, target.Worker);
            Assert.AreEqual(timestamp, target.LastIssued);
        }
        public void ModifiesTheLastIssuedDateAsExpected()
        {
            var worker   = Mock.Of <Worker>();
            var original = DateTime.Now;

            var target = new WorkerCacheEntry(worker, original);

            Thread.Sleep(100);
            target.MarkAsIssued();

            Assert.True(target.LastIssued > original);
        }
Пример #3
0
        /// <summary>
        /// Creates a new entry.
        /// </summary>
        /// <returns>The new entry instance, which includes a worker.</returns>
        protected virtual Worker CreateWorker()
        {
            Worker worker = null;

            try
            {
                worker = new Worker();

                busy[worker] = new WorkerCacheEntry(worker, DateTime.Now);

                return(worker);
            }
            catch (Exception)
            {
                worker?.Dispose();
                throw;
            }
        }