public void SimpleFieldUpdaterCanUpdateLocalizedFields() { // Arrange. var englishCulture = new CultureInfo("en-US"); var spanishCulture = new CultureInfo("es-ES"); var frenchCulture = new CultureInfo("fr-FR"); var updater = new SimpleFieldUpdater { FieldName = TestsHelper.ExtractPropertyName(() => new TestEdit().Localized), PropertyType = typeof(string), AllowLocalizedData = true }; updater.SupportedLocalizations.Add(new LocalizationInfoAttribute(englishCulture.Name)); updater.SupportedLocalizations.Add(new LocalizationInfoAttribute(spanishCulture.Name)); updater.SupportedLocalizations.Add(new LocalizationInfoAttribute(frenchCulture.Name)); updater.SetValue(englishCulture.Name, "English Text"); updater.SetValue(spanishCulture.Name, "Spanish Text"); updater.SetValue(frenchCulture.Name, "French Text"); var item = new TestEdit(); // Act. updater.Update(item); // Assert. Assert.AreEqual("English Text", item.Localized_en_US); Assert.AreEqual("Spanish Text", item.Localized_es_ES); Assert.AreEqual("French Text", item.Localized_fr_FR); }
public void SimpleFieldUpdaterCanUpdateCurrentState() { // Arrange. var updater = new SimpleFieldUpdater { FieldName = Constants.CurrentStateColumnName, NewValue = TestEdit.States.Approved.Name, PropertyType = typeof(string) }; var item = new TestEdit(); // Act. updater.Update(item); // Assert. Assert.AreEqual(TestEdit.States.Approved.Id, item.CurrentState); // Exceptions. var statelessItem = Mock.Create<IEditableRoot>(); TestsHelper.VerifyThrow<InvalidOperationException>(() => updater.Update(statelessItem)); updater.NewValue = null; TestsHelper.VerifyThrow<InvalidOperationException>(() => updater.Update(item)); updater.NewValue = "Invalid State"; TestsHelper.VerifyThrow<InvalidOperationException>(() => updater.Update(item)); }
public void SimpleFieldUpdaterCanUpdateSimpleFields() { // Arrange. var updater = new SimpleFieldUpdater { FieldName = TestsHelper.ExtractPropertyName(() => new TestEdit().Text), NewValue = "123", PropertyType = typeof(string) }; var item = new TestEdit(); // Act. updater.Update(item); // Assert. Assert.AreEqual("123", item.Text); // Exceptions. TestsHelper.VerifyThrow<ArgumentNullException>(() => updater.Update(null)); }