Comments (4)
How would you unit test the TcpListener class? :)
This is a component that you should use to fulfil your contracts without exposing it, and without leaking its implementation details to other parts of your application.
This component is already unit tested, and in your tests, you should mock whatever implementation uses it.
from websocketlistener.
I don't want to unit test your library which as you said is already unit tested.
My idea was more like having the WebSocketListener implement a IWebSocketListener interface I could mock in my unit tests. Right now the WebSocketListener is sealed and has no virtual methods so it's hard for me to simulate a case where for example the ReadStringAsync method returns a specific string I'm looking for...
from websocketlistener.
Just think about WebSocketListener
like you would do about TcpListener
. The right way of using it, is to have a wrapper class that implements one of your interfaces. That interface can be mocked and they you can test what happens when you receive a specific string. If in the future, you want to move to System.Net.WebSockets
, you would just create a new implementation of your custom interface, and replace the one that wraps WebSocketListener
; then you would have no dependency on my interfaces.
Cheers.
from websocketlistener.
yeah that's what i've done, it's just more painful.
TcpListener inability to be mocked is an issue, not a feature though :)
I'll mark this issue as solved.
from websocketlistener.
Related Issues (20)
- I am trying to upgrade from V2.2.0.1 to V3.0.0 but it errors out. HOT 5
- Does WebSocketListener work with the HoloLens (UWP)? HOT 1
- V3.0.0 does not work with Mono v4.6.2 HOT 3
- How to bypass CORS? HOT 1
- IOException Issues Randomly HOT 1
- IE Origin HOT 2
- WSS Configuration HOT 2
- On quick client disconnect, ObjectDisposedException being thrown HOT 1
- WebSocketMessageReadNetworkStream can only start with a Text or Binary frame, not Continuation HOT 2
- WebSocketHandshaker.ParseWebSocketProtocol throws a NullReferenceException HOT 1
- Server does not detect broken link on linux
- TLS 1.2 is not supported HOT 1
- Cannot understand frame header exception when receiving messages from Javascript HOT 5
- SSL Deserialize Message not working HOT 4
- How to use OnHttpNegotiation in 3.0.0
- Is there a sample including Authentication? HOT 1
- Some Information about Client HOT 1
- Try to Secure WebSocket: Unknow error while processing the certificate
- Is WebSocketListener good enough out of the box for video streaming? HOT 2
- Websocket Listener is able to accept incoming data from Client but Websocket Listener thinks connection with client is closed. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websocketlistener.