Ejemplo n.º 1
0
        public void NoLines()
        {
            LineCalculator       lc     = new LineCalculator();
            ICollection <string> result = lc.CalculateLines(Array.AsReadOnly(new string[] { }));

            Assert.AreEqual(0, result.Count);
        }
Ejemplo n.º 2
0
        public void CalculateThreeLinesSecondIncomplete()
        {
            LineCalculator lc = new LineCalculator();

            ICollection <string> result = lc.CalculateLines(Array.AsReadOnly(new string[] { "1+1", "2+", "5+5" }));

            Assert.AreEqual(3, result.Count);

            ICollection <string> expected = Array.AsReadOnly(new string[] { "2", "2+", "10" });

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 3
0
        public void CalculateTwoLines()
        {
            LineCalculator lc = new LineCalculator();

            ICollection <string> result = lc.CalculateLines(Array.AsReadOnly(new string[] { "1+1", "2+1" }));

            Assert.AreEqual(2, result.Count);

            ICollection <string> expected = Array.AsReadOnly(new string[] { "2", "3" });

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 4
0
        public void CalculateNoResult()
        {
            LineCalculator lc = new LineCalculator();

            ICollection <string> result =
                lc.CalculateLines(Array.AsReadOnly(new string[] { "" }));

            Assert.AreEqual(1, result.Count);

            ICollection <string> expected = Array.AsReadOnly(new string[] { "" });

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 5
0
        public void CalculateFourLinesLastIncomplete()
        {
            LineCalculator lc = new LineCalculator();

            ICollection <string> result =
                lc.CalculateLines(Array.AsReadOnly(new string[] { "1+1", "2+2", "5+5", "2+2+" }));

            Assert.AreEqual(4, result.Count);

            ICollection <string> expected = Array.AsReadOnly(new string[] { "2", "4", "10", "4+" });

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Введите путь к файлу с кодом:");
            var path = Console.ReadLine();

            var calculator = new LineCalculator(path);
            var result     = calculator.CalculateLines();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"Строк кода: {result.CodeLines}");
            Console.WriteLine($"Строк комментариев: {result.CommentLines}");
            Console.WriteLine($"Пустых строк: {result.EmptyLines}");
            Console.WriteLine($"Смешанных строк: {result.HybridLines}");
        }
        public void CalculateLines_CSharpFile_ShouldReturnCorrectResult()
        {
            Console.WriteLine(Directory.GetCurrentDirectory());
            _calculator = new LineCalculator("../../../TestFiles/CSharp.cs");
            var actual = _calculator.CalculateLines();

            var expected = new CalculationResult
            {
                CodeLines    = 5,
                CommentLines = 5,
                HybridLines  = 3,
                EmptyLines   = 3
            };

            expected.Should().BeEquivalentTo(actual);
        }