-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8934c40
commit 7934bf2
Showing
3 changed files
with
491 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/noports_core/test/sshnp/util/sshnpd_channel/sshnpd_channel_mocks.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:at_client/at_client.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:noports_core/sshnp_foundation.dart'; | ||
|
||
abstract class HandleSshnpdPayloadCaller { | ||
Future<SshnpdAck> call(AtNotification notification); | ||
} | ||
|
||
class HandleSshnpdPayloadStub extends Mock | ||
implements HandleSshnpdPayloadCaller {} | ||
|
||
class StubbedSshnpdChannel extends SshnpdChannel { | ||
final Future<void> Function(AtKey, String)? _notify; | ||
final Stream<AtNotification> Function({String? regex, bool shouldDecrypt})? | ||
_subscribe; | ||
final Future<SshnpdAck> Function(AtNotification notification)? | ||
_handleSshnpdPayload; | ||
|
||
StubbedSshnpdChannel({ | ||
required super.atClient, | ||
required super.params, | ||
required super.sessionId, | ||
required super.namespace, | ||
Future<void> Function(AtKey, String)? notify, | ||
Stream<AtNotification> Function({String? regex, bool shouldDecrypt})? | ||
subscribe, | ||
Future<SshnpdAck> Function(AtNotification notification)? | ||
handleSshnpdPayload, | ||
}) : _notify = notify, | ||
_subscribe = subscribe, | ||
_handleSshnpdPayload = handleSshnpdPayload; | ||
|
||
@override | ||
Future<SshnpdAck> handleSshnpdPayload(AtNotification notification) async { | ||
return await _handleSshnpdPayload?.call(notification) ?? | ||
SshnpdAck.notAcknowledged; | ||
} | ||
|
||
@override | ||
Future<void> notify( | ||
AtKey atKey, | ||
String value, | ||
) async { | ||
return _notify?.call(atKey, value); | ||
} | ||
|
||
@override | ||
Stream<AtNotification> subscribe({ | ||
String? regex, | ||
bool shouldDecrypt = false, | ||
}) { | ||
return _subscribe?.call(regex: regex, shouldDecrypt: shouldDecrypt) ?? | ||
Stream.empty(); | ||
} | ||
} | ||
|
||
class MockRemoteSecondary extends Mock implements RemoteSecondary {} |
Oops, something went wrong.