예제 #1
0
        public void TestMethod1()
        {
            ITestInterface service = ServiceLocator.GetInstance <ITestInterface>();

            Assert.IsNotNull(service);
            service.TestMethod("Hello world!");
        }
예제 #2
0
        public static async Task AsyncMain()
        {
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

            ITestInterface apiInterface = TypeSafeHttpBuilder <ITestInterface> .Create()
                                          .RegisterRestSharpClient(@"http://localhost.fiddler:5000")
                                          .RegisterDefaultSerializers()
                                          .RegisterJsonNetSerializer()
                                          .Build();

            Console.WriteLine("About to call intercepted method.");

            Task <TestReturnModel> result = apiInterface.TestMethod("test", "testing dynamic header value");

            Console.WriteLine("API method temporarily yielded.");

            await result;

            Console.WriteLine($"Finished call intercepted method. Result: {result.Result.ReturnValue}");
        }
예제 #3
0
        public static async Task AsyncMain()
        {
            ITestInterface apiInterface = TypeSafeHttpBuilder <ITestInterface> .Create()
                                          .RegisterDotNetHttpClient(@"https://localhost:5001", new HttpClientHandler()
            {
                SslProtocols = SslProtocols.Tls, ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
            })
                                          .RegisterDefaultSerializers()
                                          .RegisterJsonNetSerializer()
                                          .Build();

            Console.WriteLine("About to call intercepted method.");

            Task <TestReturnModel> result = apiInterface.TestMethod(new TestModel(12456, "Two"), "test");

            Console.WriteLine("API method temporarily yielded.");

            await result;

            Console.WriteLine($"Finished call intercepted method. Result: {result.Result.ReturnValue}");
        }