예제 #1
0
        private static void TraverseIndex(IObjectContainer container)
        {
            // #example: Traverse index
            IStoredField storedField = container.Ext()
                                       .StoredClass(typeof(Item)).StoredField("data", typeof(int));

            storedField.TraverseValues(new IndexVisitor());
            // #end example
        }
예제 #2
0
        public virtual void TestTraverseValues()
        {
            IStoredField     field            = StoredField();
            ExpectingVisitor expectingVisitor = new ExpectingVisitor(IntArrays4.ToObjectArray
                                                                         (Foos));

            field.TraverseValues(expectingVisitor);
            expectingVisitor.AssertExpectations();
        }
예제 #3
0
        public virtual void TestTraverseValues()
        {
            IStoredField field = StoredField();

            StringFieldIndexTestCase.ExpectedVisitor visitor = new StringFieldIndexTestCase.ExpectedVisitor
                                                                   (2);
            field.TraverseValues(visitor);
            for (int i = 0; i < _fooValues.Length; i++)
            {
                Assert.AreEqual(_fooValues[i], visitor.GetValues()[i]);
            }
        }
예제 #4
0
        private void AssertStoredField(Type objectClass, string fieldName, object expectedFieldValue
                                       , Type expectedFieldType, bool hasIndex, bool isArray)
        {
            IStoredClass storedClass = StoredClass(objectClass);

            IStoredField[] storedFields = storedClass.GetStoredFields();
            Assert.AreEqual(1, storedFields.Length);
            IStoredField storedField = storedFields[0];

            Assert.AreEqual(fieldName, storedField.GetName());
            IStoredField storedFieldByName = storedClass.StoredField(fieldName, expectedFieldType
                                                                     );

            Assert.AreEqual(storedField, storedFieldByName);
            object item = RetrieveOnlyInstance(objectClass);

            Assert.AreEqual(expectedFieldValue, storedField.Get(item));
            IReflectClass fieldType = storedField.GetStoredType();

            Assert.AreEqual(Reflector().ForClass(expectedFieldType), fieldType);
            Assert.AreEqual(isArray, storedField.IsArray());
            if (IsMultiSession())
            {
                return;
            }
            Assert.AreEqual(hasIndex, storedField.HasIndex());
            // FIXME: test rename
            if (!hasIndex)
            {
                Assert.Expect(typeof(Exception), new _ICodeBlock_113(storedField));
            }
            else
            {
                IntByRef count = new IntByRef();
                storedField.TraverseValues(new _IVisitor4_123(count, expectedFieldValue));
                Assert.AreEqual(1, count.value);
            }
        }