I have a method that calls a service to retrieve an instance of an object, updates the instance then saves the instance back to the service (the code for this is below).
What I want to know is if there is a nice way in Moq to check the following:-
That the instance that is being saved back to the service is a modified version of the o...
Hi folks,
i have the following code, which fails during runtime...
var mock = new Mock<ControllerContext>();
mock.SetupGet(x => x.HttpContext.Request
.ServerVariables["HTTP_HOST"]).Returns(domain);
** RunTime Error: Invalid setup on non-overridable
property
I've got some code in my controller, which needs to check the doma...
Is it possible to stub only one property and keep other's behaviour using Rhino Mocks?
Upd.
Example:
I have a class with two properties
public class ClassA
{
public string Property1
{
get
{
return "Property1";
}
}
public string Property2
{
get
{
return "Property2";
}
}
}
I would like to get an instance of thi...
I'm a relative newcomer to python and I'm just wondering if there is some equivalent to the map coercion feature available in groovy.
For context, I am writing a unit test and want to mock a class with a simple two method interface, in groovy I would do the following:
mock = [apply:{value -> return value*2 }, isValid:{return true}]
tes...
I would assume that the more dynamic nature of .NET 4 would improve the possibility of mocking. (but I may be wrong)
Are there mocking frameworks that take advantage of .NET 4?
If yes, which does it best?
Conversely, are there mocking frameworks that do not even run on .NET 4?
...
I'm just starting out with BDD/TDD using MSpec (with AutoMocking by James Broome) and RhinoMocks. Here's an excerpt from my practice project:
namespace Tests.VideoStore.Controllers
{
public abstract class context_for_movie_controller :
Specification<MovieController>
{
private static IList<Movie> movies;
prote...
Hello,
I am a fairly new software developer currently working adding unit tests to an existing C++ project that started years ago. Due to a non-technical reason, I'm not allowed to modify any existing code. The base class of all my modules has a bunch of methods for Setting/Getting data and communicating with other modules.
Since I ju...
Hi,
I have a method i'd like to stub but it has a lot of parameters.
How can i avoid mocking all parameters but still stub the method.
Ex:
//Method to stub
public void myMethod(Bar bar, Foo foo, FooBar fooBar, BarFoo barFoo, .....endless list of parameters..);
...
Hi I'm using Mocha for a Rails project. I'm new to TDD so please forgive me if this is a stupid question.
If I have this
@client.expects(:create_config).once.returns(true)
then am I right in assuming that the code in create_config() won't be run and instead true will just be returned?
...
I'm trying to implement unit tests for function that uses imported external objects.
For example helpers.py is:
import os
import pylons
def some_func(arg):
...
var1 = os.path.exist(...)
var2 = os.path.getmtime(...)
var3 = pylons.request.environ['HTTP_HOST']
...
So when I'm creating unit test for it I do some mocking (...
I have a Perl object that has defined use overload '""' => \&name;
and a name method.
In my unit tests I have mocked this object, including the name method, but code like
if (-d $object)
still gives me Use of uninitialized value in -d .... The mocked method is not being executed.
My mock code:
my $CMmock = Test::MockObject::Extend...
I am looking for the best way to go about testing the following static method (specifically using a Doctrine Model):
class Model_User extends Doctrine_Record
{
public static function create($userData)
{
$newUser = new self();
$newUser->fromArray($userData);
$newUser->save();
}
}
Ideally, I would use...
Hello,
I am trying to write a unit test for the 'IsUnique' function in the class below that looks like this:
class Foo
{
public bool IsUnique(params...)
{
ValidateStuffExists(params);
return CheckUniqueness(params);
}
private void ValidateStuffExists(params)
{
//does some validation
}
p...
I am using RhinoMocks, and I have a Mock which has a property I need to behave as a real property - updating its value when set, and also trigger PropertyChanged when the property is changed.
The interface of the mocked object is in essence this:
public interface IFoo
{
event PropertyChangedEventHandler PropertyChanged;
int B...
Hi,
It is often said that interfaces making mocking and unit testing an easier process. How do interfaces help with this?
Thanks
...
Since I started to develop in a test/behavior driven style, I appreciated the ability to mock out every dependency.
Since mocking frameworks like Moq work best when told to mock an interface, I now implement an interface for almost every class I create b/c most likely I will have to mock it out in a test eventually.
Well, and programmin...
Requirements:
I wish there was a software that does:
runs my application in "learn mode"
logs any network traffic
creates a database of request-response combination (e.g. http)
runs my application in "offline mode"
catches any network traffic (e.g. http), and returns a response from the request-response database
Purpose:
Testing C...
I have an abstract class that has a virtual method. The method is virtual in the event that a later implementation needs to override that functionality.
However, Moq proxies all virtual methods so I don't seem to be able to test the actual code that's written, and instead uses the Mock setup for that method (which is currently to return...
Hi,
I hope this question is not 'controversial' - I'm just basically asking - has anyone here purchased TypeMock and been happy (or unhappy) with the results?
We are a small dev shop of only 12 developers including the 2 dev managers. We've been using NMock so far but there are limitations. I have done research and started playing with...
Hello,
I trying to test an AccountController that uses DotNetOpenAuth but I am running into a problem. I want to test the Logon Actionresult to see that it is returning the correct views. The test fails because realm(I think) has a contract that requires the HttpContext.Current not to be null. I think I have to mock the request somehow ...