public void NoLines() { LineCalculator lc = new LineCalculator(); ICollection <string> result = lc.CalculateLines(Array.AsReadOnly(new string[] { })); Assert.AreEqual(0, result.Count); }
public LineFigure() { points = new List <Point>(); painter = new PolygonPainter(); calculator = new LineCalculator(); mover = new PolygonMover(); checker = new PolygonChecker(); }
public LineFigure(Color color, int width) { points = new List <Point>(); this.pen = new Pen(color, width); painter = new PolygonPainter(); calculator = new LineCalculator(); mover = new PolygonMover(); checker = new PolygonChecker(); }
public LineFigure(Pen pen) { points = new List <Point>(); this.pen = pen; painter = new PolygonPainter(); calculator = new LineCalculator(); mover = new PolygonMover(); checker = new PolygonChecker(); }
public void CalculateSubTotal_Test01() { var mockedCalculable = new Mock <ILineCalculable>(); mockedCalculable.Setup(x => x.Price).Returns(9.99m); mockedCalculable.Setup(x => x.Quantity).Returns(5); var result = LineCalculator.SubTotal(mockedCalculable.Object); Assert.That(result == 49.95m); }
public void Should_Return_List_Of_Points() { var directions = "R8,U5,L5,D3"; var expected = new List <(int, int)>() { (0, 0), (8, 0), (8, 5), (3, 5), (3, 2) }; var result = LineCalculator.GetPointsFromString(directions); Assert.Equal(expected, result); }
public void CalculateTotal_Test02() { var mockedCalculable = new Mock <ILineCalculable>(); mockedCalculable.Setup(x => x.Price).Returns(9.99m); mockedCalculable.Setup(x => x.Quantity).Returns(20); mockedCalculable.Setup(x => x.TaxRate).Returns(0.99m); var result = LineCalculator.Total(mockedCalculable.Object); Assert.That(result == 397.602m); }
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); }
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); }
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); }
public void CalculateLines(int[] line) { currentDices = line; LineCalculator.StartCalculating(sheetLines, currentDices); // send the used sheet and the numbers to be calculated. the results are passed on to SingleLines of the sheetlines clickBlocker.SetActive(false); //lines can be clicked if (!GameManager.instance.roundEnded && DiceParent.instance.throwsUsed != GameManager.instance.throwsPerRound) { //let player throw again once the dices have stopped moving, except when all throws have been used(round ended p much) //DiceParent.instance.ThrowButton.interactable = true; DiceParent.instance.throwBut.enabled = true; DiceParent.instance.throwButtonAnimator.Play("ColorEnabled"); } }
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); }
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); }
public void Should_Return_Occupied_Points_Multiple_Positions() { var points = new List <(int, int)>() { (0, 0), (3, 0), (3, 2), }; var expected = new List <(int, int)>() { (0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (3, 2) }; var result = LineCalculator.GetOccupiedBetweenPoints(points); Assert.Equal(expected, result); }
public void Should_Return_Occupied_Points() { int fromX = 0; int fromY = 0; int toX = 5; int toY = 0; var expected = new List <(int, int)> { (0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0) }; List <(int, int)> result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY); Assert.Equal(expected, result); fromX = 0; fromY = 0; toX = 0; toY = 5; expected = new List <(int, int)> { (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5) }; result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY); Assert.Equal(expected, result); fromX = 2; fromY = 0; toX = -2; toY = 0; expected = new List <(int, int)> { (-2, 0), (-1, 0), (0, 0), (1, 0), (2, 0) }; result = LineCalculator.GetOccupiedBetweenPoints(fromX, fromY, toX, toY); Assert.Equal(expected, result); }
public void Should_Get_Score_For_Corrupt_Lines() { var lines = new string[] { "[({(<(())[]>[[{[]{<()<>>", "[(()[<>])]({[<{<<[]>>(", "{([(<{}[<>[]}>{[]{[(<()>", "(((({<>}<{<{<>}{[]{[]{}", "[[<[([]))<([[{}[[()]]]", "[{[{({}]{}}([{[{{{}}([]", "{<[[]]>}<{[{[{[]{()[[[]", "[<(<(<(<{}))><([]([]()", "<{([([[(<>()){}]>(<<{{", "<{([{{}}[<[[[<>{}]]]>[]]" }; var result = LineCalculator.CalculateScoreForCorrupt(lines); Assert.Equal(26397, result); }
public void Should_Return_Closest_Intersection(string directionsOne, string directionsTwo, int expected) { var result = LineCalculator.GetClosestIntersectionManhattan(directionsOne, directionsTwo); Assert.Equal(expected, result); }
public void Should_Return_Number_Of_Steps_To_Point(string directions, int x, int y, int expected) { var result = LineCalculator.GetTotalStepsToReachPoint(directions, x, y); Assert.Equal(expected, result); }
public void Should_Show_As_Corrupt(string line, char expected) { var result = LineCalculator.AnalyseForCorruption(line.ToCharArray()); Assert.Equal(expected, result); }