public void testAnyToList_List() { IList <Object> actual = ListUtil.AnyToList(expectedList); AssertSimilar(expectedList, actual); Assert.AreSame(expectedList, actual); }
public void testAnyToList_Set() { IList <Object> expected = new List <Object>(expectedSet); IList <Object> actual = ListUtil.AnyToList(expectedSet); AssertSimilar(expected, actual); }
public void testAnyToList_Array3() { Int32[] input = { }; IList <Object> actual = ListUtil.AnyToList(input); AssertSimilar(emptyList, actual); }
public void testAnyToList_Array1() { Object[] input = new Object[expectedList.Count]; expectedList.CopyTo(input, 0); IList <Object> actual = ListUtil.AnyToList(input); AssertSimilar(expectedList, actual); }
public void testAnyToList_Object() { Int32 testItem = 9843789; IList <Object> actual = ListUtil.AnyToList(testItem); Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Count); Assert.AreEqual(testItem, actual[0]); }
public void testAnyToList_Array2() { Int32[] input = { 1, 2, 3, 4, 5 }; IList <Object> expected = new List <Object>(input.Length); for (uint i = 0; i < input.Length; i++) { expected.Add(input[i]); } IList <Object> actual = ListUtil.AnyToList(input); AssertSimilar(expected, actual); }
public void testAnyToList_Collection() { IDictionary <Int32, String> input = new Dictionary <Int32, String>(); input.Add(4, "four"); input.Add(7, "seven"); IList <Object> actual = ListUtil.AnyToList(input); Assert.IsNotNull(actual); Assert.AreEqual(input.Count, actual.Count); IEnumerator <KeyValuePair <Int32, String> > enumerator = input.GetEnumerator(); while (enumerator.MoveNext()) { Assert.IsTrue(actual.Contains(enumerator.Current)); } }
protected void HandleValueHolderContainer(IValueHolderContainer vhc, RelationMember[] relationMembers, IObjRef[][] relations) { ICacheHelper cacheHelper = this.CacheHelper; ICacheIntern parent = this.Parent; IProxyHelper proxyHelper = this.ProxyHelper; for (int relationIndex = relationMembers.Length; relationIndex-- > 0;) { RelationMember relationMember = relationMembers[relationIndex]; IObjRef[] relationsOfMember = relations[relationIndex]; if (!CascadeLoadMode.EAGER.Equals(relationMember.CascadeLoadMode)) { if (ValueHolderState.INIT != vhc.Get__State(relationIndex)) { // Update ObjRef information within the entity and do nothing else vhc.Set__ObjRefs(relationIndex, relationsOfMember); continue; } } // We can safely access to relation if we want to if (relationsOfMember == null) { // Reset value holder state because we do not know the content currently vhc.Set__Uninitialized(relationIndex, null); continue; } Object relationValue = relationMember.GetValue(vhc); if (relationsOfMember.Length == 0) { if (!relationMember.IsToMany) { if (relationValue != null) { // Relation has to be flushed relationMember.SetValue(vhc, null); } } else { if (relationValue != null) { // Reuse existing collection ListUtil.ClearList(relationValue); } else { // We have to create a new empty collection relationValue = cacheHelper.CreateInstanceOfTargetExpectedType(relationMember.RealType, relationMember.ElementType); relationMember.SetValue(vhc, relationValue); } } continue; } // So we know the new content (which is not empty) and we know that the current content is already initialized // Now we have to refresh the current content eagerly // load entities as if we were an "eager valueholder" here IList <Object> potentialNewItems = parent.GetObjects(new List <IObjRef>(relationsOfMember), this, CacheDirective.None); if (OverwriteToManyRelations) { Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType, relationMember.ElementType); // Set new to-many-relation, even if there has not changed anything in its item content relationMember.SetValue(vhc, newRelationValue); continue; } IList <Object> relationItems = ListUtil.AnyToList(relationValue); bool diff = (relationItems.Count != potentialNewItems.Count); if (!diff) { for (int b = potentialNewItems.Count; b-- > 0;) { if (!Object.ReferenceEquals(potentialNewItems[b], relationItems[b])) { diff = true; break; } } } if (!diff) { // Nothing to do continue; } if (relationValue != null && relationMember.IsToMany) { // Reuse existing collection ListUtil.ClearAndFillList(relationValue, relationItems); } else { // We have to create a new empty collection or replace the to-one value Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType, relationMember.ElementType); relationMember.SetValue(vhc, newRelationValue); } } }