My test is trying to assert that a certain dal method was called, with some parameters.
The method is returning a DataSet object, so my mock just returns an empty DataSet when called.
The problem I have is that when the SUT doesn't call the dal with the proper parameters, the mock will not return the empty DataSet, and so my class will ...
I'm working on an enterprise application that relies heavily on message queues, com+, databases, httpcontext, static utility classes etc.
Since there's 600 projects in our system it seems impractical to rewrite to use inversion of control. Typemock claims they are the only isolation framework that doesn't require you to rewrite your co...
I have a class that occasionally gets passed null for File objects. During normal operation it uses a Scanner class to parse through the file.
Instead of littering my code with null checks against the File objects, I thought I could replace the Files with nullobjects (Gang of Four style).
However, it looks like File isn't really design...
I've got a PresenterFactory that creates Presenter classes based on a Role parameter. Specifically, the Role parameter is an external class which I cannot control (IE 3rd party.)
My factory looks something like this:
public class PresenterFactory {
public Presenter CreatePresenter(Role role, ...) {
if (role.IsUserA("Manage...
Our web application works together with several web-services which we can't influence. After each workflow (tested with Selenium) a hook call to a web-service occurs. I would like to mock that server. Ideally, I want a HTTP server object which I can start and kill at will, and an URL dispatcher which would call certain subroutines in my ...
I need to make tests for my webservice project. In my webservice Interface there is a method named loginuser with string params username and password. It uses C#, WCF, and Visual Studio.
How do I to test that loginuser method in my webservice returns correct results?
...
Hi,
I have a method call which I want to mock with mockito. To start with I have created and injected an instance of an object on which the method will be called. My aim is to verify one of the object in method call.
Is there a way that mockito allows you to assert or verify the object and it's attributes when the mock method is called...
My program has a daily routine, similar to an alarm clock event. Say, when it's 2pm(The time is the system time in my pc), do something for me.
What I want to do is to speed up the testing period(I don't really want to wait 4 days looking at the daily routine and check errors.) I read on wiki of Mock object, the writer DID mention alar...
Hi, I'm testing a simple DAO layer with mockito but I found a problem, basically a hard to test interface and I was wondering if you could give me some insight...
This is the method I want to test:
public Person getById(UserId id) {
final Person person = new PersonImpl();
gateway.executeQuery(GET_SQL + id.getUserId(), new Resu...
I'm using Rhino Mock 3.5 for .Net Framework 2.0 and when I run this code I get a run time error.
This is the code
IFile fileInterface = MockRepository.GenerateStub<IFile>();<br>
IUrlMapper urlMapper = MockRepository.GenerateStub<IUrlMapper>();
// this is the line causing the run-time error<br>
HttpContextBase mockHttpContext = MockRe...
I am mocking an HttpRequest object using Moq for unit testing in ASP.NET MVC. I need to set one of the ServerVariables (LOGON_USER) in the request. Is this possible? I have tried using the following method, but I get an exception because the ServerVariables collection is non-overridable.
request.SetupGet(req => req.ServerVariables["...
I'm using PHPUnit but find it difficult to make it create good mocks and stubs for objects used as datastore.
Example:
class urlDisplayer {
private $storage;
public function __construct(IUrlStorage $storage) { $this->storage = $storage; }
public function displayUrl($name) {}
public function displayLatestUrls($count) {}
...
The current product I work on is a Windows Service written C++ and going forward all new functionality will have unit tests written for it. But this creates an interesting problem (for me at least) we do a lot Win32 calls for various things and behave accordingly, so for the unit tests to be complete it would be nice to test a variety o...
Is it possible to create a mock object that implements several interfaces with EasyMock?
For example, interface Foo and interface Closeable?
In Rhino Mocks you can provide multiple interfaces when creating a mock object, but EasyMock's createMock() method only takes one type.
Is it possbile to achieve this with EasyMock, without resor...
Hi all
Beginner in Moq.
Trying to understand the use of verifySet etc... but unless I do a workaround I cannot get it to work.
public interface IProduct
{
int Id { get; set; }
string Name { get; set; }
}
public void Can_do_something()
{
var newProduct = new Mock<IProduct>();
newProduct.SetupGet(p => p.Id).Returns(1);...
I'd like to know how do you test your methods if the libs you are using don't use Interfaces
My class is like
private ThirdParyClass thirdPartyClass;
void myMethod() {
AnotherThirdPartyClass param = "abc";
...
thirdPartyClass.execute(param);
}
I want to test that execute is called with the "abc" param.
I was thinking in creating M...
We are in the initial phase of trying to implement TDD. I demo'd the Visual Studio Team System code coverage / TDD tools and the team is excited at the possibilities. Currently we use Devpartner for code coverage, but we want to eliminate it because its expensive. We have very limited experience in TDD and want to make sure we don't go a...
In the following code, Test1 succeeds but Test2 fails:
protected Mock<IMyInterface> MyMock { get; set; }
[SetUp]
public virtual void Initialize()
{
MyMock = new Mock<IMyInterface>();
}
[Test]
void Test1()
{
// ... code that causes IMyIntervace.myMethod to be called once
MyMock.Verify(x=> x.myMethod(), Times.Once());
}
[...
I'm trying to unit-test my implementation of an interface, and I'm having a little difficulty successfully mocking out a SqlTransaction parameter to one of the interface methods.
Here's what the interface, and method under test that I'm interested in look like..
public class MyInterface
{
void MyMethod(SqlTransaction SharedTransact...
Hi.
When writing code in Java, it is very helpful to embrace composition and dependency injection to make it possible and easy to do pure unit testing by mocking collaborating objects.
I find that doing the same in Erlang is less straightforward and makes for dirtier code.
That's likely to be my fault, as I'm quite new to Erlang and q...