public void LocalizedValue()
        {
            var localized = new LocalizableString("RelativeDateFormatStringTomorrow");
            localized.Value = "RelativeDateFormatStringTomorrow";
            Assert.IsNull(localized.ResourceType);
            Assert.AreEqual("RelativeDateFormatStringTomorrow", localized.Value);
            Assert.AreEqual("RelativeDateFormatStringTomorrow", localized.GetLocalizableValue());

            localized.ResourceType = typeof(Properties.Resources);
            Assert.IsNotNull(localized.ResourceType);
            Assert.AreEqual("RelativeDateFormatStringTomorrow", localized.Value);
            Assert.AreEqual("Tomorrow", localized.GetLocalizableValue());

            var currentCulture = Thread.CurrentThread.CurrentUICulture;
            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("es-ES");
                localized.ResourceType = typeof(Properties.Resources);
                Assert.IsNotNull(localized.ResourceType);
                Assert.AreEqual("RelativeDateFormatStringTomorrow", localized.Value);
                Assert.AreEqual("Mañana", localized.GetLocalizableValue());
            }
            finally
            {
                Thread.CurrentThread.CurrentUICulture = currentCulture;
            }
        }
        public void InvalidResource()
        {
            var localized = new LocalizableString("RelativeDateFormatStringTomorrow");
            localized.ResourceType = typeof(Properties.Resources);
            localized.Value = "RelativeDateFormatStringYesterday";
            Assert.AreEqual("RelativeDateFormatStringYesterday", localized.Value);
            Assert.IsNotNull(localized.ResourceType);

            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.ResourceType = typeof(LocalizbleStringTests.ResourceTester);
            localized.Value = "Invalid";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.Value = "InvalidStatic";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.Value = "Invalid2";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.Value = "Invalid3";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.Value = "Invalid4";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());

            localized.Value = "Invalid5";
            ExceptionAssert.Throws<InvalidOperationException>(() => localized.GetLocalizableValue());
        }
 public void LocalValue()
 {
     var localized = new LocalizableString("Width");
     localized.Value = "100px";
     Assert.AreEqual("100px", localized.Value);
     Assert.AreEqual("100px", localized.GetLocalizableValue());
 }
 public void MissingValue()
 {
     var localized = new LocalizableString("RelativeDateFormatStringTomorrow");
     localized.ResourceType = typeof(Properties.Resources);
     Assert.IsNotNull(localized.ResourceType);
     Assert.IsNull(localized.GetLocalizableValue());
 }