I'm currently trying to get one of my unit tests to work, but there is one thing in the way. I have a class called AccountingScheduleLookup that has an ID field attached to it that's read-only. When I try to mock a call to a method that uses this ID field it throws me a lovely NullReferenceException on that particular line of code. This ...
Hi all,
I am just starting out with unit testing and have a scenario I'm not sure how to appraoch and my solution doesn't feel right.
I have a bit of code that does something, if it fails i.e. throws an exception the exception is caught and logged as below.
public T CreateTypedObjectInstance<T>()
{
T o = default(T);
try
...
public Class Test{
GetDataset(RandomBoolean uncertain);
GetDataset2();
GetDataset3();
}
where method definitions are
public virtual void GetDataset2(){}
public virtual void GetDataset3(){}
public virtual void GetDataset(RandomBoolean uncertain)
{
if (uncertain.State){
GetDataset2();
}
...
Sometimes Rhino.Mocks is driving me mad, 'cause there's not enough documentation on topics that, I suppose, are relatively easy.
What I want to do is to expect call to AddContact("test", contact). So for the second parameter I must use parameter constraint Property.AllPropertiesMatch(contact). But what should I use for the first one?
_...
Hi,
I have so far been coding by doing mostly Get methods in my business/service layer using Rhino Mocks to get an expected List or type and making Rhino Mocks return it for me, my question is how do I test a set/save call, e.g void SaveCustomers(Customer)
I have a call called GetCustomers, can I use Rhino mocks to call this immediatel...
I'm very new at mocking and Rhino Mock. I searched for resources about learning Rhino Mocks but not found an easy one. Does anyone knows any good resources to start
...
Is it true that mocking frameworks in general and Rhino mocking in specific only mocks interfaces and classes that have virtual method? For example can I mock following simple class:
public class MyClass
{
void method1()
{
//some code goes here
}
}
If the answer is true, why such a limitation exists? Is there any w...
Can I set up a mock object to always return the object given as a parameter? I have a method
public MyObject DoSomething(MyObject obj)
and I want to have a mock which always returns obj for every call to DoSomething, sort of like this:
mock.Stub(x=>x.DoSomething(Arg<MyObject>.Is.Anything).Return(Arg<MyObject>)
although I'm not su...
I have a
I have an Interface called IFileDownloader which has a signature called DownlowadFile(string url, string fileName)
I have a class, called, StockManager which implements this method. This class has another method called DownloadFiles(string url, String[] fileNames) which calls the Interface method. How can I use Rhino Mocks to...
Benn trying to test a service layer method which returns a simple IList using RhinoMocks 3.6
[TestMethod]
public void GetItems_Returns_ActionItemsList()
{
// arrange
var mockRepository = MockRepository.GenerateMock<IActionItemRepository>();
mockRepository.Stub(s => s.Select()).Return(GetFakeActionItems()...
I'm currently trying to implement StructureMap's AutoMocking functionality and I need help with getting the mocked .
I have a Test method as follows:
[Test]
public void DirctoryResult_Returns_Groups()
{
var autoMocker = new RhinoAutoMocker<GroupController>(MockMode.AAA);
GroupController controller = autoMocker.ClassUnderTest;
...
Hi,
I have a .NET 3.5 Win Form application with three classes login.cs,Main.cs,dBTansaction.cs. I am writing a testcase to for Main.cs which makes calls to dbTransaction.cs. So I mocked to DBTransaction.cs to return diff values for each call and it all works fine. After the testcase is run in my teardown, i close the application for whi...
Is it possible to use Rhino Mocks to mock WindowsImpersonationContext?
I get:
System.MissingMethodException : Can't find a constructor with matching arguments
----> System.MissingMethodException : Constructor on type 'WindowsImpersonationContextProxy04bee852de914d5b8a47d6776edc4cb3'
var windowsImpersonationContext = mockRepository....
I heard that latest style is AAA. Is there any other one? Why we use one and don't use another?
...
Build server:
TFS 2008, W2003
Error message:
System.IO.FileLoadException: Could not load file or assembly 'Rhino.Mocks, Version=3.5.0.1337, Culture=neutral, PublicKeyToken=0b3305902db7183f' or one of its dependencies. Access is denied..
This happens only aprox. last 2 weeks.
Same tests were successful before and still are when runn...
Hi All;
Trying to mock the following method:
bool IsLoginValid(LoginViewModel viewModel, out User user);
Tried this initially:
dependency<ILoginService>()
.Stub(serv =>
serv.IsLoginValid(
Arg<LoginViewModel>.Is.Equal(a_login_viewmodel),
out Arg<User>.Is.Anything)
.Return(false);
But, that fails, as ...
Now this is just strange:
The code as it is below works fine in a NUnit unit test with RhinoMocks (the assert passes).
This is creating an IndexSearcher in the code.
Now if I use the mocked version of Get (swap the commented assignment of IndexSearcher) so now the searcher is returned by the mock, it doesn't pass the assertion.
Can a...
Hello,
I'm having a strange error trying to create a unit test. I'm trying to mock IPresenterFactory of the WebFormsMvp framework to force the return of a presenter. So I'm mocking it as:
var view = ..;
var presenter = new TestPresenter(view);
var factory = mock.Stub<IPresenterFactory>();
factory.Expect(i => i.Create(null, null, null...
I'm trying to test if the method I want to test calls some external (mock) object properly.
Here is the sample code:
using System;
using Rhino.Mocks;
using NUnit.Framework;
namespace RhinoTests
{
public abstract class BaseWorker
{
public abstract int DoWork(string data);
}
public class MyClass
{
...
I have a COM library that I have to reference in my app and I am trying to mock its interfaces.
I am getting exceptions when I am doing this MockRepository.GenerateMock<IAmAComInterface>();
I don't get exceptions when I do this: MockRepository.GenerateDynamicMockWithRemoting<IAmAComInterface>(); but none of my expectations are verifyin...