Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Problem using NCrunch with FSharp.Data.SqlClient
simonhdickson
#1 Posted : Thursday, October 30, 2014 10:10:20 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/30/2014(UTC)
Posts: 1
Location: United Kingdom

In my test I'm trying to mock out database access which I'm using the F# Sql Command type provider for. The project with the type provider code in builds fine in NCrunch. But when I try to create an instance of the record in my test project, the test project doesn't build in NCrunch (it builds normally with VS & msbuild and runs fine in the standard xnunit test runner).

To give a minimum example:

Code:

// In Data Project
type MyQuery = SqlCommandProvider<"SELECT hello FROM dbo.world", connectionString>

// In Test Project
[<Fact>]
let test () =
    MyQuery.Record("hello") |> ignore


System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
at System.Reflection.AssemblyName..ctor(String assemblyName)
at Gallio.Common.Reflection.Impl.CecilReflectionPolicy.GetAssemblyReferences(StaticAssemblyWrapper assembly)
at Gallio.Common.Reflection.Impl.StaticAssemblyWrapper.<GetReferencedAssemblies>b__2()
at Gallio.Common.Memoizer`1.Memoize(Func`1 populator)
at Gallio.Common.Reflection.Impl.StaticAssemblyWrapper.GetReferencedAssemblies()
at Gallio.Model.DefaultTestFrameworkManager.SelectTestFrameworksForCodeElementsImpl(IEnumerable`1 filteredTestFrameworkHandlesWithoutFallback, TestFrameworkFallbackMode testFrameworkFallbackMode, TestFrameworkOptions testFrameworkOptions, IEnumerable`1 codeElements)
at Gallio.Model.DefaultTestFrameworkManager.FilteredTestDriver.DescribeImpl(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at Gallio.Model.BaseTestDriver.Describe(IReflectionPolicy reflectionPolicy, IList`1 codeElements, TestExplorationOptions testExplorationOptions, IMessageSink messageSink, IProgressMonitor progressMonitor)
at nCrunch.Module.Gallio.Integration.GallioWrapper.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths)
at nCrunch.Module.Gallio.Integration.GallioTestFramework.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName)
at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, TestFrameworkDescription[] frameworks, ComponentUniqueName testComponentUniqueName)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.DiscoverTests(TestFrameworkDescription[] applicableTestFrameworks, ComponentUniqueName testComponentUniqueName)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters , FilePath , BuildOutput , DirectoryPath[] , FilePath[] )
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)
Remco
#2 Posted : Thursday, October 30, 2014 11:10:21 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

Thanks for sharing this issue. NCrunch does have some known compatibility problems with FSharp type providers. There are ways you can work around these issues - see http://forum.ncrunch.net/yaf_postst1203_Making-NCRUNCH-aware-of-additional-reference--for-which-there-is-no-code--just-dlls.aspx for more information.

The error you're receiving is coming from the static analysis code invoked by Gallio to discover tests. It's possible that you won't see this for other test frameworks .. and I do hold a hope that the above type provider workaround may solve the issue. Let me know how you get on. If you still see the error with the workaround in place, I may need to ask for a sample solution to help reproduce the problem in order to understand it better.


Cheers,

Remco
the_joric
#3 Posted : Tuesday, December 23, 2014 2:39:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/23/2014(UTC)
Posts: 1
Location: Ukraine

Hi,

I encountered the same problem (first missing *.DesignTime.dll and now -- HResult). I've also put a sample solution to github: https://github.com/skali.../ncrunch-type-providers
It uses VS2013 Community and NCrunch 2.10.0.4.
Could you please take a look?

Thanks :)
Remco
#4 Posted : Tuesday, December 23, 2014 9:13:05 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing the sample solution! I'll take a look and will get back to you :)


Cheers,

Remco
Remco
#5 Posted : Friday, January 9, 2015 3:15:47 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, just an update on this one...

This looks to be caused by some strange structural problems around how the assembly references are being physically declared inside the test assembly.

The problem doesn't appear if you set your 'Framework utilisation type for Gallio/Xunit' to 'DynamicAnalysis' - This is a solution-level NCrunch configuration option. I hope that adjusting this setting will allow you to work around the problem.

Alternatively you can also look towards using a later version of Xunit. Xunit V2 is in an advanced beta state and it is also supported by NCrunch.

I'm implementing a fix for this problem that will allow NCrunch to function normally with the Static Analysis enabled. This will be included in the full release of 2.11.

Sorry for the time it's taken to get back to you on this one.


Cheers,

Remco
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.064 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download