public static void Main(string[] args) { var host = "http://localhost:60944"; var factory = new HttpClientWrapperFactory() { DefaultHost = new Uri(host) }; factory.HttpClientSettings.MaxRetry = 3; var oauthApiClient = new HttpClientWrapperFactory().CreateFor <OAuthApiClient>(host); //var oauth2ClientHandler = new OAuth2ClientHandler(oauthApiClient); //factory.HttpClientSettings.OAuth2ClientHandler = oauth2ClientHandler; //oauth2ClientHandler.Login(); var testApiClient = factory.CreateFor <TestApiClient>(); string line; while ((line = Console.ReadLine()) != null) { //testApiClient.SetValue("myname", line); var val = testApiClient.GetValue("myname"); Console.WriteLine("val=" + val); } }
public void WhenGettingSingletonHttpClientWrapper_ThenReturnWrapper() { var factory = new HttpClientWrapperFactory(bugDatabaseFactoryMock.Object); var wrapper = factory.GetSingletonHttpClientWrapper(); Assert.NotNull(wrapper); }
public void WhenSameBugFactoryDiffrentWrapper_ThenReturnSingletonWrapper() { bugDatabaseFactoryMock.SetupSequence(f => f.GetHttpClientWrapper()) .Returns(new Mock <IHttpClientWrapper>().Object) .Throws(new Exception()); var factory1 = new HttpClientWrapperFactory(bugDatabaseFactoryMock.Object); var factory2 = new HttpClientWrapperFactory(bugDatabaseFactoryMock.Object); var wrapper1 = factory1.GetSingletonHttpClientWrapper(); var wrapper2 = factory2.GetSingletonHttpClientWrapper(); Assert.True(wrapper1.Equals(wrapper2)); }