public void SetValue_AssigningAGenericListField_ValueShouldBeSet() { var container = new ClassWithLists(); Assert.That(container.Int32List, Is.Null); PropertyContainer.SetValue(ref container, nameof(ClassWithLists.Int32List), new List <int> { 1, 2, 3 }); Assert.That(container.Int32List, Is.Not.Null); Assert.That(container.Int32List.Count, Is.EqualTo(3)); }
public void PathVisitor_VisitArrayElement_ReturnVisitErrorCodeOk() { var container = new ClassWithLists { Int32List = new List <int> { 1, 2, 3 } }; var visitor = new TestPathVisitor(new PropertyPath($"{nameof(ClassWithLists.Int32List)}[1]")); PropertyContainer.Accept(visitor, ref container); Assert.That(visitor.ErrorCode, Is.EqualTo(VisitErrorCode.Ok)); }
public void PropertyVisitor_NullCollectionType_VisitCollectionIsInvoked() { var withVisitCollection = new VisitorWithVisitCollection(); var withoutVisitCollection = new VisitorWithoutVisitCollection(); var container = new ClassWithLists() { Int32List = new List <int>(), ClassContainerList = null, StructContainerList = null, Int32ListList = null }; PropertyContainer.Accept(withVisitCollection, container); PropertyContainer.Accept(withoutVisitCollection, container); Assert.That(withVisitCollection.VisitCollectionCount, Is.EqualTo(4)); Assert.That(withVisitCollection.VisitPropertyCount, Is.EqualTo(0)); Assert.That(withoutVisitCollection.VisitCollectionCount, Is.EqualTo(0)); Assert.That(withoutVisitCollection.VisitPropertyCount, Is.EqualTo(4)); }