public static void SetErrorWithResponse(IBitfinexClient client, string responseData, HttpStatusCode code) { var expectedBytes = Encoding.UTF8.GetBytes(responseData); var responseStream = new MemoryStream(); responseStream.Write(expectedBytes, 0, expectedBytes.Length); responseStream.Seek(0, SeekOrigin.Begin); var r = new Mock <HttpWebResponse>(); r.Setup(x => x.GetResponseStream()).Returns(responseStream); var we = new WebException("", null, WebExceptionStatus.Success, r.Object); var request = new Mock <IRequest>(); request.Setup(c => c.Headers).Returns(new WebHeaderCollection()); request.Setup(c => c.GetResponse()).Throws(we); var factory = Mock.Get(client.RequestFactory); factory.Setup(c => c.Create(It.IsAny <string>())) .Returns(request.Object); }
public BitfinexApiManager(IBitfinexClient client) { _bitfinexClient = client; }