1package com.example.food_front.utils;
3import android.content.Context;
4import android.content.SharedPreferences;
6import org.junit.Before;
8import org.junit.runner.RunWith;
9import org.mockito.Mock;
10import org.mockito.junit.MockitoJUnitRunner;
12import static org.junit.Assert.*;
13import static org.mockito.ArgumentMatchers.anyInt;
14import static org.mockito.ArgumentMatchers.anyString;
15import static org.mockito.ArgumentMatchers.eq;
16import static org.mockito.Mockito.verify;
17import static org.mockito.Mockito.when;
22@RunWith(MockitoJUnitRunner.class)
29 SharedPreferences mockSharedPreferences;
32 SharedPreferences.Editor mockEditor;
37 when(mockContext.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPreferences);
38 when(mockSharedPreferences.edit()).thenReturn(mockEditor);
39 when(mockEditor.putString(anyString(), anyString())).thenReturn(mockEditor);
45 when(mockContext.getPackageName()).thenReturn(
"com.example.food_front");
51 assertNotNull(result);
52 assertFalse(result.isEmpty());
55 assertTrue(result.containsKey(
"device_model"));
56 assertTrue(result.containsKey(
"device_manufacturer"));
57 assertTrue(result.containsKey(
"android_version"));
58 assertTrue(result.containsKey(
"api_level"));
59 assertTrue(result.containsKey(
"payment_server"));
65 when(mockContext.getPackageName()).thenReturn(
"com.example.food_front");
71 assertNotNull(report);
72 assertTrue(report.contains(
"DIAGNÓSTICO"));
73 assertTrue(report.contains(
"DISPOSITIVO"));
74 assertTrue(report.contains(
"APLICACIÓN"));
75 assertTrue(report.contains(
"SERVIDOR"));
86 when(mockContext.getPackageName()).thenReturn(
"com.example.food_front");
static Map< String, String > collectDiagnosticInfo(Context context)
static void logDiagnosticInfo(Context context)
static String generateDiagnosticReport(Context context)
void collectDiagnosticInfo_returnsNonEmptyMap()
void generateDiagnosticReport_containsExpectedSections()
void logDiagnosticInfo_callsCollectDiagnosticInfo()