Example #1
0
            public T ExecuteRequest <T>(string eventFilePath)
            {
                var requestFilePath  = Path.Combine(Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location), eventFilePath);
                var responseFilePath = Path.GetTempFileName();

                var comamndArgument = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"/c" : $"-c";
                ProcessStartInfo processStartInfo = new ProcessStartInfo();

                processStartInfo.FileName         = GetSystemShell();
                processStartInfo.Arguments        = $"{comamndArgument} dotnet run \"{requestFilePath}\" \"{responseFilePath}\"";
                processStartInfo.WorkingDirectory = GetTestAppDirectory();


                lock (lock_process)
                {
                    using var process = Process.Start(processStartInfo);
                    process.WaitForExit(15000);

                    if (!File.Exists(responseFilePath))
                    {
                        throw new Exception("No response file found");
                    }

                    using var responseFileStream = File.OpenRead(responseFilePath);

                    var serializer = new DefaultLambdaJsonSerializer();
                    var response   = serializer.Deserialize <T>(responseFileStream);

                    return(response);
                }
            }
Example #2
0
        private static Task <InvocationResponse> ToUpperAsync(InvocationRequest invocation)
        {
            var input = JsonSerializer.Deserialize <string>(invocation.InputStream);

            return(Task.FromResult(GetInvocationResponse(nameof(ToUpperAsync), input.ToUpper())));
        }