public void PreferenceSet_Set_String_Test() { var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); prefs.Set(Preference.EmailReportingFromAddress, (string)null); Assert.AreEqual(null, data.Email.FromAddress); prefs.Set(Preference.EmailReportingFromAddress, "*****@*****.**"); Assert.AreEqual("*****@*****.**", data.Email.FromAddress); prefs.Set(Preference.EmailReportingFromAddress, "*****@*****.**"); Assert.AreEqual("*****@*****.**", data.Email.FromAddress); }
public void PreferenceSet_Set_ValueType_Test() { var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); prefs.Set(Preference.FormSplitterLocation, (object)null); Assert.AreEqual(0, data.MainWindowState.SplitterLocation); prefs.Set(Preference.FormSplitterLocation, "60"); Assert.AreEqual(60, data.MainWindowState.SplitterLocation); prefs.Set(Preference.FormSplitterLocation, 120); Assert.AreEqual(120, data.MainWindowState.SplitterLocation); prefs.Set(Preference.FormSplitterLocation, 360); Assert.AreEqual(360, data.MainWindowState.SplitterLocation); }
public void PreferenceSet_Set_ThrowsOnReadOnlyPreference_Test() { // Arrange var prefs = new InMemoryPreferenceSet(); // Act & Assert Assert.Throws <InvalidOperationException>(() => prefs.Set(Preference.ApplicationPath, String.Empty)); }
public void PreferenceSet_Set_ThrowsOnDataTypeMismatch_Test() { // Arrange var prefs = new InMemoryPreferenceSet(); // Act & Assert Assert.Throws <ArgumentException>(() => prefs.Set(Preference.ClientRetrievalTask, String.Empty)); }
public void PreferenceSet_Set_Collection_Test() { var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); prefs.Set(Preference.FormColumns, (List <string>)null); Assert.AreEqual(null, data.MainWindowGrid.Columns); var enumerable = (IEnumerable <string>) new[] { "a", "b", "c" }; prefs.Set(Preference.FormColumns, enumerable); Assert.AreEqual(3, data.MainWindowGrid.Columns.Count); Assert.AreNotSame(enumerable, data.MainWindowGrid.Columns); var collection = (ICollection <string>) new[] { "a", "b", "c" }; prefs.Set(Preference.FormColumns, collection); Assert.AreEqual(3, data.MainWindowGrid.Columns.Count); Assert.AreNotSame(collection, data.MainWindowGrid.Columns); }
public void PreferenceSet_Set_Class_Test() { var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); ClientRetrievalTask task = null; prefs.Set(Preference.ClientRetrievalTask, task); Assert.AreEqual(null, data.ClientRetrievalTask); task = new ClientRetrievalTask(); prefs.Set(Preference.ClientRetrievalTask, task); Assert.AreNotSame(task, data.ClientRetrievalTask); task = new ClientRetrievalTask { Enabled = false }; prefs.Set(Preference.ClientRetrievalTask, task); Assert.AreNotSame(task, data.ClientRetrievalTask); }
public void PreferenceSet_Set_StringAsEnum_Test() { // Arrange var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); // Act prefs.Set(Preference.BonusCalculation, BonusCalculation.Default); // Assert Assert.AreEqual("Default", data.ApplicationSettings.BonusCalculation); }
public void PreferenceSet_RoundTripEncryptedPreference_Test() { // Arrange const string value = "fizzbizz"; var data = new PreferenceData(); var prefs = new InMemoryPreferenceSet(data); // Act prefs.Set(Preference.WebGenPassword, value); // Assert Assert.AreNotEqual(value, data.WebDeployment.FtpServer.Password); Assert.AreEqual(value, prefs.Get <string>(Preference.WebGenPassword)); }
public void PreferenceSet_PreferenceChanged_Test() { // Arrange var prefs = new InMemoryPreferenceSet(); object sender = null; PreferenceChangedEventArgs args = null; prefs.PreferenceChanged += (s, e) => { sender = s; args = e; }; // Act prefs.Set(Preference.ColorLogFile, false); // Assert Assert.AreSame(prefs, sender); Assert.AreEqual(Preference.ColorLogFile, args.Preference); }