Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. @isTest
  2. public with sharing class Some_Test {
  3. private static final Map<String, String> lang2key = new Map<String, String>{'English' => 'en_US', 'Japanese' => 'ja', 'Simplefied_Chinese' => 'zh_CN'};
  4.  
  5. private static User setLang(String lang) {
  6. User me = [SELECT Id, LanguageLocaleKey FROM USER WHERE Id = :UserInfo.getUserId() LIMIT 1];
  7. me.LanguageLocaleKey = lang2key.get(lang);
  8. update me;
  9. return me;
  10. }
  11.  
  12. @isTest static void testGetSomeLabel() {
  13. Test.startTest();
  14.  
  15. System.runAs(Some_Test.setLang('English')) {
  16. // getSomeLabel(String key) returns key's label.
  17. String someLabel = Some.getSomeLabel('key');
  18. System.assertEquals('Key', someLabel, 'label is not correct');
  19. }
  20.  
  21. System.runAs(Some_Test.setLang('Japanese')) {
  22. // getSomeLabel(String key) returns key's label.
  23. String someLabel = Some.getSomeLabel('key');
  24. System.assertEquals('キー', someLabel, 'ラベルが正しくありません');
  25. }
  26.  
  27. Test.stopTest();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement