-
I'm currently working on a solution that uses Yarp as a reverse proxy. And we have implemented a TransformProvider which has a fair amount of logic that needs to be unit tested. I could test that by mocking a lot, if not all, of its dependencies. But then I'm mimicking a lot of existing Yarp code. I prefer to test the TransformProvider by "arranging" the Yarp cluster en routes configuration. And then create a host and a client, and call an api using the client. So I can do some assertions to see that the TransformProvider is doing the right thing. What I'm looking for is guidance on how to properly unit or integration test, in this case, the TransformProvider. And in general how to unit test the custom code that is used for Yarp configuration. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I'd say it depends on what your transforms are doing. E.g. it might be as simple as something along the lines of In most cases it's also simple to create fake request objects ( If you really need to test the end-to-end behavior, YARP itself uses this |
Beta Was this translation helpful? Give feedback.
I'd say it depends on what your transforms are doing. E.g. it might be as simple as something along the lines of
reverse-proxy/test/ReverseProxy.Tests/Transforms/PathStringTransformTests.cs
Lines 12 to 25 in 69acefb