Where is the MOQ documentation located?

Where can I find comprehensive documentation for MOQ? I am just starting out with a mockery and having a hard time hugging him. I read all the links in http://code.google.com/p/moq/wiki/QuickStart , but it seems I can not find a tutorial or a gentle introduction.

I also looked briefly at Rhino Mocks, but found this very confusing.




Yes. I am reading an article by Stephen Walter - very helpful. I also looked through the links. I can not watch the video at http://www.bestechvideos.com/2008/06/08/dimecasts-net-introduction-to-mocking-with-moq [broken link]

In particular, I am trying to determine if an event was raised from a mocking class. I cannot get an example for events on the QuickStarts page to compile. In google groups, Daniel explained that CreateEventHandler can handle an event like EventHandler<TEventArgs> , but even then I cannot compile it.

In particular, I have a class that implements 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 ..... } 

How do I make fun of a class to check if the PropertyChanged event has been fired? I cannot rewrite the event to the public event EventHandler<PropertyChangedEventArgs> because I get this error:

Error 1 'CoreServices.Notifier' does not implement a member of the System.ComponentModel.INotifyPropertyChanged.PropertyChanged 'interface. "CoreServices.Notifier.PropertyChanged" cannot implement "System.ComponentModel.INotifyPropertyChanged.PropertyChanged" because it does not have the corresponding return type "System.ComponentModel.PropertyChangedEventHandler".

+52
c # testing moq mocking
Oct 23 '08 at 19:44
source share
4 answers

The latest Moq documentation is now available on the github wiki page:

https://github.com/Moq/moq4/wiki/Quickstart

They used to be on Google Code. In addition to the wiki and other online resources, there is complete documentation in the .CHM file format in the Moq binary download format associated with the Moq homepage .

+30
Nov 09 '08 at 19:33
source share

Have you watched Introduction to Mocking with Moq ? This is an introductory overview of the use of Moq and is intended for those who are new to either bullying in general or the Moq framework itself.

+15
Oct. 23 '08 at 19:48
source share

Have you read the related pages at https://github.com/Moq/moq4/wiki/Quickstart ? for example this one (may have moved to the personal blog stephen walthers )

+4
Oct 23 '08 at 19:59
source share

I am trying to determine if an event was raised from bullying a class.

You? Or are you trying to determine if the Id property has been set? Remember that the default layout has no behavior. This does not increase event notifications.

I would do:

 const int ExpectedId = 123; mockEntity.VerifySet(x => x.Id = ExpectedId); 

This assumes Entity implements the interface; one example:

 public interface IKeyedEntity { int Id { get; set; } } 

However, if Entity is POCO without any interesting behavior, I would neither implement the interface (except INotifyChanged ) nor mock it. Test with an actual Entity instance (just don't use the database). Reserve mocking service and complex addictions.

For additional Moq features, see

Old stylistic requirements for fraudsters and functional functions of moq and Mock.Of - how to specify behavior? (Thread) . I also posted my own example of the functional specifications of Moq v4 .

+1
Dec 17 '11 at 17:31
source share



All Articles