예제 #1
0
        public void TestBatchingByCount()
        {
            var serviceConfig = new DecisionServiceConfiguration<TestContext>("",
                new EpsilonGreedyExplorer<TestContext>(new TestPolicy(), epsilon: 0.2f, numActions: 10))
            {
                BatchConfig = new BatchingConfiguration()
                {
                    MaxDuration = TimeSpan.FromDays(30),
                    MaxEventCount = 2,
                    MaxBufferSizeInBytes = 10 * 1024 * 1024
                }
            };

            var service = new DecisionService<TestContext>(serviceConfig);

            string uniqueKey = "eventid";

            service.ChooseAction(uniqueKey, new TestContext());
            service.ReportOutcome("my json outcome", uniqueKey);
            service.ReportReward(0.5f, uniqueKey);

            var batch = JsonConvert.DeserializeObject<EventBatch>(File.ReadAllText(batchOutputFile), new EventJsonConverter());
            Assert.AreEqual(2, batch.Events.Count);
        }