private void EndInternal() { PackageHandler.PauseSending(); AttributionHandler.PauseSending(); StopTimer(); if (UpdateActivityState(DateTime.Now)) { WriteActivityStateInternal(); } }
private void UpdateAttributionHandlerStatus() { if (Paused()) { AttributionHandler.PauseSending(); } else { AttributionHandler.ResumeSending(); } }
private void CheckAttributionState() { // if it's a new session if (ActivityState.SubSessionCount <= 1) { return; } // if there is already an attribution saved and there was no attribution being asked if (Attribution != null && !ActivityState.AskingAttribution) { return; } AttributionHandler.AskAttribution(); }
public void FinishedTrackingActivity(Dictionary <string, string> jsonDict) { LaunchDeepLink(jsonDict); AttributionHandler.CheckAttribution(jsonDict); }
private void WrongJsonTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler, ResponseType.WRONG_JSON); Assert.Verbose("Response: not a json response"); Assert.Error("Failed to parse json response (Unexpected character encountered while parsing"); }
public void TestAskIn() { AttributionHandler attributionHandler = new AttributionHandler( activityHandler: MockActivityHandler, attributionPackage: AttributionPackage, startPaused: false, hasDelegate: true); var response = "Response: {{ \"ask_in\" : 4000 }}"; CallCheckAttributionWithGet(attributionHandler, ResponseType.ASK_IN, response); // change the response to avoid a cycle; MockHttpMessageHandler.ResponseType = ResponseType.MESSAGE; // check attribution was called with ask_in Assert.NotTest("ActivityHandler UpdateAttribution"); // it did update to true Assert.Test("ActivityHandler SetAskingAttribution, True"); // and waited to for query Assert.Debug("Waiting to query attribution in 4000 milliseconds"); DeviceUtil.Sleep(2000); var askInJsonResponse = new Dictionary<string, string>{{ "ask_in", "5000" }}; attributionHandler.CheckAttribution(askInJsonResponse); DeviceUtil.Sleep(3000); // it did update to true Assert.Test("ActivityHandler SetAskingAttribution, True"); // and waited to for query Assert.Debug("Waiting to query attribution in 5000 milliseconds"); // it was been waiting for 1000 + 2000 + 3000 = 6 seconds // check that the mock http client was not called because the original clock was reseted Assert.NotTest("HttpMessageHandler SendAsync"); // check that it was finally called after 6 seconds after the second ask_in DeviceUtil.Sleep(3000); OkMessageTestLogs(); RequestTest(MockHttpMessageHandler.HttpRequestMessage); }
private void ServerErrorTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler, ResponseType.INTERNAL_SERVER_ERROR); // the response logged Assert.Verbose("Response: {{ \"message\": \"testResponseError\"}}"); // the message in the response Assert.Error("testResponseError"); // check attribution was called without ask_in Assert.Test("ActivityHandler UpdateAttribution, Null"); Assert.Test("ActivityHandler SetAskingAttribution, False"); }
private void StartGetAttributionTest(AttributionHandler attributionHandler, ResponseType responseType) { MockHttpMessageHandler.ResponseType = responseType; attributionHandler.AskAttribution(); DeviceUtil.Sleep(1000); RequestTest(MockHttpMessageHandler.HttpRequestMessage); Assert.Test("HttpMessageHandler SendAsync"); }
private void NullClientTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler: attributionHandler, responseType: ResponseType.NULL); // check error Assert.Error("Failed to get attribution (Object reference not set to an instance of an object.)"); // check response was not logged Assert.NotVerbose("Response"); }
private void OkMessageTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler, ResponseType.MESSAGE); OkMessageTestLogs(); }
private void EmptyJsonResponseTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler, ResponseType.EMPTY_JSON); Assert.Verbose("Response: {{ }}"); Assert.Info("No message found"); // check attribution was called without ask_in Assert.Test("ActivityHandler UpdateAttribution, Null"); Assert.Test("ActivityHandler SetAskingAttribution, False"); }
private void ClientExceptionTest(AttributionHandler attributionHandler) { StartGetAttributionTest(attributionHandler, ResponseType.CLIENT_PROTOCOL_EXCEPTION); // check the client error Assert.Error("Failed to get attribution (testResponseError)"); }
private void CallCheckAttributionWithGet(AttributionHandler attributionHandler, ResponseType responseType, string response) { StartGetAttributionTest(attributionHandler, responseType); // the response logged Assert.Verbose(response); }
public void TestWithoutListener() { AttributionHandler attributionHandler = new AttributionHandler( activityHandler: MockActivityHandler, attributionPackage: AttributionPackage, startPaused: false, hasDelegate: false); MockHttpMessageHandler.ResponseType = ResponseType.MESSAGE; attributionHandler.AskAttribution(); DeviceUtil.Sleep(1000); // check that the activity handler is not paused Assert.NotDebug("Attribution handler is paused"); // but it did not call the http client Assert.Null(MockHttpMessageHandler.HttpRequestMessage); Assert.NotTest("HttpMessageHandler SendAsync"); }
public void TestCheckAttribution() { AttributionHandler attributionHandler = new AttributionHandler( activityHandler: MockActivityHandler, attributionPackage: AttributionPackage, startPaused: false, hasDelegate: true); var response = "Response: {{ \"attribution\" : " + "{{\"tracker_token\" : \"ttValue\" , " + "\"tracker_name\" : \"tnValue\" , " + "\"network\" : \"nValue\" , " + "\"campaign\" : \"cpValue\" , " + "\"adgroup\" : \"aValue\" , " + "\"creative\" : \"ctValue\" , " + "\"click_label\" : \"clValue\" }} }}"; CallCheckAttributionWithGet(attributionHandler, ResponseType.ATTRIBUTION, response); // check attribution was called without ask_in Assert.Test("ActivityHandler UpdateAttribution, tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); // updated set askingAttribution to false Assert.Test("ActivityHandler SetAskingAttribution, False"); // it did not update to true Assert.NotTest("ActivityHandler SetAskingAttribution, True"); // and waiting for query Assert.NotDebug("Waiting to query attribution"); }