Exemple #1
0
        public void Test_Replace_WhenCursorIsNull()
        {
            var list = new TwoWayList <int>();

            list.Replace(1);
            Assert.AreEqual(OperationStatus.ERR, list.ReplaceStatus);
        }
Exemple #2
0
        public void Test_Find_WhenListIsEmpty()
        {
            var list = new TwoWayList <int>();

            list.Find(3);
            Assert.AreEqual(OperationStatus.OK, list.FindStatus);
        }
Exemple #3
0
        public void Test_MoveToHead_WhenListIsEmpty()
        {
            var list = new TwoWayList <int>();

            list.MoveToHead();
            Assert.AreEqual(OperationStatus.ERR, list.MoveToHeadStatus);
        }
Exemple #4
0
    public void ReloadConcepts()
    {
        conceptNames      = new List <string>();
        conceptDictionary = new TwoWayList <int, Fuzzy.Concept>();

        displayFunctions   = new List <bool>();
        functionDictionary = new Dictionary <Fuzzy.Concept, TwoWayList <int, Fuzzy.Function> >();

        //Fills the conceptDictionary container and gather the concept names
        for (int conceptKey = 0; conceptKey < _owner.ConceptList.Count; conceptKey++)
        {
            Fuzzy.Concept concept = _owner.ConceptList[conceptKey];

            displayFunctions.Add(false);
            conceptNames.Add(concept.name);
            conceptDictionary.Add(conceptKey, concept);
            functionDictionary.Add(concept, new TwoWayList <int, Fuzzy.Function>());

            //Fills the function two-way list of the current concept
            for (int j = 0; j < concept.Functions.Count; j++)
            {
                functionDictionary[concept].Add(j, concept.GetFunction(j));
            }
        }
    }
Exemple #5
0
        public void Test_MoveToTail_WhenOneNode()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.MoveToTail();
            Assert.AreEqual(1, list.Value());
        }
Exemple #6
0
        public void Test_PutLeft_WhenEmptyList()
        {
            var list = new TwoWayList <int>();

            list.PutLeft(2);

            Assert.AreEqual(OperationStatus.ERR, list.PutLeftStatus);
        }
Exemple #7
0
        public void Test_Remove_WhenListIsEmpty()
        {
            var list = new TwoWayList <int>();

            list.Remove();

            Assert.AreEqual(OperationStatus.ERR, list.RemoveStatus);
        }
Exemple #8
0
        public void Test_MoveToTail_WhenEmptyList()
        {
            var list = new TwoWayList <int>();

            list.MoveToTail();

            Assert.AreEqual(OperationStatus.ERR, list.MoveToTailStatus);
        }
Exemple #9
0
        public void Test_Constructor()
        {
            var list = new TwoWayList <int>();

            Assert.AreEqual(false, list.IsValue);
            Assert.AreEqual(false, list.IsTail);
            Assert.AreEqual(false, list.IsHead);
        }
Exemple #10
0
        public void TestMethod3()
        {
            double exp = 1.6;

            TwoWayList list = new TwoWayList(new double[] { 0.5, 0, 1.6 });
            double     act  = list.Solve();

            Assert.AreEqual(exp, act);
        }
Exemple #11
0
        public void TestMethod1()
        {
            double exp = 0;

            TwoWayList list = new TwoWayList(new double[] { });
            double     act  = list.Solve();

            Assert.AreEqual(exp, act);
        }
Exemple #12
0
        public void Test_Replace_WhenCursorIsNotNull()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.Replace(2);
            Assert.AreEqual(OperationStatus.OK, list.ReplaceStatus);
            Assert.AreEqual(2, list.Value());
        }
Exemple #13
0
        public void Test_MoveRight_WhenNoNodesRighter()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.MoveRight();

            Assert.AreEqual(OperationStatus.ERR, list.MoveRightStatus);
        }
Exemple #14
0
        public void TestMethod4()
        {
            double exp = 7.6;

            TwoWayList list = new TwoWayList(new double[] { 0.9, 2, 0.1, 4 });
            double     act  = list.Solve();

            Assert.AreEqual(exp, act);
        }
Exemple #15
0
        public void Test_Find_WhenCursorNoElementAfter()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.Find(3);
            Assert.AreEqual(OperationStatus.OK, list.FindStatus);
            Assert.AreEqual(list.Value(), 1);
        }
Exemple #16
0
        public void Test_Remove_WhenOneElement()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.Remove();

            Assert.AreEqual(OperationStatus.OK, list.RemoveStatus);
            Assert.AreEqual(0, list.Size());
            Assert.AreEqual(false, list.IsValue);
        }
Exemple #17
0
        public void Test_RemoveAll_WhenCursorNodeIsRemovedSeveralTimes()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.AddTail(2);
            list.AddTail(3);
            list.RemoveAll(1);
            Assert.AreEqual(2, list.Value());
        }
Exemple #18
0
        public void Test_PutRight_WhenNewNodeInTail()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.PutRight(2);

            Assert.AreEqual(OperationStatus.OK, list.PutRightStatus);
            Assert.AreEqual(1, list.Value());
            Assert.AreEqual(2, list.Size());
        }
Exemple #19
0
        public void Test_Find_WhenValueEqualsCurrent()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.AddTail(2);
            list.AddTail(3);
            list.Find(1);
            Assert.AreEqual(OperationStatus.OK, list.FindStatus);
            Assert.AreEqual(list.Value(), 1);
        }
Exemple #20
0
        public void Test_RemoveAll_WhenCursorNodeIsHeadAndRemoved()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.AddTail(2);
            list.AddTail(3);
            list.RemoveAll(1);
            Assert.AreEqual(2, list.Value());
            Assert.AreEqual(3, list.Size());
        }
Exemple #21
0
        public void Test_MoveRight_WhenSuccess()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.MoveRight();

            Assert.AreEqual(OperationStatus.OK, list.MoveRightStatus);
            Assert.AreEqual(true, list.IsTail);
            Assert.AreEqual(2, list.Value());
        }
Exemple #22
0
        public void Test_Remove_WhenHead()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.Remove();

            Assert.AreEqual(OperationStatus.OK, list.RemoveStatus);
            Assert.AreEqual(1, list.Size());
            Assert.AreEqual(true, list.IsValue);
        }
Exemple #23
0
        public void Test_Remove_WhenInMiddle()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.AddTail(3);
            list.MoveRight();
            list.Remove();

            Assert.AreEqual(OperationStatus.OK, list.RemoveStatus);
            Assert.AreEqual(2, list.Size());
        }
Exemple #24
0
        public void Test_RemoveAll_WhenSeveralNodesAreRemoved()
        {
            var list = new TwoWayList <int>();

            list.AddTail(1);
            list.AddTail(2);
            list.AddTail(3);
            list.AddTail(2);
            list.AddTail(4);
            list.MoveRight();
            list.MoveRight();
            list.RemoveAll(2);

            Assert.AreEqual(3, list.Value());
            Assert.AreEqual(3, list.Size());
        }
Exemple #25
0
        static void Main(string[] args)
        {
            Console.WriteLine("Працюємо зi стеком");
            Console.WriteLine("Операцiї\n1 - додати в стек\n2 - видалити з стеку\n3 - показати стек як массив\n4 - перейти до черги");
            Stack <int> stack = new Stack <int>();
            bool        IsEnd = false;

            while (!IsEnd)
            {
                Console.Write("Введiть номер операцiї => ");
                switch (Convert.ToInt32(Console.ReadLine()))
                {
                case 1:
                    Console.Write("Введiть елемент => ");
                    stack.Push(Convert.ToInt32(Console.ReadLine()));
                    break;

                case 2:
                    Console.WriteLine("Видалили " + stack.Pop());
                    break;

                case 3:
                    ShowArray(stack.ToArray());
                    break;

                case 4:
                    IsEnd = true;
                    break;
                }
            }
            Console.Clear();
            Console.WriteLine("Працюємо iз чергою");
            Console.WriteLine("Операцiї\n1 - додати в чергу\n2 - видалити з черги\n3 - показати чергу як массив\n4 - перейти до списку");
            Queue <int> queue = new Queue <int>();

            IsEnd = false;
            while (!IsEnd)
            {
                Console.Write("Введiть номер операцiї => ");
                switch (Convert.ToInt32(Console.ReadLine()))
                {
                case 1:
                    Console.Write("Введiть елемент => ");
                    queue.Enqueue(Convert.ToInt32(Console.ReadLine()));
                    break;

                case 2:
                    Console.WriteLine("Видалили " + queue.Dequeue());
                    break;

                case 3:
                    ShowArray(queue.ToArray());
                    break;

                case 4:
                    IsEnd = true;
                    break;
                }
            }
            Console.Clear();
            Console.WriteLine("Працюємо iз списком");
            Console.WriteLine("Операцiї\n1 - додати в початок списку\n2 - додати в кiнець списку\n3 - видалити з початку списку\n4 - видалити з кiнця списку\n5 - додати в середину списку\n6 - видалити з середини списку\n7 - показати список як массив\n8 - завершити роботу");
            TwoWayList <int> twList = new TwoWayList <int>();

            IsEnd = false;
            while (!IsEnd)
            {
                Console.Write("Введiть номер операцiї => ");
                switch (Convert.ToInt32(Console.ReadLine()))
                {
                case 1:
                    Console.Write("Введiть елемент => ");
                    twList.AddHead(Convert.ToInt32(Console.ReadLine()));
                    break;

                case 2:
                    Console.Write("Введiть елемент => ");
                    twList.AddEnd(Convert.ToInt32(Console.ReadLine()));
                    break;

                case 3:
                    twList.DelHead();
                    Console.WriteLine("Видалили");
                    break;

                case 4:
                    twList.DelEnd();
                    Console.WriteLine("Видалили");

                    break;

                case 5:
                    Console.Write("Введiть елемент пiсля якого додати => ");
                    int temp = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Введiть елемент => ");
                    twList.AddMid(temp, Convert.ToInt32(Console.ReadLine()));
                    break;

                case 6:
                    Console.Write("Введiть елемент => ");
                    twList.DelMid(Convert.ToInt32(Console.ReadLine()));
                    break;

                case 7:
                    ShowArray(twList.ToArray());
                    break;

                case 8:
                    IsEnd = true;
                    break;
                }
            }
        }