public void Verify_SetChangesValue_WhenPathIsSimplePropertyName() { var building = new Building(); var nav = new ObjectNavigator(); nav.SetValue(building, "Price", 123.45); Assert.AreEqual(123.45, building.Price); }
public void Verify_SetChangesValue_WhenPathIsSimpleDictionaryStringKey() { var dict = new Dictionary<string, int>(); dict["The Answer"] = 42; var nav = new ObjectNavigator(); nav.SetValue(dict, "The Answer", 24); Assert.AreEqual(24, dict["The Answer"]); }
public void Verify_SetChangesValue_WhenPathIsSimpleListIndex() { var list = new List<string> { "One", "Two", "Three" }; var nav = new ObjectNavigator(); nav.SetValue(list, "[2]", "THIRD"); Assert.AreEqual("THIRD", list[2]); }
public void Verify_SetChangesValue_WhenPathIsCompoundListIndex() { var building = new Building { Rooms = new Room[] { new Room { Name = "Room Zero" }, new Room { Name = "Room One" } } }; var nav = new ObjectNavigator(); nav.SetValue(building, "Rooms[0].Name", "First Room"); Assert.AreEqual("First Room", building.Rooms[0].Name); }
public void Verify_SetChangesValue_WhenPathIsIndexedDictionaryStringKey() { var dict = new Dictionary<string, int[]>(); dict["The Answer"] = new int[] { 1, 2, 3, 4 }; var nav = new ObjectNavigator(); nav.SetValue(dict, "The Answer[1]", 10002); Assert.AreEqual(10002, dict["The Answer"][1]); }