Has anyone had success in building a Mocking Library to mimic the SLProtocol/SLProtocolExt for unit testing for protocol development?
Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 7th July 2023
Hi Rebecca!
We have some videos explaining how to do unit tests and in this part we go through the process of mocking the SLProtocol.
You can watch the video or read a bit of the explanation.
Mainly, I use the Moq library as the example here:
[TestMethod()] public void Rewrite_PathWithItemsToAbbreviate_ReturnsAbbreviatedPath() { // Arrange PathRewriter pathRewriter = new PathRewriter(); string path = @"Visios\Customers\Skyline\Protocols\Test"; string expected = @"V\C\Skyline\P\Test"; var fakeSlProtocol = new Mock<SLProtocol>(); // Act string result = pathRewriter.Rewrite(fakeSlProtocol.Object, path); // Assert Assert.AreEqual(expected, result); }
Hope that helps!
Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 7th July 2023
Thank you for your answer. We are already using Moq similar to the above but, we were hoping somebody had already built an independant helper library that mocked things like the NotifyProtocol to help with validating table calls that are represented as object arrays which can be hard to write mocks for.