.NET 1.0.1 Unit test strategy #4575
Replies: 3 comments
-
Does anyone know how to setup the mock for InvokeAsync? this.kernelMock.Setup(k => k.InvokeAsync(It.IsAny(), It.IsAny())).ReturnsAsync(It.IsAny()); this is throwing an error and I am not able to mock the call. |
Beta Was this translation helpful? Give feedback.
-
Per @markwallace-microsoft guidance on #4589, you can take a look at our existing unit tests here for KernelFunctionFromMethodTests1.cs For your use case you can mock the AI service and add that to the Kernel you use in your unit tests. We're going to take a look at providing guidance around unit testing. |
Beta Was this translation helpful? Give feedback.
-
@jimmy-vo-librestream @pratibw Here is a blog post about unit testing of Semantic Kernel components: Hope it will help! |
Beta Was this translation helpful? Give feedback.
-
I am working on upgrading 1.0.0-beta8 to 1.0.1, and I found it is not possible to mock Kenel, Function, or Pluggin. For example I have an extension function that my business logic calling to:
In 1.0.0-beta8, I was able to mock
ISKFunction
,IReadOnlyFunctionCollection
, andIKernel
. But they are removed in 1.0.1.KernelFunction
is now an abstract class with internal constructor, so there is no way I can create aMockKernelFunction
that wraps KernelFunction and overridesValueTask<FunctionResult> InvokeCoreAsync(Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)
.I am currious how you guys do it?
Beta Was this translation helpful? Give feedback.
All reactions