We have been using Moq for two months now. However, there is a problem that cannot be solved somehow.
In the visual studio, all the tests went well. The build server runs several tests. What they have in common is that they use the raise method to create an event. Our build server tests obfuscated what is good to find obfuscation errors. Each "normal" wait is like "Setup (something) .Returns (something)" works. Only the boost event does not fire. stacktrace is as follows:
MESSAGE: Test method Ade.Graphic.Presenter.Test.RoutingEngineTest.TestRouteOverLadderLinesWithFbd threw exception: System.ArgumentException: Could not locate event for attach or detach method Void α(α¦[α’]). +++++++++++++++++++ STACK TRACE: bei Moq.Extensions.GetEvent[TMock](Action`1 eventExpression, TMock mock) bei Moq.Mock`1.Raise(Action`1 eventExpression, EventArgs args) bei Ade.Graphic.Presenter.Test.RoutingEngineTest.TestRouteOverLadderLinesWithFbd()
Code for this:
documentEventHandler.Raise(stub => stub.DocumentChanged += null, new DocumentChangeEventArgs(DocumentChangeTypes.ViewUpdate));
We donβt know what is the difference between the above code and this
eventHandler.SetupGet(stub => stub.DocumentChangeNotify).Returns(documentEventHandler.Object);
because this code is working fine.
Has anyone had the same problem, or at least can tell what the difference is?
events moq obfuscation
Yggdrasil
source share