1
我在寫一組簡單的單元測試。在這個特定的測試中,我正在測試所有標準文本輸入到函數中。C#單元測試。並非所有的路徑都返回值
然而,當我嘗試編譯,我收到此錯誤
ConverterTests.ConvertSixteenthsFractionalToDecimal_AverageCase()':不是所有的代碼路徑返回一個值
我應該改變來解決這個編譯錯誤?
下面是代碼:
[TestMethod]
public double ConvertSixteenthsFractionalToDecimal_AverageCase()
{
// arrange
string input = "1/16";
int expected = 1;
// act
int actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "1/8";
expected = 2;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "3/16";
expected = 3;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "1/4";
expected = 4;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "5/16";
expected = 5;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "7/16";
expected = 3;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "1/2";
expected = 8;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "9/16";
expected = 9;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "5/8";
expected = 10;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "11/16";
expected = 11;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "3/4";
expected = 12;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "13/16";
expected = 13;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "7/8";
expected = 14;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
// arrange
input = "15/16";
expected = 15;
// act
actual = clsDimension.CvtSixteenthsFractionalToDecimal(input);
// assert
Assert.AreEqual(expected, actual);
}
我在12分鐘內接受 –
對不起,我分心了,從未回來 –