❔ Unit Test | Mocking class with unsafe methods
Hi, I am having trouble writing unit tests, because I dont know how to mock/setup the underlying instance/its methods.
The class
This would be one of the methods I need to mock:
(instead of
I tried using Moq, but I run into errors for the null pointer and count parameter:
Any idea how to do that?
The class
Silk.NET.OpenCL.CL (https://github.com/dotnet/Silk.NET/blob/main/src/OpenCL/Silk.NET.OpenCL/CL.gen.cs) does not implement an interface and the methods are unsafe and non virtual.This would be one of the methods I need to mock:
(instead of
out uint num_platforms I could also use uint* num_platforms, if that matters)I tried using Moq, but I run into errors for the null pointer and count parameter:
CS1944: An expression tree may not contain an unsafe pointer operation( I tried also other libraries like Pose, but they all use
CS8198: An expression tree may not contain an out argument variable declaration
System.Linq.Expressions.Expression so I always ran into the same errors)Any idea how to do that?