Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _procs.registerComponent(typeof(KernelTransaction), ctx => ctx.get(KERNEL_TRANSACTION), false);
            _procs.registerComponent(typeof(DependencyResolver), ctx => ctx.get(_dependencyResolver), false);
            _procs.registerComponent(typeof(GraphDatabaseAPI), ctx => ctx.get(_graphdatabaseapi), false);
            _procs.registerComponent(typeof(SecurityContext), ctx => ctx.get(SECURITY_CONTEXT), true);

            _procs.registerComponent(typeof(Log), ctx => ctx.get(_log), false);
            _procs.registerType(typeof(Node), NTNode);
            _procs.registerType(typeof(Relationship), NTRelationship);
            _procs.registerType(typeof(Path), NTPath);

            (new SpecialBuiltInProcedures("1.3.37", Edition.enterprise.ToString())).accept(_procs);
            _procs.registerProcedure(typeof(BuiltInProcedures));
            _procs.registerProcedure(typeof(BuiltInDbmsProcedures));

            when(_tx.acquireStatement()).thenReturn(_statement);
            when(_tx.tokenRead()).thenReturn(_tokens);
            when(_tx.dataRead()).thenReturn(_read);
            when(_tx.schemaRead()).thenReturn(_schemaRead);
            when(_schemaRead.snapshot()).thenReturn(_schemaReadCore);

            when(_tokens.propertyKeyGetAllTokens()).thenAnswer(AsTokens(_propKeys));
            when(_tokens.labelsGetAllTokens()).thenAnswer(AsTokens(_labels));
            when(_tokens.relationshipTypesGetAllTokens()).thenAnswer(AsTokens(_relTypes));
            when(_schemaReadCore.indexesGetAll()).thenAnswer(i => Iterators.concat(_indexes.GetEnumerator(), _uniqueIndexes.GetEnumerator()));
            when(_schemaReadCore.index(any(typeof(SchemaDescriptor)))).thenAnswer((Answer <IndexReference>)invocationOnMock =>
            {
                SchemaDescriptor schema = invocationOnMock.getArgument(0);
                int label = Schema.keyId();
                int prop  = Schema.PropertyId;
                return(GetIndexReference(label, prop));
            });
            when(_schemaReadCore.constraintsGetAll()).thenAnswer(i => _constraints.GetEnumerator());

            when(_tokens.propertyKeyName(anyInt())).thenAnswer(invocation => _propKeys[invocation.getArgument(0)]);
            when(_tokens.nodeLabelName(anyInt())).thenAnswer(invocation => _labels[invocation.getArgument(0)]);
            when(_tokens.relationshipTypeName(anyInt())).thenAnswer(invocation => _relTypes[invocation.getArgument(0)]);

            when(_indexingService.getIndexId(any(typeof(SchemaDescriptor)))).thenReturn(42L);

            when(_schemaReadCore.constraintsGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.indexesGetForLabel(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.indexesGetForRelationshipType(anyInt())).thenReturn(emptyIterator());
            when(_schemaReadCore.constraintsGetForLabel(anyInt())).thenReturn(emptyIterator());
            when(_read.countsForNode(anyInt())).thenReturn(1L);
            when(_read.countsForRelationship(anyInt(), anyInt(), anyInt())).thenReturn(1L);
            when(_schemaReadCore.indexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.ONLINE);
        }