FluentAssertions를 사용하여 NonActionAttribute로 장식되지 않은 모든 메서드를 테스트하고 싶습니다. (이렇게하면 T4MVC에 의해 자리 표시 자로 자동 생성 된 동작 메서드가 줄어 듭니다.)Fluent Assertions ThatAreNotDecoratedWith
내 특정 문제는 함께 MethodInfoSelector 메서드를 연결하는 것입니다.
이public MethodInfoSelector AllActionMethods() {
return TestControllerType.Methods()
.ThatReturn<ActionResult>()
.ThatAreNotDecoratedWith<NonActionAttribute>();
}
public static MethodInfoSelector ThatAreNotDecoratedWith<TAttribute>(this IEnumerable<MethodInfo> selectedMethods) {
return (MethodInfoSelector)(selectedMethods.Where(method => !method.GetCustomAttributes(false).OfType<TAttribute>().Any())); // this cast fails
}
어느 캐스트가 실패하거나 내가 IEnumberable 내 결과를 변환하면 내가 할 수없는 체인 추가 MethodInfoSelector 방법 :이 같은 것을 쓰고 싶습니다.
MethodInfoSelector를 생성하는 방법이나 특정 속성이없는 방법을 나열하는 기본 문제에 대한 다른 방법에 대해 도움을 주시면 감사하겠습니다.
덕분에 내가 코드를 시도하고 컴파일하지만, 적어도 한 곳에서 내가 NUnit과 테스트 케이스와 같은 결과를 사용하고, 그 충돌 NUnit과 원인, @vossad : 여기에 체인 연결 작업을하게됩니다 하나의 구현은 . 나는 당신의 첫 번째 대답이 최고라고 생각합니다. –
나는 동의한다, 우리는 아직이 필요성을 예상하지 못했다. 이슈 또는 풀 요청은이를 해결합니다. –