pex-and-moles

Has anyone made moles work properly?

℡╲_俬逩灬. 提交于 2019-12-06 11:40:09
I was trying to find a consistent description on how to use moles isolation framework but haven't found much on this topic. So far i did the following: Download moles from here (x86 version). Install it. Here guy describes how to use it with custom library. So i added moles assembly for my own library. After rebuild the assembly appeared in references. Then i tried to add using of .Moles namespace and build the project but it failed with bunch of errors. Example with MDateTime didn't work either. MDateTime just didn't have any method. Considering that was 5th failed attempt to get it work i

Moling DataContext with MS Moles?

老子叫甜甜 提交于 2019-12-06 02:05:39
问题 How can I mole the DataContext that I'm using in a class to write messages to a table. I'd like to assert that the table LINQ is writing to has the expected count of messages. Here's what i have so far. var context = new MJustTestingDataContext(); MyMessagewriter writer = new MyMessageWriter(context); var messageList = new List<MIncmoingMessage>(); MTable<MIncomingMessage> messageTable = new MTable<MIncomingMessage>(); messageTable.Bind(messagesLinqList.AsQueryable()); If I use this code with

What to put as the Provider for a mocked IQueryable

巧了我就是萌 提交于 2019-12-04 09:25:36
I am working with Moles and mocking a System.Data.Linq.Table. I got it constructing fine, but when I use it, it wants IQueryable. Provider to be mocked (moled) as well. I just want it to use normal Linq To Objects. Any idea what that would be? Here is the syntax I can use: MTable<User> userTable = new System.Data.Linq.Moles.MTable<User>(); userTable.Bind(new List<User> { UserObjectHelper.TestUser() }); // this is the line that needs help MolesDelegates.Func<IQueryProvider> provider = //Insert provider here! ^ userTable.ProviderSystemLinqIQueryableget = provider | | | what can I put here? -----

Moling DataContext with MS Moles?

こ雲淡風輕ζ 提交于 2019-12-04 05:36:16
How can I mole the DataContext that I'm using in a class to write messages to a table. I'd like to assert that the table LINQ is writing to has the expected count of messages. Here's what i have so far. var context = new MJustTestingDataContext(); MyMessagewriter writer = new MyMessageWriter(context); var messageList = new List<MIncmoingMessage>(); MTable<MIncomingMessage> messageTable = new MTable<MIncomingMessage>(); messageTable.Bind(messagesLinqList.AsQueryable()); If I use this code with xUnit in my class under test I'll get this exception Microsoft.Moles.Framework.Moles

Moles and SharePoint Behaviour types

随声附和 提交于 2019-12-01 23:42:11
We are having problems with the following code: BSPSite site = new BSPSite(); BSPWeb web = site.SetRootWeb(); The error is : Could not load file or assembly 'System.Moles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0ae41878053f6703' or one of its dependencies. The system cannot find the file specified. We have tried rebuilding the Behavoir assembly in the source code to .NET 4 but that didn't go through. We are using v0.94. Any help would be appreciates. kaloyan 1) Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies 2 ) Find Microsoft.Moles.VsHost.x86

Using Moles with DateTime

痞子三分冷 提交于 2019-11-30 22:01:08
I'm starting to using Moles in unit tests and am struggling a little with documentation. I want to mole DateTime.Now. If you look around the old way of doing this was to add a reference to mscorlib, then add a stubx file for it (Add New Item -> Stubs And Moles For Testing). The 'Stubs and Moles for Testing' template has been deprecated, instead all you need do is to right click a reference and select 'Add moles assembly', whch is fine. VS2010 does not allow you to add a reference directly to mscorlib, because we have a reference to "System", this is ok as I can see DateTime in object browser

Integrate Pex with MoQ

廉价感情. 提交于 2019-11-30 07:55:41
Can anyone point me to a resource that shows an example of how Pex can be used in conjunction with MoQ? Thanks Pex uses Moles for isolation (mocking). One can still use MoQ alongside Moles. It's actually preferred to use a framework like MoQ for stubbing and mocking when the code can allow for it, leaving only Moles for the stuff MoQ can't isolate (sealed classes, non-virtual methods, private members, etc). To backup my statements, Peli de Halleux (a member of the Pex and Moles project), mentions doing the same thing over on MSDN forums . I have been using Moles and you can code with both

Integrate Pex with MoQ

穿精又带淫゛_ 提交于 2019-11-29 10:24:21
问题 Can anyone point me to a resource that shows an example of how Pex can be used in conjunction with MoQ? Thanks 回答1: Pex uses Moles for isolation (mocking). One can still use MoQ alongside Moles. It's actually preferred to use a framework like MoQ for stubbing and mocking when the code can allow for it, leaving only Moles for the stuff MoQ can't isolate (sealed classes, non-virtual methods, private members, etc). To backup my statements, Peli de Halleux (a member of the Pex and Moles project),

C# - What does “\\0” equate to?

廉价感情. 提交于 2019-11-27 15:00:06
I am playing with Pex and one of the parameters it passes into my method is "\0" . What does that mean? My guess is an empty string ( "" ) based on the content of my method. However, if it is the same then why not just use "" instead of "\0" ? Anyone know what it is? '\0' is a " null character ". It's used to terminate strings in C and some portions of C++. Pex is doing a test to see how your code handles the null character, likely looking for the Poison Null Byte security exploit. Most C# code has nothing to fear; if you pass your string to unmanaged code, however, you may have problems. Edit

C# - What does “\0” equate to?

吃可爱长大的小学妹 提交于 2019-11-26 16:58:33
问题 I am playing with Pex and one of the parameters it passes into my method is "\0" . What does that mean? My guess is an empty string ( "" ) based on the content of my method. However, if it is the same then why not just use "" instead of "\0" ? Anyone know what it is? 回答1: '\0' is a "null character". It's used to terminate strings in C and some portions of C++. Pex is doing a test to see how your code handles the null character, likely looking for the Poison Null Byte security exploit. Most C#