示例#1
0
        public void Can_listen_for_extendedqueue_enqueue_dequeue()
        {
            ExtendedQueue <object> queue = new ExtendedQueue <object>();

            queue.Enqueued += Queue_Enqueued;

            queue.Dequeued += Queue_Dequeued;

            queue.Enqueue(1);

            object result = queue.Dequeue();

            Assert.True((int)result == 1);

            queue.Enqueued -= Queue_Enqueued;

            queue.Dequeued -= Queue_Dequeued;

            queue.Enqueued += Queue_Enqueued_Invalid;

            queue.Dequeued += Queue_Dequeued_Invalid;

            queue.Dequeue();

            queue.Enqueue(null);
        }
        public void UndirectedGraphTraverseBFS()
        {
            ExtendedQueue <Vertex> queue = new ExtendedQueue <Vertex>();

            queue.AddListBox(this.listBox);
            if (Vertex.startPoint == null)
            {
                MessageBox.Show("Válasszon ki egy kezdőpontot");
            }
            else
            {
                if (!queue.Contains(Vertex.startPoint))
                {
                    queue.Enqueue(Vertex.startPoint);
                }
            }

            while (queue.Count > 0)
            {
                Vertex tempNode = queue.Dequeue();
                tempNode.logicalState = Vertex.LogicalState.Visited;
                foreach (Edge edge in tempNode.Edges)
                {
                    Vertex otherVertex;
                    if (tempNode == edge.Start)
                    {
                        otherVertex = edge.End;
                    }
                    else
                    {
                        otherVertex = edge.Start;
                    }

                    if (otherVertex.logicalState != Vertex.LogicalState.Visited && !queue.Contains(otherVertex))
                    {
                        queue.Enqueue(otherVertex);
                    }
                    wait(edge);
                    edge.logicalState = Edge.LogicalState.Visited;
                    wait(edge);
                    otherVertex.logicalState = Vertex.LogicalState.Visited;

                    /*
                     * if(ProceedOnlyOnButtonPress)
                     * {
                     *  waitToButton();
                     *
                     *  waitToButton();
                     *  otherVertex.logicalState = Vertex.LogicalState.Visited;
                     * }
                     * else
                     * {
                     *  edge.logicalState = Edge.LogicalState.Visited;
                     *  wait(edge);
                     *  otherVertex.logicalState = Vertex.LogicalState.Visited;
                     *  wait(edge);
                     * }*/
                }
            }
        }
示例#3
0
 public void Cannot_initiate_typed_extendedqueue_with_negative_capacity()
 {
     var exception = Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         ExtendedQueue <int> queue = new ExtendedQueue <int>(-4);
     });
 }
示例#4
0
 public void Cannot_initiate_typed_extendedqueue_with_null_IEnumerable()
 {
     var exception = Assert.Throws <ArgumentNullException>(() =>
     {
         ExtendedQueue <int> queue = new ExtendedQueue <int>(null);
     });
 }
示例#5
0
        public void Can_initiate_typed_extendedqueue_with_IEnumerable()
        {
            List <int> enumerable = new List <int>();

            enumerable.Add(1);
            enumerable.Add(2);
            enumerable.Add(3);

            ExtendedQueue <int> queue = new ExtendedQueue <int>(enumerable);

            Assert.True(queue != null);
            Assert.True(queue.Peek() == 1);
            Assert.True(queue.Count == 3);
        }
示例#6
0
        public void Can_listen_for_extendedqueue_clear()
        {
            ExtendedQueue <int> queue = new ExtendedQueue <int>();

            queue.Cleared += Queue_Cleared;

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

            Assert.True(queue.Count == 3);

            queue.Clear();

            Assert.True(queue.Count == 0);

            queue.Cleared -= Queue_Cleared;
        }
 public AggregateException Flatten()
 {
     var inner = new List<Exception>();
     var queue = new ExtendedQueue<AggregateException>
     {
         this
     };
     AggregateException current;
     while (queue.TryTake(out current))
     {
         foreach (var exception in current._innerExceptions)
         {
             var aggregatedException = exception as AggregateException;
             if (aggregatedException != null)
             {
                 queue.Add(aggregatedException);
             }
             else
             {
                 inner.Add(exception);
             }
         }
     }
     return new AggregateException(inner);
 }
示例#8
0
        public void Can_initiate_typed_extendedqueue_with_capacity()
        {
            ExtendedQueue <int> queue = new ExtendedQueue <int>(14);

            Assert.True(queue != null);
        }
示例#9
0
        public void Can_initiate_typed_extendedqueue()
        {
            ExtendedQueue <int> queue = new ExtendedQueue <int>();

            Assert.True(queue != null);
        }