public void Test_getDateInstanceI() { NUnit.Framework.Assert.IsTrue(DateFormat.DEFAULT == DateFormat.MEDIUM, "Default not medium"); SimpleDateFormat f2 = (SimpleDateFormat)DateFormat .GetDateInstance(DateFormat.SHORT); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class1"); NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.SHORT, Locale.GetDefault())), "Wrong default1"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols1"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work1"); f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.MEDIUM); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class2"); NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.MEDIUM, Locale.GetDefault())), "Wrong default2"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols2"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work2"); f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.LONG); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class3"); NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.LONG, Locale.GetDefault())), "Wrong default3"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols3"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work3"); f2 = (SimpleDateFormat)DateFormat.GetDateInstance(DateFormat.FULL); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class4"); NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.FULL, Locale.GetDefault())), "Wrong default4"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols4"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work4"); // regression test for HARMONY-940 try { DateFormat.GetDateInstance(77); NUnit.Framework.Assert.Fail("Should throw IAE"); } catch (ArgumentException iae) { // expected } }
public void Test_getDateInstance() { SimpleDateFormat f2 = (SimpleDateFormat)DateFormat.GetDateInstance(); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); NUnit.Framework.Assert.IsTrue(f2.Equals(DateFormat.GetDateInstance(DateFormat.DEFAULT, Locale.GetDefault())), "Wrong default"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); }
public void Test_getTimeInstanceILjava_util_Locale() { SimpleDateFormat f2 = (SimpleDateFormat)DateFormat.GetTimeInstance( DateFormat.SHORT, Locale.GERMAN); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals( new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.MEDIUM, Locale.GERMAN); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals( new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.LONG, Locale.GERMAN); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals( new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); f2 = (SimpleDateFormat)DateFormat.GetTimeInstance(DateFormat.FULL, Locale.GERMAN); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals( new DateFormatSymbols(Locale.GERMAN)), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); // regression test for HARMONY-940 try { DateFormat.GetTimeInstance(77, Locale.GERMAN); NUnit.Framework.Assert.Fail("Should throw IAE"); } catch (ArgumentException iae) { // expected } }
private void TestDateTime(int dStyle, int tStyle) { SimpleDateFormat f2 = (SimpleDateFormat)DateFormat .GetDateTimeInstance(dStyle, tStyle); NUnit.Framework.Assert.IsTrue((Object)f2.GetType() == (Object)typeof(SimpleDateFormat), "Wrong class"); SimpleDateFormat date = (SimpleDateFormat)DateFormat.GetDateInstance( dStyle, Locale.GetDefault()); SimpleDateFormat time = (SimpleDateFormat)DateFormat.GetTimeInstance( tStyle, Locale.GetDefault()); NUnit.Framework.Assert.IsTrue(f2.ToPattern() .Equals(date.ToPattern() + " " + time.ToPattern()), "Wrong default"); NUnit.Framework.Assert.IsTrue(f2.GetDateFormatSymbols().Equals(new DateFormatSymbols()), "Wrong symbols"); NUnit.Framework.Assert.IsTrue((Object)f2.Format(DateTime.Now).GetType() == (Object)typeof(String), "Doesn't work"); }