Reputation: 6021
I'm trying to set up a unit test of a method that takes a SocketAsyncEventArgs, ie one of the IOCP functions from the Sockets class.
In order to shove one of these classes into my function, I need to change the .BytesTransferred property of the SAEA. How does one do this? I tried to use a PrivateObject.SetFieldOrProperty, but it tell me it's unable to find the property:
pargs.SetFieldOrProperty("BytesTransferred", expected);
I get the following exception: "Method 'System.Net.Sockets.SocketAsyncEventArgs.BytesTransferred' not found."
Upvotes: 1
Views: 364
Reputation: 171236
This property does not have a setter. Two solutions:
Solution #2 would make me nervous. I'd go with #1.
Upvotes: 3