Пример #1
0
 public MyCache(int size)
 {
     _size       = size;
     _dict       = new Dictionary <TKey, MyNode <TKey, TValue> >();
     _queue      = new MyQueue <TKey, TValue>();
     _ignoreTime = DateTime.MinValue;
 }
        public void MyQueue_3_GetFront_1_ThrowsExceptionOnEmptyStack()
        {
            // Arrange
            IMyQueue <string> stack = DSBuilder.CreateMyQueue();

            // Act & Assert
            Assert.Throws(typeof(MyQueueEmptyException), () => stack.GetFront());
        }
        public void MyQueue_4_Dequeue_1_ThrowsExceptionOnEmptyList()
        {
            // Arrange
            IMyQueue <string> stack = DSBuilder.CreateMyQueue();

            // Act & Assert
            Assert.Throws(typeof(MyQueueEmptyException), () => stack.Dequeue());
        }
 public CheckController(IRevisionJob revisionJob, IMyQueue myQueue, ILogger <CheckController> logger,
                        IConfiguration configuration, ICheckPackagesService checkPackagesService)
 {
     _revisionJob          = revisionJob;
     _myQueue              = myQueue;
     _logger               = logger;
     _configuration        = configuration;
     _checkPackagesService = checkPackagesService;
 }
Пример #5
0
 private void OnComplete()
 {
     foreach (var finished in m_finishedList)
     {
         finished.OnCompleteDelegate();
     }
     Queue = null;
     m_finishedList.Clear();
     m_workPool.Deallocate(this);
 }
Пример #6
0
        public IMyQueue GetQueue(IMyQueue queue)
        {
            var result   = from myQueue in _queue where myQueue.QueueType == queue.QueueType select myQueue;
            var myQueues = result as IMyQueue[] ?? result.ToArray();

            if (myQueues.Any())
            {
                return(myQueues.FirstOrDefault());
            }
            return(null);
        }
 private void OnComplete()
 {
     ProfilerShort.Begin("MyPrecalcComponent - Complete");
     foreach (var finished in m_finishedList)
     {
         finished.OnCompleteDelegate();
     }
     Queue = null;
     m_finishedList.Clear();
     m_workPool.Deallocate(this);
     ProfilerShort.End();
 }
        public void MyQueue_1_Constructor_1_IsEmptyReturnsTrue()
        {
            // Arrange
            IMyQueue <string> q = DSBuilder.CreateMyQueue();
            bool expected       = true;

            // Act
            bool actual = q.IsEmpty();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void MyQueue_2_Enqueue_4_DequeueIsOkAfter1Enqueue()
        {
            // Arrange
            IMyQueue <string> stack    = DSBuilder.CreateMyQueue();
            string            expected = "a";

            // Act
            stack.Enqueue("a");
            string actual = stack.Dequeue();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void MyQueue_2_Enqueue_1_IsEmptyReturnsFalse()
        {
            // Arrange
            IMyQueue <string> stack = DSBuilder.CreateMyQueue();
            bool expected           = false;

            // Act
            stack.Enqueue("a");
            bool actual = stack.IsEmpty();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void MyQueue_4_Dequeue_2_IsEmptyReturnsTrueAfterGetFrontOnOneElement()
        {
            // Arrange
            IMyQueue <string> stack = DSBuilder.CreateMyQueue();
            bool expected           = true;

            // Act
            stack.Enqueue("a");
            stack.Dequeue();
            bool actual = stack.IsEmpty();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void MyQueue_3_GetBack_2_IsEmptyReturnsFalseAfterGetBackOnOneElement()
        {
            // Arrange
            IMyQueue <string> stack = DSBuilder.CreateMyQueue();
            bool expected           = false;

            // Act
            stack.Enqueue("a");
            stack.GetBack();
            bool actual = stack.IsEmpty();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void MyQueue_2_Enqueue_3_GetFrontIsOkAfter3Enqueue()
        {
            // Arrange
            IMyQueue <string> stack    = DSBuilder.CreateMyQueue();
            string            expected = "a";

            // Act
            stack.Enqueue("a");
            stack.Enqueue("b");
            stack.Enqueue("c");
            string actual = stack.GetFront();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Пример #14
0
            public void MyQueue_2_Enqueue_6_TwoTimesDequeueIsOkAfter3Enqueue()
            {
                // Arrange
                IMyQueue <string> stack    = DSBuilder.CreateMyArrayQueue();
                string            expected = "b";

                // Act
                stack.Enqueue("a");
                stack.Enqueue("b");
                stack.Enqueue("c");
                stack.Dequeue();
                string actual = stack.Dequeue();

                // Assert
                Assert.AreEqual(expected, actual);
            }
Пример #15
0
    public void ChangeImpl(ref List <T> l)
    {
        l.Clear();
        int size = M.size();

        for (int i = 0; i < size; i++)
        {
            l.Add(M.get());
            M.remove();
        }
        M = new listQueue <T>();
        impl(M);

        for (int i = 0; i < size; i++)
        {
            M.add(l.First <T>());
            l.RemoveAt(0);
        }
    }
Пример #16
0
 static void Test(IMyQueue <int> queue)
 {
     foreach (int i in Enumerable.Range(0, 9))
     {
         queue.Enqueue(i);
     }
     Console.WriteLine(queue.Dequeue());
     Console.WriteLine(queue.Peek());
     foreach (int i in Enumerable.Repeat(2, 5))
     {
         queue.Enqueue(i);
     }
     try
     {
         while (true)
         {
             Console.WriteLine(queue.Dequeue());
         }
     }
     catch (InvalidOperationException)
     {
         Console.WriteLine("Queue is empty");
     }
 }
Пример #17
0
 public void impl(IMyQueue <T> imp)
 {
     this.M = imp;
 }
Пример #18
0
 public MyQueue(ref Queue <T> I)
 {
     q = I;
     M = new QueQueue <T>();
 }
Пример #19
0
 public MyWorker(ILogger <MyWorker> logger, IMyQueue myQueue, IConfiguration configuration)
 {
     _logger        = logger;
     _myQueue       = myQueue;
     _configuration = configuration;
 }