public void TestCoverage() { // Key IBM.ICU.Impl.ICUService.Key key = new IBM.ICU.Impl.ICUService.Key("foobar"); Logln("ID: " + key.Id()); Logln("canonicalID: " + key.CanonicalID()); Logln("currentID: " + key.CurrentID()); Logln("has fallback: " + key.Fallback()); // SimpleFactory Object obj = new Object(); IBM.ICU.Impl.ICUService.SimpleFactory sf = new IBM.ICU.Impl.ICUService.SimpleFactory(obj, "object"); try { sf = new IBM.ICU.Impl.ICUService.SimpleFactory(null, null); Errln("didn't throw exception"); } catch (ArgumentException e) { Logln("OK: " + e.Message); } catch (Exception e_0) { Errln("threw wrong exception" + e_0); } Logln(sf.GetDisplayName("object", null)); // ICUService ICUService service = new ICUService(); service.RegisterFactory(sf); try { service.Get(null, null); Errln("didn't throw exception"); } catch (NullReferenceException e_1) { Logln("OK: " + e_1.Message); } /* * catch (Exception e) { errln("threw wrong exception" + e); } */ try { service.RegisterFactory(null); Errln("didn't throw exception"); } catch (NullReferenceException e_2) { Logln("OK: " + e_2.Message); } catch (Exception e_3) { Errln("threw wrong exception" + e_3); } try { service.UnregisterFactory(null); Errln("didn't throw exception"); } catch (NullReferenceException e_4) { Logln("OK: " + e_4.Message); } catch (Exception e_5) { Errln("threw wrong exception" + e_5); } Logln("object is: " + service.Get("object")); Logln("stats: " + service.Stats()); // ICURWLock ICURWLock rwlock = new ICURWLock(); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); Logln("stats: " + rwlock.ClearStats()); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); try { rwlock.ReleaseRead(); Errln("no error thrown"); } catch (InvalidOperationException e_6) { Logln("OK: " + e_6.Message); } try { rwlock.ReleaseWrite(); Errln("no error thrown"); } catch (InvalidOperationException e_7) { Logln("OK: " + e_7.Message); } // ICULocaleService // LocaleKey // LocaleKey lkey = LocaleKey.create("en_US", "ja_JP"); // lkey = LocaleKey.create(null, null); IBM.ICU.Impl.ICULocaleService.LocaleKey lkey = IBM.ICU.Impl.ICULocaleService.LocaleKey .CreateWithCanonicalFallback("en_US", "ja_JP"); Logln("lkey: " + lkey); lkey = IBM.ICU.Impl.ICULocaleService.LocaleKey.CreateWithCanonicalFallback(null, null); Logln("lkey from null,null: " + lkey); // LocaleKeyFactory IBM.ICU.Impl.ICULocaleService.LocaleKeyFactory lkf = new ICUServiceTest.LKFSubclass(false); Logln("lkf: " + lkf); Logln("obj: " + lkf.Create(lkey, null)); Logln(lkf.GetDisplayName("foo", null)); Logln(lkf.GetDisplayName("bar", null)); lkf.UpdateVisibleIDs(new Hashtable()); IBM.ICU.Impl.ICULocaleService.LocaleKeyFactory invisibleLKF = new ICUServiceTest.LKFSubclass(false); Logln("obj: " + invisibleLKF.Create(lkey, null)); Logln(invisibleLKF.GetDisplayName("foo", null)); Logln(invisibleLKF.GetDisplayName("bar", null)); invisibleLKF.UpdateVisibleIDs(new Hashtable()); // ResourceBundleFactory IBM.ICU.Impl.ICULocaleService.ICUResourceBundleFactory rbf = new IBM.ICU.Impl.ICULocaleService.ICUResourceBundleFactory(); Logln("RB: " + rbf.Create(lkey, null)); // ICUNotifier ICUNotifier nf = new ICUServiceTest.ICUNSubclass(); try { nf.AddListener(null); Errln("added null listener"); } catch (NullReferenceException e_8) { Logln(e_8.Message); } catch (Exception e_9) { Errln("got wrong exception"); } try { nf.AddListener(new ICUServiceTest.WrongListener()); Errln("added wrong listener"); } catch (InvalidOperationException e_10) { Logln(e_10.Message); } catch (Exception e_11) { Errln("got wrong exception"); } try { nf.RemoveListener(null); Errln("removed null listener"); } catch (NullReferenceException e_12) { Logln(e_12.Message); } catch (Exception e_13) { Errln("got wrong exception"); } nf.RemoveListener(new ICUServiceTest.MyListener()); nf.NotifyChanged(); nf.AddListener(new ICUServiceTest.MyListener()); nf.RemoveListener(new ICUServiceTest.MyListener()); }
public void TestCoverage() { // Key Key key = new Key("foobar"); Logln("ID: " + key.ID); Logln("canonicalID: " + key.CanonicalID); Logln("currentID: " + key.CurrentID); Logln("has fallback: " + key.Fallback()); // SimpleFactory object obj = new object(); SimpleFactory sf = new SimpleFactory(obj, "object"); try { sf = new SimpleFactory(null, null); Errln("didn't throw exception"); } catch (ArgumentException e) { Logln("OK: " + e.ToString()); } catch (Exception e) { Errln("threw wrong exception" + e); } Logln(sf.GetDisplayName("object", null)); // ICUService ICUService service = new ICUService(); service.RegisterFactory(sf); try { service.Get(null, null); Errln("didn't throw exception"); } catch (ArgumentNullException e) { Logln("OK: " + e.ToString()); } /* * catch (Exception e) { * Errln("threw wrong exception" + e); * } */ try { service.RegisterFactory(null); Errln("didn't throw exception"); } catch (ArgumentNullException e) { Logln("OK: " + e.ToString()); } catch (Exception e) { Errln("threw wrong exception" + e); } try { service.UnregisterFactory(null); Errln("didn't throw exception"); } catch (ArgumentNullException e) { Logln("OK: " + e.ToString()); } catch (Exception e) { Errln("threw wrong exception" + e); } Logln("object is: " + service.Get("object")); Logln("stats: " + service.Stats()); // ICURWLock ICURWLock rwlock = new ICURWLock(); rwlock.ResetStats(); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); Logln("stats: " + rwlock.ClearStats()); rwlock.AcquireRead(); rwlock.ReleaseRead(); rwlock.AcquireWrite(); rwlock.ReleaseWrite(); Logln("stats: " + rwlock.GetStats()); try { rwlock.ReleaseRead(); Errln("no error thrown"); } catch (Exception e) { Logln("OK: " + e.ToString()); } try { rwlock.ReleaseWrite(); Errln("no error thrown"); } catch (Exception e) { Logln("OK: " + e.ToString()); } // ICULocaleService // LocaleKey // LocaleKey lkey = LocaleKey.create("en_US", "ja_JP"); // lkey = LocaleKey.create(null, null); LocaleKey lkey = LocaleKey.CreateWithCanonicalFallback("en_US", "ja_JP"); Logln("lkey: " + lkey); lkey = LocaleKey.CreateWithCanonicalFallback(null, null); Logln("lkey from null,null: " + lkey); // LocaleKeyFactory LocaleKeyFactory lkf = new LKFSubclass(false); Logln("lkf: " + lkf); Logln("obj: " + lkf.Create(lkey, null)); Logln(lkf.GetDisplayName("foo", null)); Logln(lkf.GetDisplayName("bar", null)); lkf.UpdateVisibleIDs(new Dictionary <string, IFactory>()); LocaleKeyFactory invisibleLKF = new LKFSubclass(false); Logln("obj: " + invisibleLKF.Create(lkey, null)); Logln(invisibleLKF.GetDisplayName("foo", null)); Logln(invisibleLKF.GetDisplayName("bar", null)); invisibleLKF.UpdateVisibleIDs(new Dictionary <string, IFactory>()); // ResourceBundleFactory ICUResourceBundleFactory rbf = new ICUResourceBundleFactory(); Logln("RB: " + rbf.Create(lkey, null)); // ICUNotifier ICUNotifier nf = new ICUNSubclass(); try { nf.AddListener(null); Errln("added null listener"); } catch (ArgumentNullException e) { Logln(e.ToString()); } catch (Exception e) { Errln("got wrong exception"); } try { nf.AddListener(new WrongListener()); Errln("added wrong listener"); } catch (InvalidOperationException e) { Logln(e.ToString()); } catch (Exception e) { Errln("got wrong exception"); } try { nf.RemoveListener(null); Errln("removed null listener"); } catch (ArgumentNullException e) { Logln(e.ToString()); } catch (Exception e) { Errln("got wrong exception"); } nf.RemoveListener(new MyListener()); nf.NotifyChanged(); nf.AddListener(new MyListener()); nf.RemoveListener(new MyListener()); }