Telerik Forums
JustMock Forum
6 answers
244 views
I am evaluating the framework for mocking the IPluginExecutionContext interface that is critical to mocking Microsoft Crm Plug-ins.  This is a good test of the framework because on the same interface, I need a dictionary property to essentially be stubbed and then some methods to be mocked.  Also the property can use indexers to get to the values and there is only a getter for the interface, so I cannot just set the property to a new dictionary (actually the class is a custom Crm class called PropertyBag, but is similar to a dictionary).

I receive the error:
Test method Ryland.Crm.Plugins.Tests.ContactRequiredFieldsPluginTest.ExecuteRequiredFieldTelerikTest threw exception System.AccessViolationException, but exception Microsoft.Crm.Sdk.InvalidPluginExecutionException was expected. Exception message:  System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Telerik.DynamicProxy.ProxyFactory.Create()
Telerik.DynamicProxy.Fluent.FluentProxy.NewInstance()
Telerik.DynamicProxy.Proxy.Create(Type target, Action`1 action)
ctor(Type target, BehaviorMode mode, Object[] args)
Telerik.JustMock.Mock.Create(Type target, BehaviorMode mode, Object[] args)
Telerik.JustMock.Mock.Create(Type target, Object[] args)
Telerik.JustMock.Mock.Create[T]()
Ryland.Crm.Plugins.Tests.ContactRequiredFieldsPluginTest.ExecuteRequiredFieldTelerikTest() in C:\projects\RylandStandards\RylandStandards\tests\Ryland.Crm.Plugins.Tests\ContactRequiredFieldsPluginTest.cs: line 58


My code is below.  Also note I am running on a Hyper-V Guest and do have references to other Mocking frameworks in the project since I am comparing and contrasting Rhino Mocks, Moq and JustMock.  I have JustMock enabled.  The Microsoft Crm sdk contains the IPluginExecutionContext and only the sdk is needed to test this scenario, not Crm.

If the syntax below works for this test, I will definitely recommend this framework.  The simplicity is great compared to RhinMocks and slightly better than Moq.  Understanding the API is important to adoption and the ability to avoid needing different calls for stubbing or mocking is very nice.  I also am assuming the typical Create will essentially cause properties to behave like simple get/set properties without any setup.

///

 

<summary>

 

 

///

 

 

///</summary>

 

[

TestMethod()]

 

[

ExpectedException(typeof(InvalidPluginExecutionException))]

 

 

public void ExecuteRequiredFieldTelerikTest()

 

{

 

 

 

ContactRequiredFieldsPlugin target = new ContactRequiredFieldsPlugin(string.Empty, string.Empty);

 

 

var context = TelerikMock.Mock.Create<IPluginExecutionContext>(); //!!!!!!!!! Fails here

 

 

var service = TelerikMock.Mock.Create<ICrmService>();

 

 

TelerikMock.Mock.Arrange(() => context.CreateCrmService(true)).Returns(service);

 

 

DynamicEntity

 

entity = new DynamicEntity(EntityName.contact.ToString());

 

entity.Properties.Add(

new StringProperty("telephone1", ""));

 

entity.Properties.Add(

new StringProperty("emailaddress1", ""));

 

 

 

context.InputParameters[

ParameterName.Target] = entity;

 

target.Execute(context);

 

 

}

Chris
Telerik team
 answered on 19 Apr 2010
3 answers
256 views
Hello.

I'm currently trying out JustMock to make a SharePoint Unit test.
However I have difficulties mocking SPSite and SPWeb objects.
Any advice?

The method that I'm trying to mock is roughly as follows:
SPSite site = SPContext.Current.Site; 
SPSecurity.RunWithElevatedPrivileges(delegate() { 
    using (SPSite mysite = new SPSite(site.ID)) { 
        using (SPWeb myweb = mysite.OpenWeb()) { 
            SPList = myweb.Lists["List_Name"]; 
            // do something else 
        } 
    } 
}); 
Ricky
Telerik team
 answered on 18 Apr 2010
1 answer
86 views
Can these two be used together? Because normally when creating objects in an OpenAccess project you need to start transactions and data is automatically saved to the database.
Ricky
Telerik team
 answered on 16 Apr 2010
1 answer
175 views
I'm trying to mock instances of WebClient. How can I invoke an event, say DownloadDataCompleted?


Ricky
Telerik team
 answered on 15 Apr 2010
1 answer
173 views
My company uses TypeMock as our isolation tools in our unit tests. The great thing about TypeMock is that it has almost no limitation on what it can mock. This freedom however comes from a design choice that is also the greates weakness of TypeMock: it is a Profiler.

The problem we have is that since the .NET CLR can only have one profiler attached at a time, other profilers must go through TypeMock to work. For another profiler to work while TypeMock is running it must be supported by TypeMock. This is a problem when new versions of profilers are released, like the 4.0 version of dotTrace, or when a great profiler isn't supported at all, like Ants from red gate. I'd like to choose which profiler to use based on price, features and how it suits my needs, not based on which one TypeMock likes.

Also, since TypeMock works as profiler and intercepts and alters calls by using the profiling API it can have some pretty odd bugs. Like, for example, it will crash if you try to isolate a call using the Microsoft Entlib Data block in an x64 process.

My three questions about JustMock are:
1. Is it also a "profiler"'?
2. If JustMock is also a profiler, how have you solved the issues with it working together with other profilers?
3. If JustMock is also a profiler, will you strive to make it just as stable in an x64 process as in an x86 process?
Chris
Telerik team
 answered on 15 Apr 2010
1 answer
123 views
Hi
what is the roadmap for JustMock?
Is JustMock going into the .net bundle or as seperate product?
Thanks
Adiel
Chris
Telerik team
 answered on 14 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?