static void Main(string[] args)
    {
        var s = new LongestSequence();

        Console.WriteLine("Start day of longest sequence: " + s.GetStartDay() + " and end day of longest sequence: " + s.GetEndDay());
        Console.Read();
    }
        public void ExpectToReturnCorrectResultsWithNegativeNumbers()
        {
            this.testNumbers = new List <int> {
                -5, -0, -3, -4, 0, 0, -4, -4, -4
            };
            var result         = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);
            var resultAsString = string.Join(", ", result);

            Assert.AreEqual("-4, -4, -4", resultAsString);
        }
        public void ExpectToReturnFirstNumberWhenNoHaveLongestSequence()
        {
            this.testNumbers = new List <int> {
                1, 4, 5, 8, 1, 4, 5
            };
            var    result         = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);
            string resultAsString = string.Join(", ", result);

            Assert.AreEqual("1", resultAsString);
        }
        public void ExpectToReturnFirstLongestSequenceWhenExistMoreThenOne()
        {
            this.testNumbers = new List <int> {
                9, 9, 9, 1, 1, 1, 8, 8, 8, 7, 8, 2, 2, 2
            };
            var    result         = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);
            string resultAsString = string.Join(", ", result);

            Assert.AreEqual("9, 9, 9", resultAsString);
        }
        public void ExpectWhenlongestSequenceIsInTheMiddleToReturnCorrectResult()
        {
            this.testNumbers = new List <int> {
                9, 9, 1, 1, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9
            };
            var    result         = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);
            string resultAsString = string.Join(", ", result);

            Assert.AreEqual("8, 8, 8, 8, 8, 8, 8", resultAsString);
        }
        public void ExpectWhenlongestSequenceIsInTheBeginingToReturnCorrectResult()
        {
            this.testNumbers = new List <int> {
                1, 1, 1, 1, 3, 3, 5, 6, 7, 9, 9, 9
            };
            var    result         = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);
            string resultAsString = string.Join(", ", result);

            Assert.AreEqual("1, 1, 1, 1", resultAsString);
        }
Exemple #7
0
 // END CUT HERE
 // BEGIN CUT HERE
 public static void Main()
 {
     LongestSequence ___test = new LongestSequence();
     ___test.run_test(-1);
     try {
     } catch(Exception e) {
     //Console.WriteLine(e.StackTrace);
     Console.WriteLine(e.ToString());
     }
 }
Exemple #8
0
// END CUT HERE
// BEGIN CUT HERE
    public static void Main()
    {
        LongestSequence ___test = new LongestSequence();

        ___test.run_test(-1);
        try {
        } catch (Exception e) {
//Console.WriteLine(e.StackTrace);
            Console.WriteLine(e.ToString());
        }
    }
        public void ExpectToReturnWholeListWhenAllNumbersAreEqual()
        {
            this.testNumbers = new List <int> {
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            };
            var result = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);

            Assert.AreEqual(this.testNumbers.Count, result.Count);
            bool areAllEqual = result.All(num => num == this.testNumbers[0]);

            Assert.IsTrue(areAllEqual);
        }
        public void ExpectToReturnCorrectResultsWhenOnlyZerosAreProvided()
        {
            this.testNumbers = new List <int> {
                0, 0, 0, 0, 0, -0, -0, -0, +0, +0, 0, -0, +0, 0 * 0,
            };
            var result = LongestSequence.FindLongestSequnceOfEqualNumbers(this.testNumbers);

            Assert.AreEqual(this.testNumbers.Count, result.Count);
            bool areAllEqual = result.All(num => num == 0);

            Assert.IsTrue(areAllEqual);
        }
Exemple #11
0
    static void Main()
    {
        List <string> inputs = new List <string>()
        {
            "12 2 7 4 3 3 8",
            "2 2 2 3 3 3",
            "4 4 5 5 5",
            "1 2 3",
            "0"
        };

        List <string> results = new List <string>()
        {
            "3, 3",
            "2, 2, 2",
            "5, 5, 5",
            "1",
            "0"
        };

        bool worksCorrect = true;

        for (int i = 0; i < inputs.Count; i++)
        {
            var currResult = string.Join(", ", LongestSequence.getLongestSubsequence(inputs[i]));
            if (currResult != results[i])
            {
                worksCorrect = false;
            }
        }

        if (worksCorrect)
        {
            Console.WriteLine("The program works correct !");
        }
        else
        {
            Console.WriteLine("Not all test passed...");
        }
    }