6/7/2023 0 Comments Rhino mocksParameterCollection inputParameters = new ParameterCollection() ServiceProvider.Stub(x => x.GetService(typeof())).Return(pipelineContext) Var pipelineContext = MockRepository.GenerateStub() Var serviceProvider = MockRepository.GenerateStub() RhinoMocks.Logger = new TextWriterExpectationLogger(Console.Out) Public void FollowupPlugin_CheckFollowupCreated() Using Rhino Mocks allows us to create a mock Organisation Service and assert that the Create method was called passing a task with the desired attributes set. So by mocking the pipeline context, we can specify the account id, and check that the resulting task that is created is regarding the same account. So in our example, the Followup Plugin should create a task with the regarding id set to the id of the account. We can then say we are ‘Done’ when all tests pass. This approach supports Test Driven Development (TDD), where the test is written first and then the desired functionality is added in order that the test passes. By mocking we are fixing behaviour and return values of the dependant code so that we can assert if the results are what we expect. The key principle of mocking is that we can exercise and examine the code that we need to test without executing the bits that are not being tested. To build the examples, you’ll need the CRM2011 SDK example plugins and Rhino Mocks 3.6 ( ). How to assert that the correct Organisation Service method was called with the desired values. ![]() ![]() How to assert that exceptions are raised by a plugin
0 Comments
Leave a Reply. |