GetActionResult( ConnectionOutput output, string[]?stdOut, string[]?stdErr) { const string?casePath = @"d:\case"; const string?search = "*.png"; const string?tag = "image"; var action = ConnectionTestsHelper.SearchAndTagAction(casePath, search, tag, output); action.WriteToStdOut = stdOut; action.WriteToStdErr = stdErr; var loggerFactory = TestLoggerFactory.Create(); var nuixConnection = ConnectionTestsHelper.GetNuixConnection( loggerFactory, ConnectionTestsHelper.SearchHelperAction, ConnectionTestsHelper.ExpandHelperAction, action ); var result = await nuixConnection.RunFunctionAsync( ConnectionTestsHelper.GetStateMonadForProcess(loggerFactory), null, new NuixSearchAndTag().RubyScriptStepFactory.RubyFunction, ConnectionTestsHelper.SearchAndTagParams(casePath, search, tag), CasePathParameter.IgnoresOpenCase.Instance, new CancellationToken() ); return(loggerFactory, result); }
public async Task RunFunctionAsync_WhenFunctionHasEntityStream_ProcessStream() { var action = new ExternalProcessAction( new ConnectionCommand { Command = "EntityStream", FunctionDefinition = "doesn't matter", Arguments = new Dictionary <string, object>(), IsStream = true } ); var logFactory = TestLoggerFactory.Create(); var nuixConnection = ConnectionTestsHelper.GetNuixConnection(logFactory, action); var ct = new CancellationToken(); var entities = new List <Entity> { Entity.Create(("Property1", "Value1")), Entity.Create(("Property2", "Value2")) }; var stream1 = entities.ToAsyncEnumerable().ToSCLArray(); var dict = new Dictionary <RubyFunctionParameter, object> { { new RubyFunctionParameter("entityStream", "EntityStream", false), stream1 } }; var stepParams = new ReadOnlyDictionary <RubyFunctionParameter, object>(dict); var step = new FakeNuixStreamFunction(); var result = await nuixConnection.RunFunctionAsync( ConnectionTestsHelper.GetStateMonadForProcess(logFactory), null, step.RubyScriptStepFactory.RubyFunction, stepParams, CasePathParameter.IgnoresOpenCase.Instance, ct ); result.ShouldBeSuccessful(); Assert.Equal(@"[{""Property1"":""Value1""},{""Property2"":""Value2""}]", result.Value); }
public async Task RunFunctionAsync_WhenDisposed_Throws() { var logFactory = TestLoggerFactory.Create(); var nuixConnection = ConnectionTestsHelper.GetNuixConnection(logFactory); var ct = new CancellationToken(); nuixConnection.Dispose(); await Assert.ThrowsAsync <ObjectDisposedException>( () => nuixConnection.RunFunctionAsync <Unit>( ConnectionTestsHelper.GetStateMonadForProcess(logFactory), null !, null !, new Dictionary <RubyFunctionParameter, object>(), CasePathParameter.IgnoresOpenCase.Instance, ct ) ); }
public async Task RunFunctionAsync_WithTwoEntityStreamParameters_ReturnsError() { var logFactory = TestLoggerFactory.Create(); var action = ConnectionTestsHelper.GetDoneAction(); var nuixConnection = ConnectionTestsHelper.GetNuixConnection(logFactory, action); var ct = new CancellationToken(); var stream1 = new List <Entity>().ToAsyncEnumerable().ToSCLArray(); var stream2 = new List <Entity>().ToAsyncEnumerable().ToSCLArray(); var dict = new Dictionary <RubyFunctionParameter, object> { { new RubyFunctionParameter("stream1Arg", "Stream1", false), stream1 }, { new RubyFunctionParameter("stream2Arg", "Stream2", false), stream2 } }; var stepParams = new ReadOnlyDictionary <RubyFunctionParameter, object>(dict); var step = new FakeNuixTwoStreamFunction(); var result = await nuixConnection.RunFunctionAsync( ConnectionTestsHelper.GetStateMonadForProcess(logFactory), null, step.RubyScriptStepFactory.RubyFunction, stepParams, CasePathParameter.IgnoresOpenCase.Instance, ct ); Assert.True(result.IsFailure); Assert.Equal( "A nuix function cannot have more than one Entity Array parameter.", result.Error.AsString ); }