static void Main(string[] args) { try { Console.WriteLine("Let me know when the server's ready"); Console.ReadLine(); var valuesClient = new ValuesClient( /* this way you can deploy somewhere * and tell the client how to find it * and not have to change ur codez */ new Uri("http://localhost:62611/") ); var results = valuesClient.GetValues(); foreach (var value in results) { Console.WriteLine(value); } } catch (Exception x) { Console.WriteLine(x); Debugger.Break(); } Console.WriteLine("Finished"); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Тестирование изменений данных через сервис"); var client = new ValuesClient(new HttpClient{BaseAddress = new Uri(__WebAPI)}); PrintData(client, "Элементы изначально:"); Console.WriteLine("Нажмите любую кнопку и будет удален один элемент"); Console.ReadKey(); var result = client.Delete(0); if (result) Console.WriteLine("Элемент успешно удален"); Console.WriteLine("Нажмите кнопку для добавления элемента"); Console.ReadKey(); client.Add("new"); Console.WriteLine("Элемент добавлен"); PrintData(client, "Элементы сейчас:"); Console.WriteLine("Для завершения нажмите любую кнопку ..."); Console.ReadLine(); }
public UnitTest1() { if (this._client == null) { this._client = new ValuesClient(); this._client.HttpClient.BaseAddress = new Uri("http://localhost:56364"); } }
private static void PrintData(ValuesClient client, string message) { Console.WriteLine(message); foreach (var item in client.GetAll()) { Console.WriteLine($"{item}"); } }
public ClientTests() { mockHttp = new MockHttpMessageHandler(); var httpClient = mockHttp.ToHttpClient(); httpClient.BaseAddress = new Uri("http://localhost"); client = new ValuesClient(httpClient); }
static void Main(string[] args) { var url = "http://localhost:56685"; var client = new ValuesClient(url, new System.Net.Http.HttpClient()); var values = client.GetAll(); foreach (var val in values) { Console.WriteLine(val); } }
public static void Main() { WriteLine("Welcome to Nswag Generated Client"); ValuesClient testClient = new ValuesClient(); //ValuesClient testClient = new ValuesClient("http://localhost:44355"); // Call GetAsync Values API string getresult = testClient.GetAsync(1).GetAwaiter().GetResult(); // Call GetAllAsync Values API ICollection <string> getAllresult = testClient.GetAllAsync().GetAwaiter().GetResult(); }