@@ -36,6 +36,7 @@ void main() {
3636
3737 setUp (() {
3838 mockPlatform = MockFlutterSecureStoragePlatform ();
39+
3940 FlutterSecureStoragePlatform .instance = mockPlatform;
4041 storage = const FlutterSecureStorage ();
4142
@@ -232,6 +233,38 @@ void main() {
232233 ).called (1 );
233234 });
234235
236+ test ('deleteAll should call platform delete all method' , () async {
237+ when (
238+ () => mockPlatform.deleteAll (
239+ options: any (named: 'options' ),
240+ ),
241+ ).thenAnswer ((_) async {});
242+
243+ await storage.deleteAll ();
244+
245+ verify (
246+ () => mockPlatform.deleteAll (
247+ options: any (named: 'options' ),
248+ ),
249+ ).called (1 );
250+ });
251+
252+ test ('readAll should call platform read all method' , () async {
253+ when (
254+ () => mockPlatform.readAll (
255+ options: any (named: 'options' ),
256+ ),
257+ ).thenAnswer ((_) async => {testKey: testValue});
258+
259+ await storage.readAll ();
260+
261+ verify (
262+ () => mockPlatform.readAll (
263+ options: any (named: 'options' ),
264+ ),
265+ ).called (1 );
266+ });
267+
235268 test ('containsKey should return true if key exists' , () async {
236269 when (
237270 () => mockPlatform.containsKey (
@@ -270,6 +303,62 @@ void main() {
270303 });
271304 });
272305
306+ group ('Test FlutterSecureStorage Methods' , () {
307+ late TestFlutterSecureStoragePlatform storagePlatform;
308+ final initialData = < String , String > {'key1' : 'value1' , 'key2' : 'value2' };
309+
310+ setUp (() {
311+ storagePlatform = TestFlutterSecureStoragePlatform (Map .from (initialData));
312+ });
313+
314+ test ('reads a value' , () async {
315+ expect (await storagePlatform.read (key: 'key1' , options: {}), 'value1' );
316+ });
317+
318+ test ('returns null for non-existent key' , () async {
319+ expect (await storagePlatform.read (key: 'key3' , options: {}), isNull);
320+ });
321+
322+ test ('writes a value' , () async {
323+ await storagePlatform.write (key: 'key3' , value: 'value3' , options: {});
324+ expect (storagePlatform.data['key3' ], 'value3' );
325+ });
326+
327+ test ('containsKey returns true for existing key' , () async {
328+ expect (
329+ await storagePlatform.containsKey (key: 'key1' , options: {}),
330+ isTrue,
331+ );
332+ });
333+
334+ test ('containsKey returns false for non-existing key' , () async {
335+ expect (
336+ await storagePlatform.containsKey (key: 'key3' , options: {}),
337+ isFalse,
338+ );
339+ });
340+
341+ test ('deletes a value' , () async {
342+ await storagePlatform.delete (key: 'key1' , options: {});
343+ expect (storagePlatform.data.containsKey ('key1' ), isFalse);
344+ });
345+
346+ test ('deleteAll clears all data' , () async {
347+ await storagePlatform.deleteAll (options: {});
348+ expect (storagePlatform.data.isEmpty, isTrue);
349+ });
350+
351+ test ('readAll returns all key-value pairs' , () async {
352+ final allData = await storagePlatform.readAll (options: {});
353+ expect (allData, equals (initialData));
354+ });
355+
356+ test ('modifying data does not affect initial data map' , () async {
357+ await storagePlatform.write (key: 'key1' , value: 'newvalue1' , options: {});
358+ expect (initialData['key1' ], 'value1' );
359+ });
360+ });
361+
273362 group ('AndroidOptions Configuration Tests' , () {
274363 test ('Default AndroidOptions should have correct default values' , () {
275364 const options = AndroidOptions .defaultOptions;
0 commit comments