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);
}