MOQ 문서는 어디에 있습니까?
MOQ에 대한 포괄적 인 문서는 어디에서 찾을 수 있습니까? 나는 조롱하는 것으로 시작하고 있으며 그것에 대해 머리를 돌리는 데 어려움을 겪고 있습니다. http://code.google.com/p/moq/wiki/QuickStart의 모든 링크를 읽었 지만 자습서 나 부드러운 소개를 찾을 수없는 것 같습니다.
또한 Rhino Mocks를 간략히 살펴 보았지만 매우 혼란 스러웠습니다.
예-저는 Stephen Walthers 기사를 읽었습니다. 매우 도움이되었습니다. 나는 또한 링크를 통해 갔다. http://www.bestechvideos.com/2008/06/08/dimecasts-net-introduction-to-mocking-with-moq [깨진 링크] 에서 비디오를 볼 수없는 것 같습니다
.
특히 모의 클래스에서 이벤트가 발생했는지 확인하려고합니다. 컴파일 할 QuickStarts 페이지의 이벤트에 대한 예제를 얻을 수 없습니다. Google 그룹에서 Daniel은 CreateEventHandler가 유형의 이벤트 만 처리 할 수 있다고 설명 EventHandler<TEventArgs>
했지만 그래도 컴파일 할 코드를 가져올 수 없습니다.
보다 구체적으로 INotifyChanged
.
public class Entity : INotifyChanged
{
public event PropertyChangingEventHandler PropertyChanging;
public int Id
{
get {return _id;}
set {
_id = value;
OnPropertyChanged("Id");
}
}
protected void OnPropertyChanged(string property)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
etc .....
}
PropertyChanged
이벤트가 시작 되었는지 여부를 테스트하기 위해 클래스를 어떻게 모의 합니까? public event EventHandler<PropertyChangedEventArgs>
이 오류가 발생 하기 때문에 이벤트를 다시 작성할 수 없습니다 .
오류 1 'CoreServices.Notifier'는 인터페이스 멤버 System.ComponentModel.INotifyPropertyChanged.PropertyChanged '를 구현하지 않습니다. 'CoreServices.Notifier.PropertyChanged'는 'System.ComponentModel.PropertyChangedEventHandler'와 일치하는 반환 형식이 없기 때문에 'System.ComponentModel.INotifyPropertyChanged.PropertyChanged'를 구현할 수 없습니다.
Moq의 최신 문서는 이제 github wiki 페이지에서 사용할 수 있습니다.
https://github.com/Moq/moq4/wiki/Quickstart
이전에는 Google 코드에있었습니다. 위키 및 기타 온라인 리소스뿐만 아니라 Moq 홈페이지 에서 링크 된 Moq 바이너리 다운로드에 포함 된 Windows .CHM 도움말 파일 형식의 전체 설명서가 있습니다 .
Moq로 조롱하는 소개를 보셨습니까 ? Moq 사용에 대한 입문 개요이며 일반적으로 조롱하거나 Moq 프레임 워크 자체를 처음 사용하는 사용자를위한 것입니다.
https://github.com/Moq/moq4/wiki/Quickstart 에서 링크 된 페이지를 읽었 습니까? 예를 들어 이것 (아마 stephen walthers 개인 블로그로 옮겼을 것입니다 )
모의 클래스에서 이벤트가 발생했는지 확인하려고합니다.
당신은? 아니면 Id
속성이 설정 되었는지 확인하려고 합니까? 기본적으로 mock에는 동작이 없습니다. 알림 이벤트를 발생시키지 않습니다.
나는 할 것이다 :
const int ExpectedId = 123;
mockEntity.VerifySet(x => x.Id = ExpectedId);
이것은 Entity가 인터페이스를 구현한다고 가정합니다. 한 가지 예 :
public interface IKeyedEntity
{
int Id { get; set; }
}
That said, if Entity
is a POCO with no interesting behavior I would neither implement an interface (other than INotifyChanged
) nor mock it. Test with an actual Entity
instance (just don't use a database). Reserve mocking for services and complex dependencies.
For more Moq features, see
Old style imperative mocks vs moq functional specifications and Mock.Of - how to specify behavior? (thread). I also posted my own example of Moq v4 functional specifications.
ReferenceURL : https://stackoverflow.com/questions/231175/where-is-the-moq-documentation
'programing' 카테고리의 다른 글
Controller 클래스 이외의 클래스를 사용한 종속성 주입 (0) | 2021.01.16 |
---|---|
Powershell을 사용한 Vim (0) | 2021.01.16 |
ASP.NET MVC 3 Razor 설명서 (0) | 2021.01.16 |
Bash 스크립트에서 백틱과 $ ()의 차이점은 무엇입니까? (0) | 2021.01.16 |
Subversion이있는 ".gitignore"파일과 동일 (0) | 2021.01.16 |