public void Divide_AllowNegative_UpperBound1000_CorrectOutput() { List <int> list = input.ToList(); _calService.AllowNegative = true; _calService.UpperBound = 1000; float expectedValue = 0; string expected = ""; for (int i = 0; i < list.Count; i++) { int item = list[i]; if (i == 0) { expectedValue = item; expected = $"{item}/"; continue; } if (item > 1000) { expected += "1/"; } else { expectedValue /= item; expected += $"{item}/"; } } expected = $"divine: {expected.Remove(expected.Length-1, 1)} = {expectedValue}"; Assert.IsTrue(_calService.Divide(list).Equals(expected)); }
public void Divide_Positive() { var index = _calculateService.Divide(4, 2); var result = _calculateService.GetResult(index); Assert.Equal(2, result); }
public void Calculate_Divine_CorrectOutput() { ICalculateService calService = new CalculateService() { AllowNegative = true, UpperBound = 2000 }; Calculator cal = new Calculator( new DelimiterService(), new ParseService(), calService ); cal.SetStringSequence("//[*][!!][rrr]\\n11rrr22*-33!!44"); int[] numbers = { 11, 22, -33, 44 }; string expectedValue = (11 / 22 / -33 / 44).ToString(); string value = cal.Calculate(Calculator.CalculateOperation.DIVIDE); Assert.IsTrue(value.Contains(expectedValue)); Assert.IsTrue(value.Equals(calService.Divide(numbers.ToList()))); }