Created
July 8, 2022 01:35
-
-
Save KangDroid/1702e52e3bf8520b463ef2c873ae589c to your computer and use it in GitHub Desktop.
테스트 코드 실습 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact(DisplayName = "SquarePlus: SquarePlus는 ArithmeticRequest의 각 Operand에 2/3을 입력하면, Result로 13을 반환합니다.")] | |
public void Is_SquarePlus_Returns_ArithmeticResult_With_13_When_Request_Operand_2_3() | |
{ | |
// Let - 테스트를 하기에 앞서서 입력 / 예상 출력 변수를 정의합니다. | |
// 이 함수는 객체를 입력으로 받으므로, 객체를 준비합니다. | |
var request = new ArithmeticRequest | |
{ | |
FirstOperand = 2, | |
SecondOperand = 3 | |
}; | |
var expectedResult = new ArithmeticResult | |
{ | |
FirstOperand = 2, | |
SecondOperand = 3, | |
CalculationResult = 13 | |
}; | |
// Do - 우리가 테스트하고 싶은 함수를 미리 준비한 입력 변수와 함께 실행하는 구간입니다. | |
var result = _arithmeticService.SquarePlus(request); | |
// Check - 우리가 예상한 테스트 결과와 실제 함수의 결과가 서로 같은지, 상태가 같은지 검사합니다. | |
// 이 함수는 클래스를 반환하므로, 클래스 안에 있는 모든 멤버변수들을 검사합니다. | |
Assert.Equal(expectedResult.FirstOperand, result.FirstOperand); | |
Assert.Equal(expectedResult.SecondOperand, result.SecondOperand); | |
Assert.Equal(expectedResult.CalculationResult, result.CalculationResult); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment