My teams evolution of TDD includes what appear to be departures from traditional oop.
Moving away from classes that are self sufficient
We still encapsulate data where appropriate. But in order to mock any helper classes, we usually create some way to externally set them via constructor or mutator.
We don't use private methods, ever.
...
So, I'm reasonably new to both unit testing and mocking in C# and .NET; I'm using xUnit.net and Rhino Mocks respectively. I'm a convert, and I'm focussing on writing behaviour specifications, I guess, instead of being purely TDD. Bah, semantics; I want an automated safety net to work above, essentially.
A thought struck me though. I ...
I want to start using mock objects on my Delphi projects.
After a quick google I've found those:
Delphi Mock Wizard
PascalMock
So my question is what one is your favourite and why?
...
I need to test a function that needs to query a page on an external server using urllib.urlopen (it also uses urllib.urlencode). The server could be down, the page could change; I can't rely on it for a test.
What is the best way to control what urllib.urlopen returns?
...
Recently there has been quite some hype around all the different mocking frameworks in the .NET world. I still haven't quite grasped what is so great about them. It doesn't seem to be to hard to write the mocking objects I need myself. Especially with the help of Visual Studio I quickly can write a class that implements the interface I w...
I have a class like so:
public class ClassA
{
public bool MethodA()
{
//do something complicated to test requiring a lot of setup
}
public bool MethodB()
{
if (MethodA())
//do something
else
//do something else
endif
}
}
I have tests for MethodA and wan...
Does anyone know how to unit test SiteMapNode? We’re building some custom navigation controls, which renders unordered html lists from Site Maps with custom attributes.
I’m trying to follow a test first approach but am finding that SiteMapNode has internal dependencies on HttpContext. To traverse the site map file it insists on using a ...
I'm currently writing some methods that do some basic operations on form controls eg Textbox, Groupbox, these operations are generic and can be used in any application.
I started to write some unit tests and was just wondering should I use the real form controls found in System.Windows.Forms or should I just mock up the sections that I...
I have been working on a wrapper for a COM object that can only take and return strings. The interface for the COM object looks like this:
interface IMapinfo
{
void Do(string cmd);
string Eval(string cmd);
}
Now I have made classes that wrap up basic functions like so:
public class Table
{
...
Has anyone found a good method of mocking out ADO.Net Data Service calls from a Silverlight application?
The power of Data Services seems to be the use of linq, client side, over entities. However when testing the objects that do the data access how can you mock out the service?
One way is to create an entire mock Data Service, but th...
I'm new to unit testing. But how do I unit test my DAL which is written with Entity Framework, so I can make sure my DAL code is working correctly but no database is actually touched? Could someone give as much detail as possible please.
Thanks,
Ray.
Note: this post is relevant to my other post Mocking vs. Test DB? which is asked aft...
Earlier I asked this question How to correctly unit test my DAL?, one thing left unanswered for me is if to really test my DAL is to have a Test DB, then what is the role of mocking vs. a testing DB?
To add on this, another person suggested to "use transactions and rollback at the end of the unit test, so the db is clean", test db that ...
I understand the need to test a class that has logic (for instance, one that can calculate discounts), where you can test the actual class.
But I just started writing unit tests for a project that will act as a repository (get objects from a database). I find myself writing a 'fake' repository that implements an ISomethingRepository in...
I'm new to mocking, I have a new .net web project that is in UI->BLL->DAL->DB structure, I use NUnit to do some testing currently. I intent to use it to test middle tier so I don't have to actually write to DB.
Now, I've never done any mocking, don't quite know where to start, so I am looking for a mocking framework that has some end to...
I use custom Attributes in a project and I would like to integrate them in my unit-tests.
Now I use Rhino Mocks to create my mocks but I don't see a way to add my attributes (and there parameters) to them.
Did I miss something, or is it not possible? Other mocking framework? Or do I have to create dummy implementations with my attribut...
Hi
I'm trying to work out a way of passing the web current http context to a service class (or initialising the class with a reference to it). I am doing this to abstract the rest of the app away from needing to know anything about the http context.
I also want the service to be testable using TDD, probably using one of the Mockable f...
I am attempting to mock a call to an indexed property. I.e. I would like to moq the following:
object result = myDictionaryCollection["SomeKeyValue"];
and also the setter value
myDictionaryCollection["SomeKeyValue"] = myNewValue;
I am doing this because I need to mock the functionality of a class my app uses.
Does anyone know how...
I'm playing around with Rhino Mocks and am trying to set some dummy results on my mocked objects so when they are called in my factory methods I don't have to worry about the data.
But I've hit a snag, the methods I want to have the dummy results for are causing exceptions because they aren't virtual.
I've got code like this:
using(mo...
I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call:
function getFoo($id) {
$MyTableRepresentation = DB_DataObject::factory("mytable");
$MyTableRepresentation->get($id);
... do s...
Im very new top mocking frameworks, but I have decided to take a look at Moq. It is my understanding that I can test that a method call will occur if I call a higher level method i.e.
public abstract class SomeClass()
{
public void SomeMehod()
{
SomeOtherMethod();
}
internal abstract void SomeOtherMethod(...