public void ShareLink( int requestId, string contentURL, string contentTitle, string contentDescription, string photoURL) { this.LogMethodCall(); var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.Facebook.OnShareLinkComplete(new ResultContainer(result)); }
public void Init() { IDictionary <string, object> resultExtra = this.ResultExtras; if (resultExtra != null) { this.Facebook.OnInitComplete( new ResultContainer(MockResults.GetGenericResult(0, resultExtra))); } else { this.Facebook.OnInitComplete( new ResultContainer(string.Empty)); } }
public void FeedShare( int requestId, string toId, string link, string linkName, string linkCaption, string linkDescription, string picture, string mediaSource) { this.LogMethodCall(); var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.Facebook.OnShareLinkComplete(new ResultContainer(result)); }
public void DoAppRequestRequest( string appId, string message, string actionType, string objectId, string to, string filters, string excludeIDs, string maxRecipients, string data, string title, string callbackID, GameroomFacebook.OnComplete completeDelegate) { int cbid = Convert.ToInt32(callbackID); completeDelegate(new ResultContainer(MockResults.GetGenericResult(cbid, this.ResultExtras))); }
public void AppRequest( int requestId, string message, string actionType, string objectId, string[] to = null, int toLength = 0, string filters = "", string[] excludeIds = null, int excludeIdsLength = 0, bool hasMaxRecipients = false, int maxRecipients = 0, string data = "", string title = "") { this.LogMethodCall(); var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.Facebook.OnAppRequestsComplete(new ResultContainer(result)); }
public void Init(GameroomFacebook.OnComplete completeDelegate) { // Handle testing of init returning access token. It would be nice // to not have init return the access token but this could be // a breaking change for people who read the raw result ResultContainer resultContainer; IDictionary <string, object> resultExtras = this.ResultExtras; if (resultExtras != null) { var result = MockResults.GetGenericResult(0, resultExtras); resultContainer = new ResultContainer(result); } else { resultContainer = new ResultContainer(string.Empty); } completeDelegate(resultContainer); }
public void Init(string connectFacebookUrl, string locale, int debug, string initParams, int status) { this.LogMethodCall(); // Handle testing of init returning access token. It would be nice // to not have init return the access token but this could be // a breaking change for people who read the raw result ResultContainer resultContainer; IDictionary <string, object> resultExtras = this.ResultExtras; if (resultExtras != null) { var result = MockResults.GetGenericResult(0, resultExtras); resultContainer = new ResultContainer(result); } else { resultContainer = new ResultContainer(string.Empty); } this.Facebook.OnInitComplete(resultContainer); }
public void CallStatic(string methodName, params object[] args) { this.LogMethodCall(methodName); Utilities.Callback <ResultContainer> callback = null; IDictionary <string, object> result; IDictionary <string, object> methodArguments = null; int callbackID = -1; if (args.Length == 1) { var jsonParams = (string)args[0]; if (jsonParams != null) { methodArguments = MiniJSON.Json.Deserialize(jsonParams) as IDictionary <string, object>; string callbackStr; if (methodArguments != null && methodArguments.TryGetValue(Constants.CallbackIdKey, out callbackStr)) { callbackID = int.Parse(callbackStr); } } } if (callbackID == -1 && methodName != "Init") { // There was no callback so just return; return; } if (methodName == "Init") { callback = this.MobileFacebook.OnInitComplete; result = MockResults.GetGenericResult(0, this.ResultExtras); } else if (methodName == "GetAppLink") { callback = this.Facebook.OnGetAppLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "AppRequest") { callback = this.Facebook.OnAppRequestsComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "FeedShare") { callback = this.Facebook.OnShareLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "ShareLink") { callback = this.Facebook.OnShareLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "LoginWithPublishPermissions" || methodName == "LoginWithReadPermissions") { callback = this.Facebook.OnLoginComplete; string permissions; methodArguments.TryGetValue(AndroidFacebook.LoginPermissionsKey, out permissions); result = MockResults.GetLoginResult( callbackID, permissions, this.ResultExtras); } else if (methodName == "RefreshCurrentAccessToken") { callback = this.MobileFacebook.OnRefreshCurrentAccessTokenComplete; result = MockResults.GetLoginResult( callbackID, string.Empty, this.ResultExtras); } else { throw new NotImplementedException("Not implemented for " + methodName); } callback(new ResultContainer(result)); }
public void ExternalCall(string functionName, object[] args) { this.LogMethodCall(functionName); IDictionary <string, object> result; OnResult callback = null; if (functionName == "FBUnity.logAppEvent") { // Workaround log the method call to match the signature of ios and android. this.LogMethodCall("LogAppEvent"); // No callback on log app event return; } else if (functionName == "FBUnity.login") { var permissions = (IEnumerable <string>)args[0]; var callbackID = int.Parse((string)args[1]); result = MockResults.GetLoginResult(callbackID, permissions, this.ResultExtras); callback = this.Facebook.OnLoginComplete; } else if (functionName == "FBUnity.ui") { var callbackMetod = (string)args[2]; var callbackID = int.Parse((string)args[1]); if (callbackMetod == Constants.OnGroupCreateCompleteMethodName) { result = MockResults.GetGroupCreateResult(callbackID, this.ResultExtras); callback = this.Facebook.OnGroupCreateComplete; } else if (callbackMetod == Constants.OnGroupJoinCompleteMethodName) { result = MockResults.GetGenericResult(callbackID, this.ResultExtras); callback = this.Facebook.OnGroupJoinComplete; } else if (callbackMetod == Constants.OnAppRequestsCompleteMethodName) { result = MockResults.GetGenericResult(callbackID, this.ResultExtras); callback = this.Facebook.OnAppRequestsComplete; } else if (callbackMetod == Constants.OnShareCompleteMethodName) { result = MockResults.GetGenericResult(callbackID, this.ResultExtras); callback = this.Facebook.OnShareLinkComplete; } else if (callbackMetod == Constants.OnPayCompleteMethodName) { result = MockResults.GetGenericResult(callbackID, this.ResultExtras); callback = this.CanvasFacebook.OnPayComplete; } else { throw new NotImplementedException("Mock missing ui function: " + callbackMetod); } } else { throw new NotImplementedException("Mock missing function: " + functionName); } callback(result.ToJson()); }
public void OpenFriendFinderDialog(int requestId) { var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.MobileFacebook.OnFriendFinderComplete(new ResultContainer(result)); }
public void GetAppLink(int requestId) { var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.Facebook.OnGetAppLinkComplete(new ResultContainer(result)); }
public void GetAppLink(int requestId) { var result = MockResults.GetGenericResult(requestId, this.ResultExtras); this.Facebook.OnGetAppLinkComplete(MiniJSON.Json.Serialize(result)); }
internal MockResults SetupHttpAbstractionMocking() { var results = new MockResults(); // Locate the test manager so we can override the lower layer. var manager = ServiceLocator.Instance.Locate <IServiceLocationIndividualTestManager>(); // Create a Mock of the HTTP layer response. var moqResponse = new Moq.Mock <IHttpResponseMessageAbstraction>(MockBehavior.Loose); // Always return 200 OK moqResponse.SetupGet(res => res.StatusCode) .Returns(HttpStatusCode.OK); // Create a mock of the Request client. var moqClient = new Moq.Mock <IHttpClientAbstraction>(MockBehavior.Loose); // Mock the return to set the request headers. moqClient.SetupGet(client => client.RequestHeaders) .Returns(() => results.Headers); // Mock the return to set the request uri. moqClient.SetupGet(client => client.RequestUri) .Returns(() => results.RequestUri); // Mock the return to set the request uri. moqClient.SetupSet(abstraction => abstraction.RequestUri = It.IsAny <Uri>()).Callback <Uri>(uri => results.RequestUri = uri); // Mock the return to set the http method. moqClient.SetupGet(client => client.Method) .Returns(() => results.Method); // Mock the return to set the http method. moqClient.SetupSet(abstraction => abstraction.Method = It.IsAny <HttpMethod>()).Callback <HttpMethod>(method => results.Method = method); // Mock the return to set the content. moqClient.SetupGet(client => client.Content) .Returns(() => results.Content); moqClient.SetupSet(abstraction => abstraction.Content = It.IsAny <HttpContent>()).Callback <HttpContent>(content => results.Content = content); // Mock the SendAsync method (to just return the response object previously created). moqClient.Setup(c => c.SendAsync()) .Returns(() => Task.Run(() => { results.SendAsyncCalled = true; return(moqResponse.Object); })); // Mock the factory to return our mock client. var moqFactory = new Moq.Mock <IHttpClientAbstractionFactory>(); // Overload both create methods. moqFactory.Setup(fac => fac.Create(It.IsAny <X509Certificate2>(), It.IsAny <HDInsight.IAbstractionContext>(), false)) .Returns(() => moqClient.Object); moqFactory.Setup(fac => fac.Create(It.IsAny <HDInsight.IAbstractionContext>(), false)) .Returns(() => moqClient.Object); // Override the factory in the Service Locator (for this test only). manager.Override <IHttpClientAbstractionFactory>(moqFactory.Object); return(results); }
internal MockResults SetupHttpAbstractionMocking() { var results = new MockResults(); // Locate the test manager so we can override the lower layer. var manager = ServiceLocator.Instance.Locate<IServiceLocationIndividualTestManager>(); // Create a Mock of the HTTP layer response. var moqResponse = new Moq.Mock<IHttpResponseMessageAbstraction>(MockBehavior.Loose); // Always return 200 OK moqResponse.SetupGet(res => res.StatusCode) .Returns(HttpStatusCode.OK); // Create a mock of the Request client. var moqClient = new Moq.Mock<IHttpClientAbstraction>(MockBehavior.Loose); // Mock the return to set the request headers. moqClient.SetupGet(client => client.RequestHeaders) .Returns(() => results.Headers); // Mock the return to set the request uri. moqClient.SetupGet(client => client.RequestUri) .Returns(() => results.RequestUri); // Mock the return to set the request uri. moqClient.SetupSet(abstraction => abstraction.RequestUri = It.IsAny<Uri>()).Callback<Uri>(uri => results.RequestUri = uri); // Mock the return to set the http method. moqClient.SetupGet(client => client.Method) .Returns(() => results.Method); // Mock the return to set the http method. moqClient.SetupSet(abstraction => abstraction.Method = It.IsAny<HttpMethod>()).Callback<HttpMethod>(method => results.Method = method); // Mock the return to set the content. moqClient.SetupGet(client => client.Content) .Returns(() => results.Content); moqClient.SetupSet(abstraction => abstraction.Content = It.IsAny<HttpContent>()).Callback<HttpContent>(content => results.Content = content); // Mock the SendAsync method (to just return the response object previously created). moqClient.Setup(c => c.SendAsync()) .Returns(() => Task.Run(() => { results.SendAsyncCalled = true; return moqResponse.Object; })); // Mock the factory to return our mock client. var moqFactory = new Moq.Mock<IHttpClientAbstractionFactory>(); // Overload both create methods. moqFactory.Setup(fac => fac.Create(It.IsAny<X509Certificate2>(), It.IsAny<HDInsight.IAbstractionContext>(), false)) .Returns(() => moqClient.Object); moqFactory.Setup(fac => fac.Create(It.IsAny<HDInsight.IAbstractionContext>(), false)) .Returns(() => moqClient.Object); // Override the factory in the Service Locator (for this test only). manager.Override<IHttpClientAbstractionFactory>(moqFactory.Object); return results; }