I have a method that sets a property
public void SetNetworkCredential(string userName, string password, string domain)
{
_reportExecutionService.Credentials = new NetworkCredential(userName, password, domain);
}
how do I verify that Credentials was called with a valid NetworkCredential?
I tried this TestMethod but it fails becaus...
Hi
Is there a comparable and reliable alternative for Rhino Mock library.
I am using Rhino now for MVC ASP.NET project, but am considering (just as plan B) to see if there are any other equivalent alternatives.
...
I'm trying to implement the GetHttpContext function from HtmlHelperTest.cs in VB.NET using Rhino Mocks, but I'm getting "Type 'HttpContextBase' is not defined." The compiler suggests changing it to HttpContext, but when I do that I get a run time error that a sealed class cannot be mocked.
My test project references System.Web and also ...
I'm trying to mock out the System.net.Sockets.Socket class in C# - I tried using NUnit mocks but it can't mock concrete classes. I also tried using Rhino Mocks but it seemed to use a real version of the class because it threw a SocketException when Send(byte[]) was called. Has anyone successfully created and used a Socket mock using an...
I need to mock just Method1 to test my process exception. How I can do that?
public interface IFoo
{
void Method1();
object Method2();
}
public class Foo : IFoo
{
public void Method1()
{
// Do something
}
public object Method2()
{
try
{
// Do something
Method1(...
Mocking a concrete class with Rhino Mocks seems to work pretty easy when you have an empty constructor on a class:
public class MyClass{
public MyClass() {}
}
But if I add a constructor that takes parameters and remove the one that doesn't take parameters:
public class MyClass{
public MyClass(MyOtherClass instance) {}
}
I...
How do I mock an object with a constructor using Rhino Mocks?
For example how would this object be mocked...
public class Foo : IFoo
{
private IBar bar;
public Foo (IBar bar)
{
this.bar = bar
}
public DoSomeThingAwesome()
{
//awesomeness happens here
}
}
...
If I have the following class, how do I use RhinoMocks to mock the Count off of Things, ie myStuff.Things.Count?:
public class myStuff : ImyStuff
{
private Dictionary<String,String> _things;
...Other Code
public Dictionary<string, string> Things
{
get
{
return _thin...
I have a property in an interface that I have mocked using Rhino Mocks. I want to know if it was accessed in my unit test.
Is there a way to see if the property was accessed via Rhino Mocks?
I found this code here but it does not seem to work:
string name = customerMock.Name;
customerMock.AssertWasCalled(x => {var ignored = x.Name;})...
I have a scenario like this:
form = MockRepository.GenerateMock<IAddAddressForm>();
mediator = new AddAddressMediator(form);
The mediator is the real object under test and needs to be able to set values for the "form" object.
But the only way I can see to set values for the form object is like this:
form.Stub(x=>x.FirstName).Ret...
I am stumped. I am getting this error when I try to set a mock to have "PropertyBehavior()":
System.InvalidOperationException: System.InvalidOperationException:
Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method)..
I am trying to use only Rhino...
I'm testing an extension method on an interface 'ISomeInterface'. The extension method actually calls to another method in the interface.
How do I set up a mock and the appropriate expectations (i want to set the expectation that 'SomeMethod', which is an defined method in the interface with a different signature then this extension met...
I have in the controller a custom DataView object that comprises 2 lists. I populate them and than pass the DataView object as model for my view. In view when displaying the data I am checking for null reference. I wonder how to write unit tests to ensure that the programmer did not forget to check for null reference in the view. I would...
I'm having problems testing this scenario.
An invoice has two states - finished and unfinished - and I want to test that the method Presenter.FinishInvoice() calls DAO.FinishInvoice() then calls DAO.GetInvoice() and then sets View.Invoice with the result. The problem is that I need to call DAO.GetInvoice() to get an invoice to finish...
I work w/ Rhino Mocks 3.5 a lot but recently came across something I had never tried before. I want to stub out a service and setup the return value - simple stuff really
The only issue is that now my service isn't returning IList, but instead IQueryable
So when I try to do something like this - it blows up
<TestMethod()> _
Publi...
I have a class that has a property that I need to stub. I can't pass it as part of the constructor because the object constructing it does not know the parameters of the constructor.
When running unit tests, I want to be able to have the property be created as a stub.
This is what I have tried, but it does not work:
private DeviceMed...
Is there a way with Rhino Mocks to set a property of a Stub if a method is called.
Something like this: (Fake Code in bold)
callMonitor.Expect(x=>x.HangUp()).SetProperty(callMonitor.InACall = false);
The HangUp method returns void and I can't really change that. But I want my stub to know that the call was hung up when HangUp is call...
Is it possible in Rhino.Mocks to verify whether a specified constructor was called?
Consider the following code:
public interface IFoo
{
void Bar();
}
public class FooFactory
{
public IFoo CreateInstance(int x, int y)
{
return new Foo(x, y);
}
}
public class Foo : IFoo
{
public Foo(int x, int y)
{
// ... blah
...
We were trying to sort a collection of FileInfo objects in .NET. We implemented our IComparer to ensure that FileInfo objects were sorted based on our criteria. We then noticed that performance of sorting the FileInfo objects was many times slower than just ints. On a hunch (and remembering how references work in C) we were able to im...
I am just starting to do Test Driven Development, and I am wondering the major differences between RhinoMock, TypeMock, and NUnit's built-in mocking?
Any information would be greatly appreciated!
...