public void GenerateRankResultTest() { List <PersonalizerRankableAction> originalActions = GetActions(); List <PersonalizerRankableAction> rankableActions = new List <PersonalizerRankableAction>(); List <PersonalizerRankableAction> excludedActions = new List <PersonalizerRankableAction>(); rankableActions.Add(originalActions[1]); rankableActions.Add(originalActions[2]); rankableActions.Add(originalActions[3]); excludedActions.Add(originalActions[0]); List <ActionProbabilityWrapper> rankedActions = new List <ActionProbabilityWrapper> { new ActionProbabilityWrapperForTest(0, 0.7f), new ActionProbabilityWrapperForTest(1, 0.2f), new ActionProbabilityWrapperForTest(2, 0.1f) }; RankingResponseWrapper responseWrapper = new RankingResponseWrapperForTest(rankedActions); string eventId = "testEventId"; PersonalizerRankResult rankResponse = RlObjectConverter.GenerateRankResult(originalActions, rankableActions, excludedActions, responseWrapper, eventId); Assert.AreEqual("action1", rankResponse.RewardActionId); Assert.AreEqual(originalActions.Count, rankResponse.Ranking.Count); for (int i = 0; i < rankResponse.Ranking.Count; i++) { Assert.AreEqual(originalActions[i].Id, rankResponse.Ranking[i].Id); } }
private RlNetProcessor SetupRlNetProcessor() { Mock <LiveModelBase> mockLiveModel = new Mock <LiveModelBase>(); List <ActionProbabilityWrapper> actionProbability = new List <ActionProbabilityWrapper> { new ActionProbabilityWrapperForTest(0, 1f) }; RankingResponseWrapper responseWrapper = new RankingResponseWrapperForTest(actionProbability); mockLiveModel.Setup(m => m.ChooseRank(It.IsAny <string>(), It.IsAny <string>(), ActionFlags.Default)).Returns(responseWrapper); Dictionary <string, List <ActionProbabilityWrapper> > slotRankedActions = GetSlotActionProbabilityList(); List <SlotRankingWrapper> rankedSlots = new List <SlotRankingWrapper>(); foreach (var item in slotRankedActions) { var slotRankingWrapperForTest = new SlotRankingWrapperForTest(item.Value.FirstOrDefault().ActionIndex, item.Key, item.Value); rankedSlots.Add(slotRankingWrapperForTest); } MultiSlotResponseDetailedWrapper multiSlotResponseWrapper = new MultiSlotResponseWrapperForTest(rankedSlots); mockLiveModel.Setup(m => m.RequestMultiSlotDecisionDetailed(It.IsAny <string>(), It.IsAny <string>(), ActionFlags.Default, It.IsAny <int[]>())).Returns(multiSlotResponseWrapper); mockLiveModel.Setup(m => m.QueueOutcomeEvent(It.IsAny <string>(), It.IsAny <float>())).Verifiable(); mockLiveModel.Setup(m => m.QueueOutcomeEvent(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <float>())).Verifiable(); mockLiveModel.Setup(m => m.QueueActionTakenEvent(It.IsAny <string>())).Verifiable(); return(new RlNetProcessor(mockLiveModel.Object)); }