Its absurdly late/early so maybe I'm just tired, but can anyone tell me why in the world the following test is not failing?
[Test]
public void uhh_what() {
var a = MockRepository.GenerateMock<IPrebuiltNotifier>();
a.Expect(x => x.Notify()).Repeat.Once();
a.Notify();
a.Notify();
a.VerifyAllExpectations();
}
Really n...
Help, can anyone help out and explain the purpose of the Rhino Mocks 'Record' scope?
I assumed that that the expectation set within the scope would only be verified but it seems as soon as you create the mock object, Rhino Mocks is in 'record mode' so I'm now unsure of the purpose of the Record scope.
Here's an example I have:
pri...
I have an extension method with the following signature (in BuildServerExtensions class)::
public static IEnumerable<BuildAgent> GetEnabledBuildAgents(this IBuildServer buildServer, string teamProjectName)
{
// Omitted agrument validation and irrelevant code
var buildAgentSpec = buildServer.CreateBuildAgentSpec(teamProjectName);...
Im trying to create a small app using .net 2.0 (client requirements :p), and I have added a reference to the Rhino Mocks dll file, then compiled it using VS2008, all good.
But when I run ant on the project, I get the following error:
[nunit2] SetUp/TearDown Failures:
[nunit2] 1) DocGen.Test.TestDocumentConfigurator : Could not load ...
Running this code:
_foo = MockRepository.GenerateStub<IBar>();
_foo.Stub(x => x.Foo()).Return("sdf");
When
public interface IBar
{
string Foo();
}
public class Bar : IBar
{
public string Foo()
{
throw new NotImplementedException();
}
}
throws NotSupportedException - "Can't create mocks of sealed classes". I under...
When executing the second line of this code Rhino Mocks throws an InvalidOperationException with a message "This action is invalid when the mock object is in replay state"
var mockScanner = MockRepository.GenerateMock<PortScanner>(null);
mockScanner.Expect((scanner => { scanner.Scan(null, null); }));
Stepping through the cod...
I'm using component from a third party. The component provide a singleton pattern for context into our application. I'm using on my side this singleton but I would like to mock this object for my test. Is there any way to accomplish a mock on this object.
Also, the constructor is declared private.
...
Appreciate any good example or references to websites which has useful information of using TDD with Model-View-Presenter pattern using Rhino Mocks.
What I am looking for is with respect to the following points
What to mock (view and presenter)
The new AAA syntax
How to mock UI behaviour? e.g. if "firstName" and "lastName" entered in...
I remember that to set expectations on methods that return void in C# one has to write:
mockedRepository.Expect(() => mr.AddUser(someUser)).DoOtherStuff()
where AddUser returns void.
How to achieve the same in VB.NET?
EDIT:
I've found similar question. May be helpful: How to mock a method with Rhino Mocks in VB.NET .
...
I'm new to mocking so I need a bit of guidance on how to mock HttpPostedFileBase with Rhino Mocks. I am trying to verify that my ToByteArray() extension works as expected and this is what I have so far:
[Test]
public void Should_return_a_byte_array_with_a_length_of_eleven()
{
// Arrange
var stream = new MemoryStream(System.Text.En...
I'm trying to write a test for an UrlHelper extensionmethod that is used like this:
Url.Action<TestController>(x => x.TestAction());
However, I can't seem set it up correctly so that I can create a new UrlHelper and then assert that the returned url was the expected one. This is what I've got but I'm open to anything that does not inv...
I am trying to test that a method to load a UI matrix is being loaded properly. The test fails unless I tell the mock framework to ignore the argument passed, giving me the following message:
Rhino.Mocks.Exceptions.ExpectationViolationException :
ITimeSheetMatrixWidget.Load
(Smack.ConstructionAdmin.Domain.TransferObjects.TimeSheetDtoAss...
I have a controller in C# using the ASP.Net MVC framework
public class HomeController:Controller{
public ActionResult Index()
{
if (Request.IsAjaxRequest())
{
//do some ajaxy stuff
}
return View("Index");
}
}
I got some tips on mocking and was hoping to test the code with the following ...
Ok, is it just me, or does there seem to be a lack of (easy to find) reference documentation for Rhino Commons and Rhino Mocks? My coworkers have started using Rhino Mocks and Rhino Commons (particularly the NHibernate stuff), and I found a few tutorial-ish examples, which were good. But when I see them making use of a class in their c...
Hi
I've been experimenting with Rhino Mocks for unit testing my .Net Compact Framework application, and have hit a problem. I can get a basic unit test using Rhino Mocks built, but every time I run the test that has the Rhino Mocks code in it, the test fails because it can't find the Rhino Mocks assembly.
System.TypeLoadException: Coul...
I would like to mock a class (i.e. with RhinoMocks) for which I don't have access to the code for (like say ManagementObject or ManagementObjectCollection) and for which methods/properties I am interested in
isn't virtual
isn't defined in an interface which the class implements
The way that I have been getting around this is to imple...
So I have a bunch of internal classes which I am trying to mock with RhinoMocks. I have added the following line to assemblyinfo.cs:
[assembly:InternalsVisibleTo(RhinoMocks.StrongName)]
However, this still does not allow me to mock internal classes; I get the following error message from NUnit:
MyTests.SomeTest:
System.TypeLoadE...
I have a factory that creates job objects in the form of IJob
Public Interface IJobFactory
Function CreateJobs(ByVal cacheTypes As CacheTypes) As IEnumerable(Of IJob)
End Interface
The interface IJob defines three things
Public Interface IJob
Sub Execute()
ReadOnly Property Id() As Integer
ReadOnly Property JobType() ...
Hey people... trying to get my mocking sorted with asp.net MVC.
I've found this example on the net using Moq, basically I'm understanding it to say: when ApplyAppPathModifier is called, return the value that was passed to it.
I cant figure out how to do this in Rhino Mocks, any thoughts?
var response = new Mock<HttpResponseBase>();
re...
Hi!
I’m having a mocking problem. I know only public methods should be mocked. But what do I do when a private method is called in a public method, and this private method is getting data from a file? I want to mock this private method so I could go on in with the test of the public method.
I could make this public to make the test wor...