Where is the MOQ documentation? [closed]

Moq’s latest documentation is now available at github wiki page: https://github.com/Moq/moq4/wiki/Quickstart Previously they were on Google Code. As well as the wiki and other online resources, there’s full documentation in Windows .CHM help-file format included in the Moq binary download linked from the Moq homepage.

Moq’ing methods where Expression are passed in as parameters

It is probably correct that only an Expression with the exactly same structure (and literal values) will match. I suggest that you use the overload of Returns() that lets you use the parameters the mock is called with: repoMock.Setup(moq => moq.FindBy(It.IsAny<Expression<Func<Company, bool>>>()) .Returns((Expression<Func<Company, bool>> predicate) => …); In …, you can use predicate to return … Read more

Mocking Asp.net-mvc Controller Context

Using MoQ it looks something like this: var request = new Mock<HttpRequestBase>(); request.Expect(r => r.HttpMethod).Returns(“GET”); var mockHttpContext = new Mock<HttpContextBase>(); mockHttpContext.Expect(c => c.Request).Returns(request.Object); var controllerContext = new ControllerContext(mockHttpContext.Object , new RouteData(), new Mock<ControllerBase>().Object); I think the Rhino Mocks syntax is similar.

Why use It.is or It.IsAny if I could just define a variable?

Using It.IsAny<>, It.Is<>, or a variable all serve different purposes. They provide increasingly specific ways to match a parameter when setting up or verifying a method. It.IsAny The method set up with It.IsAny<> will match any parameter you give to the method. So, in your example, the following invocations would all return the same thing … Read more

How to assign values to properties in moq?

The way you prepare the mocked user is the problem. moqUser.Object.Name = username; will not set the name, unless you have setup the mock properly. Try this before assigning values to properties: moqUser.SetupAllProperties(); This method will prepare all properties on the mock to be able to record the assigned value, and replay it later (i.e. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)