public void Resolve_Container_List_Item() { var path = PropertyPath.Parse("ChildContainer.ChildList[1].IntValue"); var container = new TestNestedContainer { ChildContainer = new TestContainer { IntValue = 123, ChildList = { new TestChildContainer { IntValue = 123 }, new TestChildContainer { IntValue = 456 } } } }; var resolution = path.Resolve(container); Assert.IsTrue(resolution.success); Assert.AreEqual(container.ChildContainer.ChildList[1], resolution.container); Assert.AreEqual(TestChildContainer.IntValueProperty, resolution.property); Assert.AreEqual(PropertyPath.InvalidListIndex, resolution.listIndex); Assert.AreEqual(456, resolution.value); }
public void PropertyContainer_SetValue_NestedContainer() { var container = new TestNestedContainer(); PropertyContainer.SetValue(ref container, nameof(TestNestedContainer.TestPrimitiveContainer), new TestPrimitiveContainer { Int32Value = 42 }); Assert.AreEqual(42, container.TestPrimitiveContainer.Int32Value); }
public void PropertyContainer_GetValue_NestedContainer() { var container = new TestNestedContainer { TestPrimitiveContainer = new TestPrimitiveContainer { Int32Value = 42 } }; var value = PropertyContainer.GetValue <TestNestedContainer, TestPrimitiveContainer>(ref container, nameof(TestNestedContainer.TestPrimitiveContainer)); Assert.AreEqual(42, value.Int32Value); }
public void PropertyVisitor_Visit_StructWithNestedStruct() { var container = new TestNestedContainer(); PropertyContainer.Visit(ref container, new DebugLogVisitor()); }