public void FormatTest() { Assert.AreEqual(string.Format("{0:N}",customer),customer.Name); Assert.AreEqual(string.Format("{0:NCR}", customer), string.Format("{0} {1} {2}",customer.Name,customer.ContactPhone,customer.Revenue)); var cfp = new CustomerFormatProvider(); Assert.AreEqual(string.Format(cfp,"{0:QQQ}",customer),"навИ"); }
static void Main(string[] args) { var c = new Customer("Sai", "+375505", 50); Console.WriteLine(c); Console.WriteLine(String.Format("{0:N}123", c)); var pr = new CustomerFormatProvider(); Console.WriteLine(String.Format(pr, "{0:UN}", c)); Console.WriteLine("-----------------------------------"); var ith = new IntToHexFormatProvider(); Console.WriteLine(String.Format(ith, "{0:H}", 88)); Console.WriteLine("-----------------------------------"); int[] a = { 4, 2, 8 }; // Console.WriteLine(NOD.Euclidian()); }
public void TestFormats() { Assert.AreEqual(String.Format("{0:N}", c), c.Name.ToString()); Assert.AreEqual(String.Format("{0:N,R}", c), String.Format("{0} {1}",c.Name,c.Revenue)); Assert.AreEqual(String.Format("{0:N} {0:R}", c), String.Format("{0} {1}", c.Name, c.Revenue)); Assert.AreEqual(String.Format("{0:N,P}", c), String.Format("{0} {1}", c.Name, c.ContactPhone)); Assert.AreEqual(String.Format("{0:N,p,R}", c), String.Format("{0} {1} {2}", c.Name, c.ContactPhone,c.Revenue)); var pr = new CustomerFormatProvider(); Assert.AreEqual(String.Format(pr, "{0:UN}", c), c.Name.ToUpperInvariant()); Assert.AreEqual(String.Format(pr, "{0:N}", c), c.Name); }
public void TestWrongFormat() { var pr = new CustomerFormatProvider(); Assert.AreEqual(String.Format("{0:Q}", c), "Sai"); Assert.AreEqual(String.Format(pr,"{0:Q}", c), "Sai"); }