开发者

Is it possible to mock Activator.GetObject()?

开发者 https://www.devze.com 2023-01-13 17:30 出处:网络
I am trying to write a unit test for a method that uses a .net remoting object. The remoting object is created by using Activator.GetObject(typeof(myRemotingObje开发者_运维问答ctType), uri);

I am trying to write a unit test for a method that uses a .net remoting object.

The remoting object is created by using Activator.GetObject(typeof(myRemotingObje开发者_运维问答ctType), uri);

During runtime, the uri is server ip address of the remoting object.

Since I want to write a unit test, I don't want to initialize any .Net remoting to slowdown the test if possible.

Thanks


I would suggest wrapping it and have the wrapper implement an interface. You can then swap the wrapper with a mock equivalent for testing purposes.

0

精彩评论

暂无评论...
验证码 换一张
取 消