public void returns_the_same_number_when_you_pass_1_number() { Calculator calc = new Calculator(); int result = calc.Add("26"); Assert.That(result, Is.EqualTo(26)); }
public void returns_0_if_empty_string() { Calculator calc = new Calculator(); int result = calc.Add(""); Assert.That(result, Is.EqualTo(0)); }
public void AddIgnoresBigNumbers(Calculator sut, int smallSeed, int bigSeed) { var x = Math.Min(smallSeed, 1000); var y = bigSeed + 1000; var numbers = string.Join(",", x, y); var actual = sut.Add(numbers); Assert.Equal(x, actual); }
public void AddAnyAmountOfNumbersReturnsCorrectResult(Calculator sut, int count, Generator<int> generator) { var integers = generator.Take(count+2).ToArray(); var numbers = string.Join(",", integers); var actual = sut.Add(numbers); var expected = integers.Sum(); Assert.Equal(expected, actual); }
public void Add_DelimeterOfOtherLength() { // arrange string str1 = "//[**]\n1**5**6**2"; Calculator calc = new Calculator(); //act int expected = 14; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void Add_GreaterThanThousand() { // arrange string str1 = "1\n2002,3\n5"; Calculator calc = new Calculator(); //act int expected = 9; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void Add_LongDelimeter() { // arrange string str1 = "//[***]\n1***9***3"; Calculator calc = new Calculator(); //act int expected = 13; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void AddTwoNumbersReturnsCorrectResult(Calculator sut, int x, int y) { var numbers = string.Join(",", x, y); var actual = sut.Add(numbers); Assert.Equal(x + y, actual); }
public void AddLineWithNegativeNumbersThrowsCorrectException(Calculator sut, int x, int y, int z) { var numbers = string.Join(",", -x, y, -z); var e = Assert.Throws<ArgumentOutOfRangeException>(() => sut.Add(numbers)); Assert.True(e.Message.StartsWith("Negatives not allowed.")); Assert.Contains((-x).ToString(), e.Message); Assert.Contains((-z).ToString(), e.Message); }
public void AddLineWithCustomDelimiterStringsReturnsCorrectResult(Calculator sut, string delimiter1, string delimiter2, int x, int y, int z) { var numbers = string.Format("//[{0}][{1}]\n{2}{0}{3}{1}{4}", delimiter1, delimiter2, x, y, z); var actual = sut.Add(numbers); var expected = x + y + z; Assert.Equal(expected, actual); }
public void TestInitialize() { calculator = new Calculator(); }
public void BeforeScenario() { _calc = new Calculator(); }
public void setup() { calculator = new Calculator(); }
public void returns_the_sum_of_2_numbers() { Calculator calc = new Calculator(); int result = calc.Add("20,15"); Assert.That(result,Is.EqualTo(35)); }
public void Add_NegativeNumber() { // arrange string str1 = "//;\n1;2;-8;10"; Calculator calc = new Calculator(); //act int expected = 13; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void Add_ChangeDelimeter() { // arrange string str1 = "//;\n1;2;8;10"; Calculator calc = new Calculator(); //act int expected = 21; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void AddLineWithCustomDelimiterReturnsCorrrectResult(Calculator sut, Generator<char> charGenerator, Generator<int> intGenerator, int count) { int dummy; var delimiter = charGenerator.Where(c => !int.TryParse(c.ToString(), out dummy) && c != '-').First(); var integers = intGenerator.Take(count).ToArray(); var numbers = string.Format("//{0}\n{1}", delimiter, string.Join(delimiter.ToString(), integers)); var actual = sut.Add(numbers); var expected = integers.Sum(); Assert.Equal(expected, actual); }
public void AddLineWithCustomDelimiterStringREturnsCorrectResult(Calculator sut, string delimiter, int count, Generator<int> intGenerator) { var integers = intGenerator.Take(count).ToArray(); var numbers = string.Format("//[{0}]\n{1}", delimiter, string.Join(delimiter, integers)); var expected = integers.Sum(); var actual = sut.Add(numbers); Assert.Equal(expected, actual); }
public void SetUp() { _calculationAggregatorMock = new Mock<ICalculationAggregator>(); _calculationAggregatorMock.Setup(c => c.PostResults(It.IsAny<int>())).Returns(true); _sut = new Calculator(_calculationAggregatorMock.Object); }
public StringCalculatorTest1() { _calculator = new Calculator(); }
public void SetUp() { calc = new Calculator(); }
static void Main(string[] args) { Calculator calc = new Calculator(); Console.WriteLine("sum = {0}", calc.Add("//[**]\n1**1**1**1")); Console.ReadLine(); }
public void Add_StringWithNewLine() { // arrange string str1 = "1\n2,3"; Calculator calc = new Calculator(); //act int expected = 6; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void Add_SimpleString() { // arrange string str1 = "1,2,6,15"; Calculator calc = new Calculator(); //act int expected = 24; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void Add_SeveralDelimeters() { // arrange string str1 = "//[*][%]\n1*2%3"; Calculator calc = new Calculator(); //act int expected = 6; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public void AddEmptyReturnsCorrectResult( Calculator sut ) { var numbers = ""; int actual = sut.Add(numbers); Assert.Equal(0, actual); }
public void Add_NullString() { // arrange string str1 = ""; Calculator calc = new Calculator(); //act int expected = 0; // assert int actual = calc.Add(str1); Assert.AreEqual(expected, actual, "Not correctly"); }
public CalculatorTests() { parser = Substitute.For<StringParser>(); calc = new Calculator(parser); }
public void Setup() { _calculator = new Calculator(); }
public void AddSingleNumberReturnsCorrectResult(Calculator sut, int expected) { var numbers = expected.ToString(); var actual = sut.Add(numbers); Assert.Equal(expected, actual); }
public void EmptyStringShouldReturnZeroWhenAdd() { var calculator = new Calculator(); Assert.AreEqual(calculator.Add(""), 0); }
public void AddWithLineBreakAndCommaAsDelimitersReturnsCorrectResult(Calculator sut, int x, int y, int z) { var numbers = string.Format("{0}\n{1},{2}", x, y, z); var actual = sut.Add(numbers); Assert.Equal(x + y + z, actual); }