I currently have a test which tests the presenter I have in the MVP model. On my presenter I have a property which will call into my View, which in my test is mocked out. In the Initilization of my test, after I set my View on the Presenter to be the mocked View, I set my property on the Presenter which will call this method.
In my te...
I have a mocked object that is passed as a constructor argument to another object.
How can I test that a mocked object's property has been called? This is code I am using currently:
INewContactAttributes newContact = MockRepository.GenerateMock<INewContactAttributes>();
newContact.Stub(x => x.Forenames).Return("One Two Three");
someobj...
Is there any way I can mock FormsAuthentication.Authenticate("username", "password") method with test credential? My test goal is to make sure that if authentication fails, it redirects to correct place. I'm using Rhino Mocks as mocking framework.
Thank you very much for your help,
...
I would like to set up a return value
_stubRepository.Stub(Contains(null)).IgnoreArguments().Return(true);
but then in a specific test, override that expectation to return false.
Something like
_stubRepository.ClearExpectations(); //<- this does not exist, I'm just making something up
_stubRepository.Stub(Contains(null)).IgnoreAr...
I can't for the life of me find the proper syntax using the Fluent/AAA syntax in Rhino for validating order of operations.
I know how to do this with the old school record/playback syntax:
MockRepository repository = new MockRepository();
using (repository.Ordered())
{
// set some ordered expectation...
I am setting up an expectation for a call to a method that builds and executes a query. I would like to interrogate the properties of the parameter used. Is this possible
using (mocks.Record())
{
Expect.Call(connection.Retrieve(SOMETHING_HERE)).Return(returnedDatay);
}
The bit I am after is the "SOMETHING HERE" bit.
(This is my f...
I'm looking to write unit tests for a method such as this one:
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
ISPMembershipUserDao userDao = GetISPMembershipUserDao();
if (ValidateUser(username, password))
{
SPMembershipU...
Hi folks,
I currently use the following approach to create a strongly typed object representing session variables.
public abstract class SessionController : Controller
{
private const string SESSION_NAME = "UserSession";
public SessionData SessionData
{
get
{
SessionData sessionData = (SessionDa...
In the .net 3.5 project that I am working on right now, I was writing some tests for a service class.
public class ServiceClass : IServiceClass
{
private readonly IRepository _repository;
public ServiceClass(IRepository repository)
{
_repository = repository;
}
#region IServiceClass Members
pu...
Hi,
I have a paging controller with a method which calls
RouteTable.Routes.GetVirtualPath(this.viewContext.RequestContext, valueDictionary)
I am trying to test this method using Rhino mocks and I'm unsure how to mock GetVirtualPath to return a route other than null. I am mocking the RequestContext but I am unsure which methods/prop...
Hi! I'm trying to use RhinoMock for mocking out a wcf service.
Say I have the following service:
[OperationContract]
List<User> SearchUsers(UserSearchFilter filter);
Adding this service with Visual Studio will generate a proxy, and that proxy has a Interface like:
public interface ResourceService {
System.IAsyncResult ...
I have a user control which does some validation in the ValidateChildren method which I would like to test. I have created a partial mock of the user control, but although I am not setting any expectations on the ValidateChildren method, I am simply calling it, it is simply skipped and the code inside the method never executes. To try ...
With reference to the Managed Extensibility Framework (MEF), I'm trying to work out how to create clean tests with mocks.
I have an exported component which has three private imports. Each imported object (field) needs to be mocked. Given that the CompositionContainer uses fancy reflection tactics to set imported private fields of compo...
I am using Rhino mocks for unit test mocking of objects. Our DAL uses codesmith to generate code from .netTiers templates, which creates these DataRepository classes that contain all the methods for CRUD type transaction to the datasource. In unit testing, I am trying to mock this data repository object which has no interface class to us...
In NMocks2 you can mock up the result of a method you don't know the arguments to before hand using
Stub.On(aMock)
.Method( ... )
.WithAnyArguments()
.Will(Return.Value( ... );
from NMocks2 Cheatsheet. My question is, is there a similar mechanism for Rhino mocks when you don't care about the arguments? I want to make a ...
Hi, I am trying to create a unit test similar to how I would have done one in C# but am struggling with the lambdas in vb.
Bascially I am trying to mock a class and then create a stub and return. In C# I would have done something like;
MockedPersonRepository
.Stub(x => x.Find(id))
.Return(person)
But in visual basic I am t...
I have a method on an interface that looks like this and I want to stub it with Rhino Mocks:
TValue GetPropertyOfExistingObject<TValue>(long id, Expression<Func<T, TValue>> propertyExpression);
My code that does the stubbing looks like this:
var service = MockRepository.GenerateStub<IQuoteService>();
service.Stub(s => s.GetPropertyOf...
Hello,
I am using the Rhino Mocks framework.
I referenced the Rhinomocks dll and everything worked fine..
but when I was trying to use the LastCall.Constraints(Is.Anything())
it says: Error The name 'Is' does not exist in the current context
The same happens with Text and List constraints..
any help??
...
Is there, if any? :
var storage = mocks.DynamicMock<IStorage>();
...
SetupResult.For(storage.GetCustomers())
.Return(new Collection<Customer> { cust1, cust2 });
// and
storage.Stub(x => x.Customers)
.Return(new Collection<Customer> { cust1, cust2 });
...
Using Josh Flanagans StructureMap Automocking overview, I'm trying my hand at it but can get the following code to return the Category object I've assigned:
[Test]
public void Service_Should_Return_Category_From_ID()
{
// Arrange
var categoryToTest = new Category()
{
ID = 1,
Name = "Department 1",
Description = ...