I try to assert like this, including a type:
verify <@dbContext.Add<SurveyDto>(any())@> once
or like this without one:
verify <@dbContext.Add(any())@> once
Either way I get a failure with
"System.TypeLoadException : GenericArguments[0], 'a', on 'Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry`1[TEntity]' violates the constraint of type parameter 'TEntity'."
Description
any() comparison fails with constrained generics
Repro steps
I am trying to set up a method on my mock EntityFramework context:
member this.UpdateExisting<'a when 'a: not struct> (existing, updated) = base.Entry<'a>(existing).CurrentValues.SetValues(updated)
my mocked context is set up as so ( I have to use Moq for the DbSet as Foq's type checking is too strict) :
let dtos : Moq.Mock<DbSet<SurveyDto>> = [] |> Helpers.getQueryableMockDbSet
let dbContext = Mock<IDatabaseContext>() .Setup(fun ctx -> <@ ctx.Surveys @>) .Returns(dtos.Object) .Create()
I try to assert like this, including a type:
verify <@dbContext.Add<SurveyDto>(any())@> once
or like this without one:verify <@dbContext.Add(any())@> once
Either way I get a failure with "System.TypeLoadException : GenericArguments[0], 'a', on 'Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry`1[TEntity]' violates the constraint of type parameter 'TEntity'."