public void Verify_GetReturnsSimpleValue_WhenPathIsSimpleListIndex() { var list = new List<string> { "One", "Two", "Three" }; var nav = new ObjectNavigator(); var result = nav.GetValue(list, "[1]"); Assert.AreEqual("Two", result); }
public void Verify_GetReturnsSimpleValue_WhenPathIsSimpleDictionaryStringKey() { var dict = new Dictionary<string, int>(); dict["The Answer"] = 42; var nav = new ObjectNavigator(); var result = nav.GetValue(dict, "The Answer"); Assert.AreEqual(42, result); }
public void Verify_GetReturnsSimpleValue_WhenPathIsSimplePropertyName() { var building = new Building { Price = 123.45 }; var nav = new ObjectNavigator(); var result = nav.GetValue(building, "Price"); Assert.AreEqual(123.45, result); }
public void Verify_GetReturnsSimpleValue_WhenPathIsCompoundPropertyNames() { var building = new Building { Address = new Address { Street = "123 Oxford Road" } }; var nav = new ObjectNavigator(); var result = nav.GetValue(building, "Address.Street"); Assert.AreEqual("123 Oxford Road", result); }
public void Verify_GetReturnsSimpleValue_WhenPathIsCompoundListIndex() { var building = new Building { Rooms = new Room[] { new Room { Name = "Room Zero" }, new Room { Name = "Room One" } } }; var nav = new ObjectNavigator(); var result = nav.GetValue(building, "Rooms[1].Name"); Assert.AreEqual("Room One", result); }