public void Post_ValidPOSTRequestDataSupplied_SendRequestSendMethodIsCalled() { var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost, new ServiceProxyUtility(), _serviceRequest); proxy.Post("videos.json", new Dictionary<string, string> { { "some_parameter", "some_value" }, { "another_parameter", "another_value" } }); _serviceRequest.AssertWasCalled(req => req.Send()); }
public void Post_FileDataSupplied_ServiceRequestPopulatedWithFileData() { var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost, new ServiceProxyUtility(), _serviceRequest); byte[] file = new byte[8]; string fileName = "somefile.jpg"; proxy.Post("videos.json", new Dictionary<string, string> { { "some_parameter", "some_value" }, { "another_parameter", "another_value" } }, file, fileName); Assert.AreEqual(file, _serviceRequest.File); Assert.AreEqual(fileName, _serviceRequest.FileName); }
public void BuildRequest_GETRequestDataSupplied_ReturnsValidIPandaServiceRequest() { var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost); var request = proxy.BuildRequest("get", "videos.json", new Dictionary<string, string> { { "some_parameter", "some_value" }, { "another_parameter", "another_value" } }); Assert.IsTrue(request.Verb == "GET", "request method should retain verb passed to RestClient"); Assert.IsTrue(request.BaseUrl == "http://api.pandastream.com/v2/videos.json", "base url should contain the host, version and path passed to RestClient"); Assert.IsTrue(request.Url.Contains("http://api.pandastream.com/v2/videos.json?some_parameter=some_value&another_parameter=another_value&access_key=some_access_key&cloud_id=some_cloud_id×tamp="), "Url should contain host, version, path and query string parameters for GET requests"); Assert.IsTrue(request.SignedParameters.Contains( "some_parameter=some_value&another_parameter=another_value&access_key=some_access_key&cloud_id=some_cloud_id×tamp="), "SignedParameters should contain the supplied parameters, access key, cloudId and timestamp in the query string of a GET request"); Assert.IsTrue(request.SignedParameters.Contains( "&signature="), "SignedParameters should be signed"); Console.WriteLine("Verb: {0}", request.Verb); Console.WriteLine("BaseUrl: {0}", request.BaseUrl); Console.WriteLine("SignedParameters: {0}", request.SignedParameters); Console.WriteLine("Url: {0}", request.Url); }
public void BuildRequest_PUTRequestDataSupplied_ReturnsValidIPandaServiceRequest() { var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost); var request = proxy.BuildRequest("put", "videos.json", new Dictionary<string, string> { { "some_parameter", "some_value" }, { "another_parameter", "another_value" } }); Assert.IsTrue(request.Verb == "PUT", "request method should retain verb passed to RestClient"); Assert.IsTrue(request.BaseUrl == "http://api.pandastream.com/v2/videos.json", "base url should contain the host, version and path passed to RestClient"); Assert.IsTrue(request.Url.Equals("http://api.pandastream.com/v2/videos.json"), "Url should contain host, version and path with no query string parameters for POST and PUT requests"); Console.WriteLine("Verb: {0}", request.Verb); Console.WriteLine("BaseUrl: {0}", request.BaseUrl); Console.WriteLine("SignedParameters: {0}", request.SignedParameters); Console.WriteLine("Url: {0}", request.Url); }
public void SignatureGenerator_ValidRequestDataSupplied_ReturnsValidSignature() { var proxy = new ServiceProxy(_cloudId, _accessKey, _secretKey, _apiHost); var signature = proxy.SignatureGenerator("get", "videos.json", "api.pandastream.com", _secretKey, new Dictionary<string, string> { { "some_parameter", "some_value" }, { "another_parameter", "another_value" } }); Assert.AreEqual("z4gJjCHfeJtPjhFKcepIvmfYSyRQPTPbkTGpRoo0UWU=", signature); }