public async Task Execute_CypherConfigFound_CorrectQueryTextPassedToQuery()
        {
            const string expectedQueryText = "query text";

            var query = $"{{\"query\": \"{expectedQueryText}\"}}";

            A.CallTo(() => _fileHelper.ReadAllTextFromFileAsync($"\\CypherQueries\\{DefaultApiVersion}\\{DefaultFunctionName}.json")).Returns(query);

            A.CallTo(() => _neo4JHelper.ExecuteCypherQueryInNeo4JAsync(A <string> .Ignored, A <IDictionary <string, object> > .Ignored)).Returns(new object());

            await RunFunction();

            // Assert

            // could use the Capture from here.. https://thorarin.net/blog/post/2014/09/18/capturing-method-arguments-on-your-fakes-using-fakeiteasy.aspx
            var neo4JHelperCalls = Fake.GetCalls(_neo4JHelper).ToList();

            var executeCalls = neo4JHelperCalls.Where(c => c.Method.Name == nameof(INeo4JHelper.ExecuteCypherQueryInNeo4JAsync));

            Assert.Single(executeCalls);

            var executeCall = executeCalls.First();
            //todo: refactor unfriendly
            var actualQueryText = executeCall.Arguments[0].As <string>();

            Assert.Equal(expectedQueryText, actualQueryText);
        }
Esempio n. 2
0
        private async Task <object> ExecuteCypherQuery(Cypher cypherModel,
                                                       Dictionary <string, object> cypherQueryParameters, ILogger log)
        {
            log.LogInformation($"Attempting to query neo4j with the following query: {cypherModel.Query}");

            try
            {
                return(await _neo4JHelper.ExecuteCypherQueryInNeo4JAsync(cypherModel.Query, cypherQueryParameters));
            }
            catch (Exception ex)
            {
                throw ApiFunctionException.InternalServerError("Unable To run query", ex);
            }
        }