From 8a764feadc3226635632b5705f1d236911745a85 Mon Sep 17 00:00:00 2001 From: Juanita <114871036+JuanitaCathy@users.noreply.github.com> Date: Thu, 28 Dec 2023 11:58:22 +0530 Subject: [PATCH 1/4] Create test_Global.dart --- test/test_Global.dart | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/test_Global.dart diff --git a/test/test_Global.dart b/test/test_Global.dart new file mode 100644 index 0000000..4ee4cff --- /dev/null +++ b/test/test_Global.dart @@ -0,0 +1,46 @@ +import 'package:test/test.dart'; +import '../classes/Global.dart'; + +void main() { + group('Global', () { + test('Initial device list should be empty', () { + expect(Global.devices, isEmpty); + }); + + test('Initial connected devices list should be empty', () { + expect(Global.connectedDevices, isEmpty); + }); + + test('Initial nearbyService should be null', () { + expect(Global.nearbyService, isNull); + }); + + test('Initial subscription should be null', () { + expect(Global.subscription, isNull); + }); + + test('Initial receivedDataSubscription should be null', () { + expect(Global.receivedDataSubscription, isNull); + }); + + test('Initial messages list should not be empty', () { + expect(Global.messages, isNotEmpty); + }); + + test('Initial publicKeys map should be empty', () { + expect(Global.publicKeys, isEmpty); + }); + + test('Initial conversations map should be empty', () { + expect(Global.conversations, isEmpty); + }); + + test('Initial myName should be an empty string', () { + expect(Global.myName, isEmpty); + }); + + test('Initial cache map should be empty', () { + expect(Global.cache, isEmpty); + }); + }); +} From decf975f82c8adcfe895c0b96e101f033cb7a63a Mon Sep 17 00:00:00 2001 From: Juanita <114871036+JuanitaCathy@users.noreply.github.com> Date: Thu, 28 Dec 2023 11:59:23 +0530 Subject: [PATCH 2/4] edited test --- test/{test_Global.dart => classes_tests/test_global.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{test_Global.dart => classes_tests/test_global.dart} (100%) diff --git a/test/test_Global.dart b/test/classes_tests/test_global.dart similarity index 100% rename from test/test_Global.dart rename to test/classes_tests/test_global.dart From 93e855f2efaca02084b3283b68cfcd3e3ae75b8f Mon Sep 17 00:00:00 2001 From: Juanita <114871036+JuanitaCathy@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:05:02 +0530 Subject: [PATCH 3/4] Create test_msg.dart --- test/classes_tests/test_msg.dart | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/classes_tests/test_msg.dart diff --git a/test/classes_tests/test_msg.dart b/test/classes_tests/test_msg.dart new file mode 100644 index 0000000..c4d33b3 --- /dev/null +++ b/test/classes_tests/test_msg.dart @@ -0,0 +1,22 @@ +import 'package:test/test.dart'; +import '../classes/Msg.dart'; + +void main() { + group('Msg', () { + test('Initialization', () { + final msg = Msg("Test Message", "sent", "2023-01-01", "1"); + + expect(msg.message, "Test Message"); + expect(msg.msgtype, "sent"); + expect(msg.timestamp, "2023-01-01"); + expect(msg.id, "1"); + expect(msg.ack, "false"); + }); + + test('Acknowledgment Default Value', () { + final msg = Msg("Test Message", "sent", "2023-01-01", "1"); + + expect(msg.ack, "false"); + }); + }); +} From f90a6240e15314f74b79033bd12d8519d1cac29e Mon Sep 17 00:00:00 2001 From: Juanita <114871036+JuanitaCathy@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:11:10 +0530 Subject: [PATCH 4/4] Create test_payload.dart --- test/classes_tests/test_payload.dart | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/classes_tests/test_payload.dart diff --git a/test/classes_tests/test_payload.dart b/test/classes_tests/test_payload.dart new file mode 100644 index 0000000..5173722 --- /dev/null +++ b/test/classes_tests/test_payload.dart @@ -0,0 +1,25 @@ +import 'package:test/test.dart'; +import '../classes/Payload.dart'; + +void main() { + group('Payload and Ack Tests', () { + test('Payload Initialization', () { + final payload = Payload("1", "sender", "receiver", "message", "timestamp"); + + expect(payload.id, "1"); + expect(payload.sender, "sender"); + expect(payload.receiver, "receiver"); + expect(payload.message, "message"); + expect(payload.timestamp, "timestamp"); + expect(payload.broadcast, true); + expect(payload.type, "Payload"); + }); + + test('Ack Initialization', () { + final ack = Ack("1"); + + expect(ack.id, "1"); + expect(ack.type, "Ack"); + }); + }); +}