I've been banging my head against the wall trying to understand these concepts for a week now. I was really surprised when I came across with a very understandable and simple explanations of these concepts in the ASP.NET MVC NerdDinner application tutorial. I suggest this to anyone struggling to have that 'aha' moment.
http://nerddinner...
I know that this is a subjective question...
Typemock is $799 per developer. Licences for 5 devs comes up to a pretty large sum. If someone here used Typemock and given that there are open source mocking frameworks, is it worth the money? Why?
...
This is NOT a question about which is the best framework, etc.
I have never used a mocking framework and I'm a bit puzzled by the idea. How does it know how to create the mock object? Is it done in runtime or generates a file? How do you know its behavior? And most importantly - what is the work flow of using such a framework (what is t...
I have slightly adapted the custom behavior code that can be found here:
http://www.reflectionit.nl/blog/default.aspx?guid=d81a8cf8-0345-48ee-bbde-84c2e3f21a25
that controls a MediaElement.
I need to know how to go about testing this with Rhino Mocks e.g. how to instantiate a new ControlMediaElementAction in test code and then call the...
Can someone please help?
I use Google code’s Moq framework for mocking within my Unit Tests and Unity for Dependency Injection.
In my Test class
private Mock<ICustomerSearchService> CustomerSearchServiceMock = null;
private CustomerService customerService = null;
private void SetupMainData()
{
CustomerSearchServiceMock = new Moc...
I am writing unit tests for the "glue" layer of my application, and am having difficulty creating deterministic tests for asynchronous methods that allow the user to cancel the operation prematurely.
Specifically, in a few async methods we have code that reacts to the cancellation of the call and ensures that the object is in the prop...
Given the Thread class with it current method.
Now inside a test, I want to do this:
def test_alter_current_thread
Thread.current = a_stubbed_method
# do something that involve the work of Thread.current
Thread.current = default_thread_current
end
Basically, I want to alter the method of a class inside a test method and recover ...
I mocked a couple of methods of my Data Access layer, but in some methods the value of an SQL output param is set. How can I mock this ?
Method:
var wrappedParameters = new SqlParameter[3];
wrappedParameters[0] = new SqlParameter("@username",username);
wrappedParameters[1] = new SqlParameter("@password",passwor...
Moles is an isolation framework created by Microsoft. A cool feature of Moles is that it can "mock" static/non-virtual methods and sealed classes (which is not possible with frameworks like Moq). Below is the quick demonstration of what Moles can do:
Assert.AreNotEqual(new DateTime(2012, 1, 1), DateTime.Now);
// MDateTime is part of ...
Hi there,
I just recently read about "Mocking objects" for unit testing and currently I'm having a difficulties implementing this approach in my application. Please let me explain my problem.
I have a User model class, which is dependent on 2 data sources (database and facebook web service). The controller class simply use this User mo...
I need to create Unit Tests for an ASP.NET MVC 2.0 web site. The site uses Windows Authentication.
I've been reading up on the necessity to mock the HTTP context for code that deals with the HttpContext. I feel like I'm starting to get a handle on the DI pattern as well. (Give the class an attribute of type IRepository and then pass...
The way I understand it, DI allows you to use an IoC container to do something like
If a constructor needs an IFoo, use a concrete class Foo : IFoo.
But how is a Mock object using Moq different? Doesn't it also use DI to create a fake Foo?
Thanks.
...
I've been looking at several Mocking frameworks for ASP.NET and came across Microsoft Moles. This seems to be a part of Microsoft Research team and was wondering If anyone here has selected Moles over other matured Mocking frameworks such as Moq.
...
Can someone provide me a reference to a good PHPUnit mock guide? The one in the official documentation doesn't seem to be detailed enough. I am trying to study PHPUnit by reading the source code, but I am not familiar with the term matcher, invocation mocker, stub return, etc.
I need to know about the following:
1) How to expect multi...
During testing I have a mock object which sets errno = ETIMEDOUT; The object I'm testing sees the error and calls strerror_r to get back an error string:
if (ret) {
if (ret == EAI_SYSTEM) {
char err[128];
strerror_r(errno, err, 128);
err_string.assign(err);
} else {
err_string.assign(gai_strerror...
As far as I know, RM should mock anything that can be accessed by a derived class. Since a protected virtual member is accessible from a subclass, shouldn't it be mockable?
My understanding is that RM does not support mocking protected virtual members.
...
I have been trying to figure this one out, how do i test that a private method is called with rhino mocks with in the class that I am testing. So my class would be something like this.
Public class Foo
{
public bool DoSomething()
{
if(somevalue)
{
//DoSomething;
}
else
{
Rep...
I realize this has been asked before, but the last time was in mid 2008.
If you were starting a new project right now, which one would you use and why? What are their strengths/weaknesses regarding readability, usability, maintainability, and overall robustness?
...
In my Zend Framework project, I have a form that I am testing. In my form, a multi-select element gets its options from a model, which gets the data from the database.
public function init()
{
$this->addElement('select', 'Region_ID', array('multiOptions' => $this->getRegions()));
}
protected function getRegions()
{
$mapper = ne...
Can Moles be used without having to use Pex?
Also, Does anyone know when MS Moles will have a Release candidate? I am hesitant of using it in the Production system without knowing which direction it will head.
...