public void Multiply_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 = $"multiply: {expected.Remove(expected.Length-1, 1)} = {expectedValue}"; Assert.IsTrue(_calService.Multiply(list).Equals(expected)); }
public void Calculate_Multiply_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.MULTIPLY); Assert.IsTrue(value.Contains(expectedValue)); Assert.IsTrue(value.Equals(calService.Multiply(numbers.ToList()))); }