public async Task ThrowServiceException() { // arrange var exception = default(Exception); _endpoint = new HttpEndpoint { BaseAddress = "http://not-found.de/123", Request = "", MethodName = "" }; // act try { _service = new GenericService(new HttpClient(), _endpoint); _service.CallResponded += (o, e) => { Log.Info($"Http responded with code: {e.StatusCode}"); }; var result = await _service.CallAsync <object>((s) => JsonIO.FromJsonString <object>(s)); } catch (Exception ex) { Log.Fatal(ex); exception = ex; } // assert Assert.IsNotNull(exception); }
public void ExportInterfacesAndImportJson() { // assert var input = new InterfaceRepository(); input.Add(new TestClassA()); input.Add(new TestClassB()); input.Add(new TestClassA()); input.Add(new TestClassA()); var binder = new TypedSerializationBinder(new List <Type> { typeof(TestClassA), typeof(TestClassB) }); string json = JsonIO.ToJsonString(input, binder); // act var output = JsonIO.FromJsonString <InterfaceRepository>(json, binder); // Assert for (int i = 0; i < output.Count; i++) { Assert.AreEqual(output[i].Name, input[i].Name, $"Name property at {i} is not equal"); Assert.AreEqual(output[i].Id, input[i].Id, $"Id property at {i} is not equal"); } }
public async Task ServiceCallAsync() { // arrange _endpoint = new HttpEndpoint { BaseAddress = "https://api.abalin.net", Request = "/get/today?country=de", MethodName = "get" }; _service = new GenericService(new HttpClient(), _endpoint); _service.CallResponded += (o, e) => { Log.Info($"Http responded with code: {e.StatusCode}"); }; // act var result = await _service.CallAsync <object>((s) => JsonIO.FromJsonString <object>(s)); // assert Assert.IsNotNull(result); }
public T As <T>() where T : new() { return(JsonIO.FromJsonString <T>(_importJson, _setting.Binder)); }