public void Comments(string comment) { //Arrange var mgr = new SimpleSettingsMgr(); //Act mgr.Comments = comment; //Assert int result = string.Compare(comment, mgr.Comments); Assert.Equal(0, result); Assert.Same(mgr.Comments, comment); }
public void ApplyChanges_Updates_All_Specified_Items_To_New_Values() { //Arrange var mgr = new SimpleSettingsMgr(); PointF expectedLoc = new PointF(33f, 55f); string item1Name = "Location"; IDictionary<string, object> changes = new Dictionary<string, object>(); changes.Add(item1Name, expectedLoc); string comment = "blah"; string item2Name = "Comments"; changes.Add(item2Name, comment); //Act mgr.ApplyChanges(changes); //Assert object val1 = mgr[item1Name]; Assert.Equal(expectedLoc, val1); object val2 = mgr[item2Name]; Assert.Equal(comment, val2); }
public void ApplyChanges_Does_Not_Fire_SettingsChangedEvent_After_All_Changes_Are_Made() { //Arrange var mgr = new SimpleSettingsMgr(); var helper = new HelperForSettingsMgr(); mgr.SettingsChanged += new SettingsChangedEventHandler<ISettings, SettingsChangedEventArgs> (helper.SettingsChanged_DummyHandler); PointF expectedLoc = new PointF(33f, 55f); string item1Name = "Location"; IDictionary<string, object> changes = new Dictionary<string, object>(); changes.Add(item1Name, expectedLoc); string comment = "blah"; string item2Name = "Comments"; changes.Add(item2Name, comment); //Act mgr.ApplyChanges(changes); //Assert Assert.Equal(0, helper.SettingsChanged_TimesCalled); }
public void Items_Contains_Setting(string name) { //Arrange var mgr = new SimpleSettingsMgr(); //Act bool result = mgr.Values.ContainsKey(name); //Assert Assert.True(result); }
public void Reset_Reverts_All_Items_To_Defaults() { //Arrange var mgr = new SimpleSettingsMgr(); mgr.Location = new PointF(33f, 44f); mgr.Comments = "blah"; mgr.Reset(); PointF result = mgr.Location; object[] defaults = (mgr as ElementSettingsMgr).Defaults; for (int i = 0; i < mgr.Names.Length; i++) { object val = mgr[mgr.Names[i]]; object dft = defaults[i]; Assert.Equal(dft, val); } }
public void Reset_For_Location_Reverts_Its_Default(float x, float y, string name) { //Arrange var mgr = new SimpleSettingsMgr(); PointF expectedLoc = new PointF(x, y); mgr.Location = expectedLoc; mgr.Reset(name); PointF result = mgr.Location; Assert.Equal(ElementSettingsMgr._LocationDefault, result); }
public void Reset_For_Location_Does_Not_Fire_SettingsChangedEvent_If_Values_Have_Changed(float x, float y, string name) { //Arrange var mgr = new SimpleSettingsMgr(); var helper = new HelperForSettingsMgr(); mgr.SettingsChanged += new SettingsChangedEventHandler<ISettings, SettingsChangedEventArgs> (helper.SettingsChanged_DummyHandler); PointF expectedLoc = new PointF(x, y); mgr.Location = expectedLoc; //Act mgr.Reset(name); //Assert Assert.Equal(0, helper.SettingsChanged_TimesCalled); }
public void Reset_For_Comments_Reverts_Its_Default(string comment, string name) { //Arrange var mgr = new SimpleSettingsMgr(); mgr.Comments = comment; mgr.Reset(name); string result = mgr.Comments; Assert.Equal(ElementSettingsMgr._CommentsDefault, result); }
public void Reset_For_Comments_Does_Not_Fire_SettingsChangedEvent_If_Values_Have_Changed(string comment, string name) { //Arrange var mgr = new SimpleSettingsMgr(); var helper = new HelperForSettingsMgr(); mgr.SettingsChanged += new SettingsChangedEventHandler<ISettings, SettingsChangedEventArgs> (helper.SettingsChanged_DummyHandler); mgr.Comments = comment; //Act mgr.Reset(name); //Assert Assert.Equal(0, helper.SettingsChanged_TimesCalled); }
public void Reset_Does_Not_Fires_SettingsChangedEvent_After_All_Changes_Are_Made() { //Arrange var mgr = new SimpleSettingsMgr(); mgr.Location = new PointF(33f, 44f); mgr.Comments = "blah"; var helper = new HelperForSettingsMgr(); mgr.SettingsChanged += new SettingsChangedEventHandler<ISettings, SettingsChangedEventArgs> (helper.SettingsChanged_DummyHandler); //Act mgr.Reset(); //Assert Assert.Equal(0, helper.SettingsChanged_TimesCalled); }
public void Location(float x, float y) { //Arrange var mgr = new SimpleSettingsMgr(); PointF expectedLoc = new PointF(x, y); //Act mgr.Location = expectedLoc; //Assert Assert.Equal(expectedLoc, mgr.Location); }
public void Item_Setter_Throws_Ex_If_New_Type_Does_Not_Match_Default_Type(string name) { //Arrange var mgr = new SimpleSettingsMgr(); //Act, Assert var ex = Assert.Throws<InvalidCastException>(() => mgr[name] = System.DBNull.Value); }
public void Item_Setter_For_Location(float x, float y, string name) { //Arrange var mgr = new SimpleSettingsMgr(); PointF expectedLoc = new PointF(x, y); //Act mgr[name] = expectedLoc; //Assert PointF result = (PointF)mgr[name]; Assert.Equal(expectedLoc, result); }
public void Item_Setter_For_Comments(string comment, string name) { //Arrange var mgr = new SimpleSettingsMgr(); //Act mgr[name] = comment; //Assert int result = string.Compare(comment, (string)mgr[name]); Assert.Equal(0, result); Assert.Same(mgr.Comments, comment); }
public void Items_Contains_Specified_Setting(string name, Type expectedType) { //Arrange var mgr = new SimpleSettingsMgr(); //Act object result = mgr.Values[name]; //Assert Assert.NotNull(result); Assert.IsType(expectedType, result); }
internal ISimpleSettingsMgr _CreateSettingsMgr(ISimpleElement element) { ISimpleSettingsMgr mgr = null; if (element != null) { mgr = new SimpleSettingsMgr(); } return mgr; }