public async Task AllowStartOfPrograms_is_cancelled() { var rfcRuntimeMock = new Mock <IRfcRuntime>() .SetupOpenConnection(out var connHandle); StartProgramDelegate callback = (c) => RfcErrorInfo.Ok(); rfcRuntimeMock.Setup(r => r .AllowStartOfPrograms(connHandle.Object, callback)) .Returns(Unit.Default); var conn = await rfcRuntimeMock.CreateConnection() .Map(c => c.AllowStartOfPrograms(callback)); rfcRuntimeMock.VerifyAll(); }
static async Task Main(string[] args) { var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryCollection(new[] { new KeyValuePair <string, string>("tests:repeats", "10"), new KeyValuePair <string, string>("tests:rows", "10") }); configurationBuilder.AddEnvironmentVariables("saprfc"); configurationBuilder.AddCommandLine(args); configurationBuilder.AddUserSecrets <Program>(); var config = configurationBuilder.Build(); var settings = new Dictionary <string, string> { { "ashost", config["saprfc:ashost"] }, { "sysnr", config["saprfc:sysnr"] }, { "client", config["saprfc:client"] }, { "user", config["saprfc:username"] }, { "passwd", config["saprfc:password"] }, { "lang", "EN" } }; var rows = Convert.ToInt32(config["tests:rows"]); var repeats = Convert.ToInt32(config["tests:repeats"]); Console.WriteLine($"Test rows: {rows}"); Console.WriteLine($"Test repeats: {repeats}"); StartProgramDelegate callback = command => { var programParts = command.Split(' '); var arguments = command.Replace(programParts[0], ""); var p = Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\" + programParts[0] + ".exe", arguments.TrimStart()); return(RfcErrorInfo.Ok()); }; var connectionBuilder = new ConnectionBuilder(settings) .WithStartProgramCallback(callback) .ConfigureRuntime(c => c.WithLogger(new SimpleConsoleLogger())); using (var context = new RfcContext(connectionBuilder.Build())) { await context.PingAsync(); await RunIntegrationTests(context); long totalTest1 = 0; long totalTest2 = 0; for (var run = 0; run < repeats; run++) { Console.WriteLine($"starting Test Run {run + 1} of {repeats}\tTest 01"); totalTest1 += await RunPerformanceTest01(context, rows); Console.WriteLine($"starting Test Run {run + 1} of {repeats}\tTest 02"); totalTest2 += await RunPerformanceTest02(context, rows); GC.Collect(); } Console.WriteLine("Total runtime Test 01: " + totalTest1); Console.WriteLine("Total runtime Test 02: " + totalTest2); Console.WriteLine("Average runtime Test 01: " + totalTest1 / repeats); Console.WriteLine("Average runtime Test 02: " + totalTest2 / repeats); } }