public void PropertyGuard_FirstLevelCheck() { //Arrange var guard = new PropertyGuard(); guard.Add(typeof(Node), "Child"); guard.Add(typeof(Node), "Child"); //Act var isRepeating = guard.IsRepeating(typeof(Node), "Child"); //Assert Assert.IsTrue(isRepeating); }
public CollectionVisitor(Type ownerType, Type collectionType, string elementName = null, PropertyGuard guard = null, bool supportsCloning = true) : base(guard, supportsCloning) { ElementName = elementName; if (!string.IsNullOrWhiteSpace(elementName)) { _elementAccessor = ExpressAccessor.Create(ownerType, collectionType, elementName); } if (SupportsCloning) { _elementCloner = ClonerBase.Create(collectionType); } }
public void PropertyGuard_SecondLevelCheck() { //Arrange var guard = new PropertyGuard(); guard.Add(typeof(SimpleParent), "Child"); guard.Add(typeof(SimpleChild), "Parent"); guard.Add(typeof(SimpleParent), "Child"); guard.Add(typeof(SimpleChild), "Parent"); //Act var isRepeating = guard.IsRepeating(typeof(SimpleParent), "Child"); //Assert Assert.IsTrue(isRepeating); }
public void PropertyGuard_ThirdLevelCheck() { //Arrange var guard = new PropertyGuard(); guard.Add(typeof(First), "Second1"); guard.Add(typeof(Second), "Third1"); guard.Add(typeof(Third), "First1"); guard.Add(typeof(First), "Second1"); guard.Add(typeof(Second), "Third1"); guard.Add(typeof(Third), "First1"); //Act var isRepeating = guard.IsRepeating(typeof(First), "Second1"); //Assert Assert.IsTrue(isRepeating); }
public DictionaryVisitor(Type ownerType, Type dictionaryType, string elementName = null, PropertyGuard guard = null, bool supportsCloning = true) : base(guard, supportsCloning) { ElementName = elementName; if (!string.IsNullOrWhiteSpace(elementName)) { _elementAccessor = ExpressAccessor.Create(ownerType, dictionaryType, elementName); } if (SupportsCloning) { _elementCloner = ClonerBase.Create(dictionaryType); } var keyType = dictionaryType.GenericTypeArguments[0]; var valueType = dictionaryType.GenericTypeArguments[1]; var kvpType = typeof(KeyValuePair <,>).MakeGenericType(keyType, valueType); KeyValueAccessor = ExpressAccessor.Create(kvpType, valueType, "Value"); }