Search Results

Search found 299 results on 12 pages for 'rhino mocks'.

Page 2/12 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Rhino - Set FEATURE_LOCATION_INFORMATION_IN_ERROR in code?

    - by Scott
    I'd like fileName, lineNumber and stack traces to automatically be provided by Rhino for any errors. I've been told that I need to set FEATURE_LOCATION_INFORMATION_IN_ERROR on the current context, but I'm not sure how to do this in code. Does anybody have an example of turning this feature on so that I can see stacktrace dumps on crashes? I'm using Rhino as part of Narwhal/Jack, and so that complicates things a bit, and I think the easiest way to at least get moving forward is if I can set it through code. Thanks.

    Read the article

  • TDD a controller with ASP.NET MVC 2, NUnit and Rhino Mocks

    - by Nissan Fan
    What would a simple unit test look like to confirm that a certain controller exists if I am using Rhino Mocks, NUnit and ASP.NET MVC 2? I'm trying to wrap my head around the concept of TDD, but I can't see to figure out how a simple test like "Controller XYZ Exists" would look. In addition, what would the unit test look like to test an Action Result off a view?

    Read the article

  • Rails Fixtures vs. Mocks

    - by Thiago
    Hi there, I'm developing a Rails app, and I was just talking with my colleague that we have a mix of fixtures and mocks in our tests, which we're doing using cucumber and Rspec. The question would be: when should each one be used?

    Read the article

  • Cannot mock class with constructor having array parameter using Rhino Mocks

    - by SharePoint Newbie
    Hi, We cannot mock his class in RhinoMocks. public class Service { public Service(Command[] commands){} } public abstract class Command {} // Code var mock = MockRepository.GenerateMock<Service>(new Command[]{}); // or mock = MockRepository.GenerateMock<Service>(null) Rhino mocks fails complaining that it cannot find a constructor with matching arguments. What am I doing wrong? Thanks,

    Read the article

  • TDD a controller with ASP.NET MVC 2, NUnit and Rhine Mocks

    - by Nissan Fan
    What would a simple unit test look like to confirm that a certain controller exists if I am using Rhino Mocks, NUnit and ASP.NET MVC 2? I'm trying to wrap my head around the concept of TDD, but I can't see to figure out how a simple test like "Controller XYZ Exists" would look. In addition, what would the unit test look like to test an Action Result off a view?

    Read the article

  • How can I test blades in MVC Turbine with Rhino Mocks?

    - by Brandon Linton
    I'm trying to set up blade unit tests in an MVC Turbine-derived site. The problem is that I can't seem to mock the IServiceLocator interface without hitting the following exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at System.Reflection.Emit.TypeBuilder._TermCreateClass(Int32 handle, Module module) at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock() at System.Reflection.Emit.TypeBuilder.CreateType() at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType() at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType() at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCode(Type proxyTargetType, Type[] interfaces, ProxyGenerationOptions options) at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors) at Rhino.Mocks.MockRepository.MockInterface(CreateMockState mockStateFactory, Type type, Type[] extras) at Rhino.Mocks.MockRepository.CreateMockObject(Type type, CreateMockState factory, Type[] extras, Object[] argumentsForConstructor) at Rhino.Mocks.MockRepository.Stub(Type type, Object[] argumentsForConstructor) at Rhino.Mocks.MockRepository.<>c__DisplayClass1`1.<GenerateStub>b__0(MockRepository repo) at Rhino.Mocks.MockRepository.CreateMockInReplay<T>(Func`2 createMock) at Rhino.Mocks.MockRepository.GenerateStub<T>(Object[] argumentsForConstructor) at XXX.BladeTest.SetUp() Everything I search for regarding this error leads me to 32-bit vs. 64-bit DLL compilation issues, but MVC Turbine uses the service locator facade everywhere and we haven't had any other issues, just with using Rhino Mocks to attempt mocking it. It blows up on the second line of this NUnit set up method: IRotorContext _context; IServiceLocator _locator; [SetUp] public void SetUp() { _context = MockRepository.GenerateStub<IRotorContext>(); _locator = MockRepository.GenerateStub<IServiceLocator>(); _context.Expect(x => x.ServiceLocator).Return(_locator); } Just a quick aside; I've tried implementing a fake implementing IServiceLocator, thinking that I could just keep track of calls to the type registration methods. This won't work in our setup, because we extend the service locator's interface in such a way that if the type isn't Unity-based, the registration logic is not invoked.

    Read the article

  • Returning a complex data type from arguments with Rhino Mocks

    - by Joseph
    I'm trying to set up a stub with Rhino Mocks which returns a value based on what the parameter of the argument that is passed in. Example: //Arrange var car = new Car(); var provider= MockRepository.GenerateStub<IDataProvider>(); provider.Stub( x => x.GetWheelsWithSize(Arg<int>.Is.Anything)) .Return(new List<IWheel> { new Wheel { Size = ?, Make = Make.Michelin }, new Wheel { Size = ?, Make = Make.Firestone } }); car.Provider = provider; //Act car.ReplaceTires(); //Assert that the right tire size was used when replacing the tires The problem is that I want Size to be whatever was passed into the method, because I'm actually asserting later that the wheels are the right size. This is not to prove that the data provider works obviously since I stubbed it, but rather to prove that the correct size was passed in. How can I do this?

    Read the article

  • Need help mocking a ASP.NET Controller in Rhino Mocks

    - by Pure.Krome
    Hi folks, I'm trying to mock up a fake ASP.NET Controller. I don't have any concrete controllers, so I was hoping to just mock a Controller and it will work. This is what I currently have: _fakeRequestBase = MockRepository.GenerateMock<HttpRequestBase>(); _fakeRequestBase.Stub(x => x.HttpMethod).Return("GET"); _fakeContextBase = MockRepository.GenerateMock<HttpContextBase>(); _fakeContextBase.Stub(x => x.Request).Return(_fakeRequestBase); var controllerContext = new ControllerContext(_fakeContextBase, new RouteData(), MockRepository.GenerateMock<ControllerBase>()); _fakeController = MockRepository.GenerateMock<Controller>(); _fakeController.Stub(x => x.ControllerContext).Return(controllerContext); Everything works except the last line, which throws a runtime error and is asking me for some Rhino.Mocks source code or something (which I don't have). See how I'm trying to mock up an abstract Controller - is that allowed? Can someone help me?

    Read the article

  • Case insensitive expectations in Rhino Mocks

    - by user313886
    I'm using Rhino Mocks to expect a call. There is a single parameter which is a string. But I'm not bothered about the case of the string. I want the test to pass even if the case is wrong. So I'm doing the following: //expect log message to be called with a string parameter. //We want to ignore case when verifiyig so we use a constraint instead of a direct parameter Expect.Call(delegate { logger.LogMessage(null); }).Constraints(Is.Matching<string>(x => x.ToLower()=="f2")); It seems a bit log winded. Is there a more sensible way of doing this?

    Read the article

  • Rhino and Javascript 1.8?

    - by Scott
    Is it possible to have Rhino use a newer implementation of JS than 1.7? Do we have to wait for mozilla to do this, or is there a community project that has taken the lead? Thanks.

    Read the article

  • Unit Test For NpgsqlCommand With Rhino Mocks

    - by J Pollack
    My unit test keeps getting the following error: "System.InvalidOperationException: The Connection is not open." The Test [TestFixture] public class Test { [Test] public void Test1() { NpgsqlConnection connection = MockRepository.GenerateStub<NpgsqlConnection>(); // Tried to fake the open connection connection.Stub(x => x.State).Return(ConnectionState.Open); connection.Stub(x => x.FullState).Return(ConnectionState.Open); DbQueries queries = new DbQueries(connection); bool procedure = queries.ExecutePreProcedure("201003"); Assert.IsTrue(procedure); } } Code Under Test using System.Data; using Npgsql; public class DbQueries { private readonly NpgsqlConnection _connection; public DbQueries(NpgsqlConnection connection) { _connection = connection; } public bool ExecutePreProcedure(string date) { var command = new NpgsqlCommand("name_of_procedure", _connection); command.CommandType = CommandType.StoredProcedure; NpgsqlParameter parameter = new NpgsqlParameter {DbType = DbType.String, Value = date}; command.Parameters.Add(parameter); command.ExecuteScalar(); return true; } } How would you test the code using Rhino Mocks 3.6? PS. NpgsqlConnection is a connection to a PostgreSQL server.

    Read the article

  • Seeding repository Rhino Mocks

    - by ahsteele
    I am embarking upon my first journey of test driven development in C#. To get started I'm using MSTest and Rhino.Mocks. I am attempting to write my first unit tests against my ICustomerRepository. It seems tedious to new up a Customer for each test method. In ruby-on-rails I'd create a seed file and load the customer for each test. It seems logical that I could put this boiler plate Customer into a property of the test class but then I would run the risk of it being modified. What are my options for simplifying this code? [TestMethod] public class CustomerTests : TestClassBase { [TestMethod] public void CanGetCustomerById() { // arrange var customer = new Customer() { CustId = 5, DifId = "55", CustLookupName = "The Dude", LoginList = new[] { new Login { LoginCustId = 5, LoginName = "tdude" } } }; var repository = Stub<ICustomerRepository>(); // act repository.Stub(rep => rep.GetById(5)).Return(customer); // assert Assert.AreEqual(customer, repository.GetById(5)); } [TestMethod] public void CanGetCustomerByDifId() { // arrange var customer = new Customer() { CustId = 5, DifId = "55", CustLookupName = "The Dude", LoginList = new[] { new Login { LoginCustId = 5, LoginName = "tdude" } } }; var repository = Stub<ICustomerRepository>(); // act repository.Stub(rep => rep.GetCustomerByDifID("55")).Return(customer); // assert Assert.AreEqual(customer, repository.GetCustomerByDifID("55")); } [TestMethod] public void CanGetCustomerByLogin() { // arrange var customer = new Customer() { CustId = 5, DifId = "55", CustLookupName = "The Dude", LoginList = new[] { new Login { LoginCustId = 5, LoginName = "tdude" } } }; var repository = Stub<ICustomerRepository>(); // act repository.Stub(rep => rep.GetCustomerByLogin("tdude")).Return(customer); // assert Assert.AreEqual(customer, repository.GetCustomerByLogin("tdude")); } } Test Base Class public class TestClassBase { protected T Stub<T>() where T : class { return MockRepository.GenerateStub<T>(); } } ICustomerRepository and IRepository public interface ICustomerRepository : IRepository<Customer> { IList<Customer> FindCustomers(string q); Customer GetCustomerByDifID(string difId); Customer GetCustomerByLogin(string loginName); } public interface IRepository<T> { void Save(T entity); void Save(List<T> entity); bool Save(T entity, out string message); void Delete(T entity); T GetById(int id); ICollection<T> FindAll(); }

    Read the article

  • rhino embedding

    - by neheh
    Anyone understands the rhino javascript Contexts? I cannot find any useful documentation about it. My main problem is the Context.exit() (really should be cx.exit()) which from what I understand exits the context associated with the current thread? Does that mean I need to keep track of what which thread does? main thread: Context cx; cx.evaluateReader( ... ) // load some function start thread 2 thread 2: Object o= scope.get("methodname", scope); ((Function)o).call( ... ) I do not plan on doing multithreading but what if the different setups comes from different threads?

    Read the article

  • removing dependancy of a private function inside a public function using Rhino Mocks

    - by L G
    Hi All, I am new to mocking, and have started with Rhino Mocks. My scenario is like this..in my class library i have a public function and inside it i have a private function call, which gets output from a service.I want to remove the private function dependency. public class Employee { public virtual string GetFullName(string firstName, string lastName) { string middleName = GetMiddleName(); return string.Format("{0} {2} {1}", firstName, lastName,middleName ); } private virtual string GetMiddleName() { // Some call to Service return "George"; } } This is not my real scenario though, i just wanted to know how to remove dependency of GetMiddleName() function and i need to return some default value while unit testing. Note : I won't be able to change the private function here..or include Interface..Keeping the functions as such, is there any way to mock this.Thank

    Read the article

  • Parsing and replacing Javascript identifiers with Rhino in Java

    - by Parhs
    Suppose I let the user to write a condition using Javascript, the user can write conditions to perform a test and return true or false. E.g.: INS>5 || ASTO.valueBetween(10,210) I want to find which variables are used in the script that the user wrote. I tried to find a way to get the identifier names in Java. The Rhino library didn't help a lot. However I found that via handling exceptions I could get all the identifiers. So this problem is solved. So everything is great, but there is one little problem. How can I replace these identifiers with a numeric identifier? E.g. INS should be _234 and ASTO should be _331. INS and ASTO etc are entities in my database. I want to replace them, because the name may change. I could do it using a replace but this isn't easy because: It should be reversible. E.g. ASTO to _234 and _234 to ASTO again. Replacing _23 with MPLAH may also replace _234. This could be fixed with regexp somehow. What if _23 is in a comment section? Rare to happen, but possible /* _23 fdsafd ktl */. It should also be replaced. What if it is a name of a function? E.g. _32() {}. Also rare, but it shouldn't be replaced. What if it is enclosed in "" or ''? I am sure that there are a lot more cases. Any ideas?

    Read the article

  • Need help understanding Mocks and Stubs

    - by Theomax
    I'm new to use mocking frameworks and I have a few questions on the things that I am not clear on. I'm using Rhinomocks to generate mock objects in my unit tests. I understand that mocks can be created to verify interactions between methods and they record the interactions etc and stubs allow you to setup data and entities required by the test but you do not verify expectations on stubs. Looking at the recent unit tests I have created, I appear to be creating mocks literally for the purpose of stubbing and allowing for data to be setup. Is this a correct usage of mocks or is it incorrect if you're not actually calling verify on them? For example: user = MockRepository.GenerateMock<User>(); user.Stub(x => x.Id = Guid.NewGuid()); user.Stub(x => x.Name = "User1"); In the above code I generate a new user mock object, but I use a mock so I can stub the properties of the user because in some cases if the properties do not have a setter and I need to set them it seems the only way is to stub the property values. Is this a correct usage of stubbing and mocking? Also, I am not completely clear on what the difference between the following lines is: user.Stub(x => x.Id).Return(new Guid()); user.Stub(x => x.Id = Guid.NewGuid());

    Read the article

  • Moving from mock to real objects?

    - by jjchiw
    I'm like doing TDD so I started everything mocking objects, creating interface, stubbing, great. The design seems to work, now I'll implement the stuff, a lot of the code used in the stubs are going to be reused in my real implementation yay! Now should I duplicate the tests to use the real object implementation (but keeping the mocks object of the sensitive stuff like Database and "services" that are out of my context (http calls, etc...)) Or just change the mocks and stubs of the actual tests to use the real objects....... So the question is that, keep two tests or replace the stubs, mocks? And after that, I should keep designing with the mocks, stubs or just go with real objects? (Just making myself clear I'll keep the mock object of the sensitive stuff like database and services that are out of my context, in both situations.)

    Read the article

  • Rhino Mocks, Dependency Injection, and Separation of Concerns

    - by whatispunk
    I am new to mocking and dependency injection and need some guidance. My application is using a typical N-Tier architecture where the BLL references the DAL, and the UI references the BLL but not the DAL. Pretty straight forward. Lets say, for example, I have the following classes: class MyDataAccess : IMyDataAccess {} class MyBusinessLogic {} Each exists in a separate assembly. I want to mock MyDataAccess in the tests for MyBusinessLogic. So I added a constructor to the MyBusinessLogic class to take an IMyDataAccess parameter for the dependency injection. But now when I try to create an instance of MyBusinessLogic on the UI layer it requires a reference to the DAL. I thought I could define a default constructor on MyBusinessLogic to set a default IMyDataAccess implementation, but not only does this seem like a codesmell it didn't actually solve the problem. I'd still have a public constructor with IMyDataAccess in the signature. So the UI layer still requires a reference to the DAL in order to compile. One possible solution I am toying with is to create an internal constructor for MyBusinessLogic with the IMyDataAccess parameter. Then I can use an Accessor from the test project to call the constructor. But there's still that smell. What is the common solution here. I must just be doing something wrong. How could I improve the architecture?

    Read the article

  • Recursive mocking with Rhino-Mocks

    - by jaspernygaard
    Hi I'm trying to unittest several MVP implementations and can't quite figure out the best way to mock the view. I'll try to boil it down. The view IView consists e.g. of a property of type IControl. interface IView { IControl Control1 { get; } IControl Control2 { get; } } interface IControl { bool Enabled { get; set; } object Value { get; set; } } My question is whether there's a simple way to setup the property behavior for Enabled and Value on the IControl interface members on the IView interface - like recursive mocking a guess. I would rather not setup expectations for all my properties on the view (quite a few on each view). Thanks in advance

    Read the article

  • Constructing mocks in unit tests

    - by Flynn1179
    Is there any way to have a mock constructed instead of a real instance when testing code that calls a constructor? For example: public class ClassToTest { public void MethodToTest() { MyObject foo = new MyObject(); Console.WriteLine(foo.ToString()); } } In this example, I need to create a unit test that confirms that calling MethodToTest on an instance of ClassToTest will indeed output whatever the result of the ToString() method of a newly created instance of MyObject. I can't see a way of realistically testing the 'ClassToTest' class in isolation; testing this method would actually test the 'myObject.ToString()' method as well as the MethodToTest method.

    Read the article

  • Difference in techniques for setting a stubbed method's return value with Rhino Mocks

    - by CRice
    What is the main difference between these following two ways to give a method some fake implementation? I was using the second way fine in one test but in another test the behaviour can not be achieved unless I go with the first way. These are set up via: IMembershipService service = test.Stub<IMembershipService>(); so (the first), using (test.Record()) //test is MockRepository instance { service.GetUser("dummyName"); LastCall.Return(new LoginUser()); } vs (the second). service.Stub(r => r.GetUser("dummyName")).Return(new LoginUser()); Edit The problem is that the second technique returns null in the test, when I expect it to return a new LoginUser. The first technique behaves as expected by returning a new LoginUser. All other test code used in both cases is identical.

    Read the article

  • Do we really need isolation frameworks to create stubs?

    - by Sandbox
    I have read this: http://martinfowler.com/articles/mocksArentStubs.html My concepts about a stub and a mock are clear. I understand the need of isolation frameworks like moq, rhinomocks and like to create a mock object. As mocks, participate in actual verfication of expectations. But why do we need these frameworks to create stubs. I would rather prefer rolling out a hand created stub and use it in various fixtures.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >