コード例 #1
0
 public void AddNewLinesAndCommasTest()
 {
     Calculator calc = new Calculator();
     string strNums = "1\n10,4\n1";
     int result = calc.Add(strNums);
     Assert.AreEqual<int>(16, result);
 }
コード例 #2
0
 public void AddMultipleArgumentsTest()
 {
     Calculator calc = new Calculator();
     string strNums = "1,5,6,10,105,5,8,0";
     int result = calc.Add(strNums);
     Assert.AreEqual<int>(140, result);
 }
コード例 #3
0
 public void AddChangeDelimiterTest()
 {
     Calculator calc = new Calculator();
     string strNums = "//:\n10:4:1";
     int result = calc.Add(strNums);
     Assert.AreEqual<int>(15, result);
 }
コード例 #4
0
 public void AddOneArgumentTest()
 {
     Calculator calc = new Calculator();
     Random rand = new Random(10);
     int arg = rand.Next();
     int result = calc.Add(arg.ToString());
     Assert.AreEqual<int>(arg, result);
 }
コード例 #5
0
 public void AddTwoArgumentsTest()
 {
     Calculator calc = new Calculator();
     Random rand = new Random(10);
     int arg1 = rand.Next();
     int arg2 = rand.Next();
     int result = calc.Add(arg1.ToString() + "," + arg2.ToString());
     Assert.AreEqual<int>(arg1 + arg2, result);
 }
コード例 #6
0
 public void AddNegativeThrowsExceptionTest()
 {
     Calculator calc = new Calculator();
     string strNums = "-10,-2,1";
     int result = calc.Add(strNums);
 }
コード例 #7
0
 public void AddEmptyStringTest()
 {
     Calculator calc = new Calculator();
     int result = calc.Add(String.Empty);
     Assert.AreEqual<int>(0, result);
 }