Default parameter for MockedObject.Verify() - moq

I have a mocked object and am verifying some things called. But wanted to know what the default parameter is for MockedObject.Verify(thingToBeVerified)?
Is it Times.Zero, Times.Once, or even Times.AtLeastOnce?
I am using Moq 4.2 in NUnit 2.6.3

Times.AtLeastOnce() is the default

Related

way to override #RedisHash value in configuration

I'm using a framework which is based spring-data-redis, and the framework was using #RedisHash to set value the redis key uses. Is there a way to override the value set in #RedisHash?
I'm tring to use KeyspaceSettings to do that, but it seems not working. I've noticed the official documentation says "#RedisHash has the highest priority", is it the truth?
However, the annotated keyspace supersedes any other configuration.
Yes, you can choose the name of the hash adding a name parameter like this:
#RedisHash("name_hash")

Virtual methods still required when using Moq?

We're using Moq and I was wondering what the current role of virtual methods were in it-- in the post below dated 2008 it's clear you had to mark your methods as virtual in order for Moq to work (or inherit from an interface.)
Moq discussion
However, is this still the case in .Net 4.5, that you're required to use virutal methods in the class you want to mock? And does this also hold true when you create a wrapper class around a static method-- the wrapper class either inherits from an interface or the method in question needs to be marked virtual?
This hasn't changed in .NET 4 or 4.5. As the link you provided explains, Moq uses Castle Windsor Dynamic Proxy to generate a type derived from the type you wish to mock. Therefore, the standard rules of inheritance apply. The derived type generated by Moq can only intercept calls to methods that any normal derived class can override.

How to use Microsofts WPL / Anti-XSS as default HTTPEncoder?

I want to use Microsofts WPL AntiXSS Library as default HTTPEncoder as described at haacked but this documentation is for WPL 3.1 and I've read that there is a change regarding HTTPEncoder with latest WPL 4.0. What is the best way to implement it so that all input fields are automatically encoded?
Thanks!
The most inportant change in this context seems to be that if you pass a null as the value for encoding function the function will return null (previous behavior was to return String.Empty). The System.IO.TextWriter will handle nulls properly, so everything should work as expected.
The only change is in the class names, they were renamed to Encoder.whatever in 4.0. If you use Phil's code you'll get a bunch of obsolete warnings.
In 4.1 I will finally have a built in class to allow use as a default encoder, but I don't have a ship date yet I'm afraid.

How do I change test stub framework?

When I stub out a test with CodeRush, it is automatically inserting a using statement for NUnit when I already have a using statement for MBUnit. Is there a way to change the default test framework used when using the templates? I was unable to find it if so.
In the templates you can change the default test namespace used. You can also add conditional logic to check if the project references MBunit.Framework, if so add the MBUnit.Framework using statement, else use Nunit.

How does Spring 2.5 map the incoming request data to ModelAttribute command?

I have used Spring 2.0 and now I am using Spring 2.5 Natually, Spring 2.5 made life very easy as far as the Web Controllers are concerned. The question keeps coming in my mind that in 2.0 we had to set the command class and accordingly the AbstractFormController used to populate that command object for us. In Spring 2.5 we don't do that so how it comes know that which class to use ? Does it depend on the type of parameter we have annotated #ModelAttribute("command") to ?
If yes, then please let me know any "Utils" class that provides the exact mechanism wherein I can pass HttpRequest and class name (or Class object) and that would return me the populated object !
Hope you got my question.
Thanks in advance.
The Web MVC annotations binding eventually rely upon an
org.springframework.beans.AbstractPropertyAccessor
which has two concrete implementations:
org.springframework.beans.BeanWrapperImpl
org.springframework.beans.DirectFieldAccessor
Both accept a Java object, which will be the target to set the properties for.
The first, BeanWrapperImpl uses the setter/getter methods of a java object, while the other set the fields directly.
Both checks that the methods/fields are public/accesible, and if otherwise, use reflection's setAccessible(true) to ensure it can be set.
From the Web MVC, an instance of AbstractPropertyAccessor is created, and the parameter map of a HttpRequest is passed to AbstractPropertyAccessor#setPropertyValues.
After the call, the java object is populated with whatever is in the map

Resources