rhino-mocks

Can I test method call order with AAA syntax in Rhino-Mocks 3.6?

梦想与她 提交于 2019-11-29 09:46:06
Is it possible to test for the following example if the Method1 called 1st, then Method2 called after and then Method3 by using the AAA syntax, in Rhino-mocks 3.6 ? // Assert var mock = MockRepository.GenerateMock<ISomeService>(); // Act myObject.Service = mock; // How should I change this part to ensure that Rhino Mocks check the call order as well? mock.AssertWasCalled(m=>m.Method1()); mock.AssertWasCalled(m=>m.Method2()); mock.AssertWasCalled(m=>m.Method3()); Here's one way to do it... mock.AssertWasCalled(m=>m.Method1(), options => options.WhenCalled(w => mockService.AssertWasNotCalled(x=

Rhino Mocks AAA Quick Start?

痴心易碎 提交于 2019-11-29 03:53:21
I've been looking around for some decent information on using Rhino Mocks 3.5+ with the AAA syntax. I find a lot of blogs that have a mix of things from the old and new which seem to make it more difficult to figure out how to use it. Would would be great would be if there were a Rhino Mocks AAA Cheat Sheet like was done for an earlier version. Is it required that you know everything about the older versions of Rhino to actually use the newer version? I'm sure if I were an expert that I would love all the capabilities in Rhino, but for now I'm just swimming in information. Any pointers or good

How to Mock a Static Singleton?

◇◆丶佛笑我妖孽 提交于 2019-11-29 01:32:20
I have number of classes I've been asked to add some unit tests to with Rhino Mocks and having some issues. First off, I know RhinoMocks doesn't allow for the mocking of Static members. I'm looking for what options I have (besides using TypeMock). An example of the class I have is similar to the below: class Example1 : ISomeInterface { private static ISomeInterface _instance; private Example1() { // set properties via private static methods } static Example1() { _instance = new Example1(); } public static ISomeInterface Instance() { get { return _instance; } } // Instance properties // Other

What is the difference between Version and 'Runtime Version' in .Net?

强颜欢笑 提交于 2019-11-28 21:01:55
When I open the properties window of one of the referenced dlls in my project in Visual Studio I see a Version and also a runtime version . Actually it is Rhino.Mocks library I am checking. And I see Runtime Version : v2.0.50727 Version : 3.6.0.0 What is the difference? (Does it mean I am not able to use 3.6.0.0 of the Rhino Mocks?) Adam Houldsworth Runtime is the version of the CLR (or .NET framework) the DLL needs (usually as a minimum), version is the DLL's version. So long as you have the minimum runtime installed, it should be usable. However as a general rule it is usually best to select

What are the capabilities of Moq and Rhino.mocks?

让人想犯罪 __ 提交于 2019-11-28 14:36:37
问题 I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq". I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking for a capability comparison . For example: Rhino has Expect.On() for threaded mocking. Can Moq do this? What about Multi-mocking (implementing multiple interfaces

How to mock extension methods with Rhino Mock?

徘徊边缘 提交于 2019-11-28 07:40:08
问题 I have extended objects of type IDataReader with some extension methods that I needed. The problem is now when I try to mock the IDataReader, the extended method is not included in the mock so when the row Expect.Call(reader.ExtensionMethod()).Return(someValue) is reach the ExtensionMethod is executed which is not what I want! I want that call to be record and when the extension method is call from somewhere else I want it to return someValue . Does anyone know how to get around this? 回答1:

How can I verify that a Microsoft Fakes (beta) stub/shim was called (like AssertWasCalled in Rhino Mocks)?

岁酱吖の 提交于 2019-11-28 07:22:04
问题 I'm using the beta of Microsoft Fakes in Visual Studio 11. How can I verify that a dependency's method was called by my system under test? 回答1: As verify functionality is not included in the Microsoft Fakes Beta, the code below is a basic test for whether or not a method on a dependency was called. You could enhance the true test to test parameter values or other conditions of a proper call. Test: [TestMethod] public void TestMethod1() { var secondDoItCalled = false; var secondStub = new

Rhino Mocks - Stub .Expect vs .AssertWasCalled

此生再无相见时 提交于 2019-11-28 04:21:58
OK, I know there has been a lot of confusion over the new AAA syntax in Rhino Mocks, but I have to be honest, from what I have seen so far, I like. It reads better, and saves on some keystrokes. Basically, I am testing a ListController which is going to basically be in charge of some lists of things :) I have created an interface which will eventually become the DAL, and this is of course being stubbed for now. I had the following code: ( manager is the system under test, data is the stubbed data interface) [Fact] public void list_count_queries_data() { data.Expect(x => x.ListCount(1));

Can't get RhinoMocks to emit a mock that follows the generic type restriction rules

痞子三分冷 提交于 2019-11-28 04:15:20
问题 So, using NUnit and RhinoMocks: //Defines basic behavior of all persistable domain objects public interface IDomainObject {...} //defines domain objects specific to the Security DB public interface ISecurityDomainObject : IDomainObject {...} //Defines a basic transactional data Repository; there are multiple implementors //which each close TRest to the interface that defines their DB's domain classes public interface IRepository<TRest> : IDisposable where TRest:IDomainObject { IUnitOfWork

Best Practices of Test Driven Development Using C# and RhinoMocks [closed]

最后都变了- 提交于 2019-11-28 02:32:25
In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rules may apply more generally as well.) Does anyone have any best practices that they follow? To maximize the testability of code, follow these rules: Write the test first, then the code. Reason: This ensures that you write testable code and that every line of code gets tests written for it. Design classes using dependency injection. Reason: You cannot mock or test