Hi guys
I know that there has been a couple questions about tutorials on rhino-mocks. But I am wondering if there are any sample apps out there that use rhino-mocks in the context of an n-tier business application using ado.net.
I find the tutes good, but they don't seem to bring everything all together into the big picture. Thus, I ...
I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the code that I found at Scott Hanselman's blog to simulate HttpContext using rhino.mocks.
so i have this unit test piece:
PostsController postsController = new PostsController(postDL);
mocks.SetFakeControllerContext(post...
I want to assert that a method is called exactly one time.
Update: I'm using RhinoMocks 3.5.
Here's what I thought would work:
[Test]
public void just_once()
{
var key = "id_of_something";
var source = MockRepository.GenerateStub<ISomeDataSource>();
source.Expect(x => x.GetSomethingThatTakesALotOfResources(key))
...
I am using Castle Windsor for IoC and I want to use Binsor to define my configuration.
I want to let my internals be visible to Boo. I have tried to mark my assembly with
InternalsVisibleTo("Boo.Lang") but that didn't do the job. I have tried InternalsVisibleTo("Rhino.Commons") because I have noticed that the exception is thrown from wi...
I've a problem with partial mocking using Rhino Mocks:
var authentication = (FormsAuthenticationService)_mocks.PartialMock(
typeof(FormsAuthenticationService));
Expect.Call( delegate{ authentication.SetAuthCookie(null, null); }).IgnoreArguments();
..and I get NullReferenceException on "Expect." line..
I will just add that FormsAuth...
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...
I would like to do something like the following but can't seem to get the syntax for the Do method quite right.
var sqr = new _mocks.CreateRenderer<ShapeRenderer>();
Expect.Call(sqr.CanRender(null)).IgnoreArguments().Do(x =>x.GetType() == typeof(Square)).Repeat.Any();
So basically, I would like to set up the sqr.CanRender() method to ...
Being new to RhinoMocks and Unit Testing, I have come accross an issue that I cannot seem to find a resolution to (no matter how much documentation I read).
The issue is this: I have created an Interface that exposes 5 Events (to be used for a view in ASP.NET and the MVP Supervisory Controller pattern..... I know, I should be using M...
The Rhino Mocks download comes with a "Rhino.Mocks.xml" file that apparently adds Intellisense for Rhino Mocks.
What do you need to do with this file in order to get it to work?
...
How do I mock the method GetValues() in System.Data.IDataReader?
This method changes the array of objects passed to it, so it can’t simply return a mocked value.
private void UpdateItemPropertyValuesFromReader( object item, IDataReader reader )
{
object[] fields = new object[ reader.FieldCount ];
reader.GetValues( fields ); //...
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'm new to RhinoMock's just been doing state unit testing up till now.
How do you test void functions?
Getting the following complie error when setting up expectation,
Expression does not produce a value
Basically I want to test that a certain mock's method is called a certain amount of times.
Cheers
...
I'm new to TDD. So any help would be appreciated. I'm using NUnit and Rhino mocks.
How can I set the ID value to 1 in my mock object?
I had a look at this: http://www.iamnotmyself.com/2008/06/26/RhinoMocksAndReadOnlyPropertyInjectionPart2.aspx
but the reflection doesn't seem to work against interfaces.
public interface IBatchInfo
...
I am new to unittesting and mocking in general and am trying to set up tests for one of my classes where I want to make sure that a particular method is called from another method within the same class. I would therefore like to use the concrete implementation but mock out parts of it. Is this possible?
public class MyClass
{
public ...
I've have searched on this and it seems to be a catch all, unfortunately everything I've read doesn't help figure it out. Here is the class:
public interface IMockInterface
{
MockClass MockedMethod();
MockClass MockThis();
}
public class MockClass : IMockInterface
{
public virtual MockClass MockedMethod()
{
MockClass r...
I have a really simple class with two methods; One that will be called and the other that it will call. The idea is to call the OuterMockMethod method BUT mock the InnerMockMethod. Right now I can only seem to mock the OuterMockMethod method.
public class MockClass : IMockInterface
{
public virtual MockClass InnerMockMeth...
I'm trying to use Rhinomocks 3.5 and the new lambda notation to mock some tests. I've read this, but have so many more questions. Are there any complete examples out there, especially for a MVC type of architecture?
For example what is the best way to mock this.
public void OnAuthenticateUnitAccount()
{
if(AuthenticateUnitAcco...
I have been using (and liking) the new Rhino Mocks AAA syntax. However, one thing that puzzles me is that I have to create my stubs and mocks like this:
var v1 = MockRepository.GenerateStub<MyClass>();
instead of with an instantiated MockRepository:
var mr = new MockRepository();
var v1 = mr.GenerateStub<MyClass>();
This syntax wo...
The following test case fails in rhino mocks:
[TestFixture]
public class EnumeratorTest
{
[Test]
public void Should_be_able_to_use_enumerator_more_than_once()
{
var numbers = MockRepository.GenerateStub<INumbers>();
numbers.Stub(x => x.GetEnumerator()).Return(new List<int>
...
I am using dependency injection to supply mocks for code outside of my class under test. I find myself writing alot of the same code over and over as I need to mock out AuthProvider, ConfigurationManager, etc. which are used in the method I want to test. The method contains branches (if-then-else) and therefore I have multiple tests in p...