コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunAggregationFunction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunAggregationFunction()
        {
            // Given
            CallableUserAggregationFunction func = Compile(typeof(SingleAggregationFunction))[0];

            // When
            UserAggregator aggregator = func.Create(new BasicContext());

            aggregator.Update(new object[] { "Harry" });
            aggregator.Update(new object[] { "Bonnie" });
            aggregator.Update(new object[] { "Sally" });
            aggregator.Update(new object[] { "Clyde" });

            // Then
            assertThat(aggregator.Result(), equalTo(Arrays.asList("Bonnie", "Clyde")));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRunClassWithMultipleFunctionsDeclared() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRunClassWithMultipleFunctionsDeclared()
        {
            // Given
            IList <CallableUserAggregationFunction> compiled = Compile(typeof(MultiFunction));
            CallableUserAggregationFunction         f1       = compiled[0];
            CallableUserAggregationFunction         f2       = compiled[1];

            // When
            UserAggregator f1Aggregator = f1.Create(new BasicContext());

            f1Aggregator.Update(new object[] { "Bonnie" });
            f1Aggregator.Update(new object[] { "Clyde" });
            UserAggregator f2Aggregator = f2.Create(new BasicContext());

            f2Aggregator.Update(new object[] { "Bonnie", 1337L });
            f2Aggregator.Update(new object[] { "Bonnie", 42L });

            // Then
            assertThat(f1Aggregator.Result(), equalTo(Arrays.asList("Bonnie", "Clyde")));
            assertThat(((System.Collections.IDictionary)f2Aggregator.Result())["Bonnie"], equalTo(1337L));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadWhiteListedFunction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadWhiteListedFunction()
        {
            // Given
            _procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, new ComponentRegistry(), NullLog.Instance, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_whitelist, "org.neo4j.kernel.impl.proc.collectCool")));

            CallableUserAggregationFunction method = Compile(typeof(SingleAggregationFunction))[0];

            // Expect
            UserAggregator created = method.Create(new BasicContext());

            created.Update(new object[] { "Bonnie" });
            assertThat(created.Result(), equalTo(Collections.singletonList("Bonnie")));
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInjectLogging() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInjectLogging()
        {
            // Given
            Log log = spy(typeof(Log));

            _components.register(typeof(Log), ctx => log);
            CallableUserAggregationFunction function = _procedureCompiler.compileAggregationFunction(typeof(LoggingFunction))[0];

            // When
            UserAggregator aggregator = function.Create(new BasicContext());

            aggregator.Update(new object[] {});
            aggregator.Result();

            // Then
            verify(log).debug("1");
            verify(log).info("2");
            verify(log).warn("3");
            verify(log).error("4");
        }