public void Test_LiveModel_ChooseRankE2E() { LiveModel liveModel = this.ConfigureLiveModel(); RankingResponse rankingResponse1 = liveModel.ChooseRank(PseudoLocEventId, PseudoLocContextJsonWithPdf); ValidatePdf(rankingResponse1); RankingResponse rankingResponse2 = liveModel.ChooseRank(PseudoLocEventId, PseudoLocContextJsonWithPdf, ActionFlags.Deferred); ValidatePdf(rankingResponse2); }
public void Test_AsyncSender_SendSuccess() { ManualResetEventSlim senderCalledWaiter = new ManualResetEventSlim(initialState: false); bool sendCalled = false; Task AsyncSenderSend(SharedBuffer buffer, BackgroundErrorCallback raiseBackgroundError) { sendCalled = true; senderCalledWaiter.Set(); return(Task.CompletedTask); } FactoryContext factoryContext = CreateFactoryContext(asyncSendFunc: AsyncSenderSend); LiveModel liveModel = CreateLiveModel(factoryContext); liveModel.Init(); RankingResponse response = liveModel.ChooseRank(EventId, ContextJsonWithPdf); senderCalledWaiter.Wait(TimeSpan.FromSeconds(1)); Assert.IsTrue(sendCalled); }
/// <summary> Wrapper method of ChooseRank </summary> public override RankingResponseWrapper ChooseRank(string eventId, string contextJson, ActionFlags actionFlags) { RankingResponse rankingResponse = liveModel.ChooseRank(eventId, contextJson, actionFlags); RankingResponseWrapper rankingResponseWrapper = rankingResponse == null ? null : new RankingResponseWrapper(rankingResponse); return(rankingResponseWrapper); }
private void Run_LiveModelChooseRankWithFlags_Test(LiveModel liveModel, string eventId, string contextJson) { NativeMethods.LiveModelChooseRankWithFlagsOverride = (IntPtr liveModelPtr, IntPtr eventIdPtr, IntPtr contextJsonPtr, uint flags, IntPtr rankingResponse, IntPtr apiStatus) => { string eventIdMarshalledBack = NativeMethods.StringMarshallingFunc(eventIdPtr); Assert.AreEqual(eventId, eventIdMarshalledBack, "Marshalling eventId does not work properly in LiveModelChooseRank"); string contextJsonMarshalledBack = NativeMethods.StringMarshallingFunc(contextJsonPtr); Assert.AreEqual(contextJson, contextJsonMarshalledBack, "Marshalling contextJson does not work properly in LiveModelChooseRank"); return(NativeMethods.SuccessStatus); }; liveModel.ChooseRank(eventId, contextJson, ActionFlags.Deferred); }
public void Test_CustomSender_SendSuccess() { ManualResetEventSlim senderCalledWaiter = new ManualResetEventSlim(initialState: false); bool sendCalled = false; void SenderSend(SharedBuffer buffer, ApiStatus status) { sendCalled = true; senderCalledWaiter.Set(); } FactoryContext factoryContext = CreateFactoryContext(sendAction: SenderSend); LiveModel liveModel = CreateLiveModel(factoryContext); liveModel.Init(); RankingResponse response = liveModel.ChooseRank(EventId, ContextJsonWithPdf); senderCalledWaiter.Wait(TimeSpan.FromSeconds(1)); Assert.IsTrue(sendCalled); }