示例#1
0
        public void PredictionWalkThrough()
        {
            var environment = new SingleThreadedPredictionEnvironment
            {
                History = "the them they them they the the the" + Environment.NewLine
            };

            var predictor = PredictionEngineFactory.Create(environment);

            Assert.IsNotNull(predictor, "We got a predictor");

            CheckPrediction(predictor, "");

            Assert.AreEqual(1, environment.workItems.Count, "Queue contains the refresh action");
            environment.workItems[0]();
            environment.workItems.RemoveAt(0);
            Assert.AreEqual(0, environment.workItems.Count, "Queue is now empty");

            CheckPrediction(predictor, "", "the", "they", "them");

            Assert.AreEqual(0, environment.workItems.Count, "Queue is still empty");

            CheckPrediction(predictor, "t", "the", "they", "them");
            CheckPrediction(predictor, "th", "they", "the", "them");
            CheckPrediction(predictor, "the", "them", "the", "they");

            predictor.RecordHistory("Wibble", false);
            Assert.AreEqual("the them they them they the the the" + Environment.NewLine + "Wibble" + Environment.NewLine, environment.History, "History should have updated");
        }
示例#2
0
        public void ComplexCreation()
        {
            var environment = new SingleThreadedPredictionEnvironment(true);
            var queue       = new List <Action>();

            var predictor = PredictionEngineFactory.Create(environment);

            Assert.IsNotNull(predictor, "We got a predictor");

            Assert.AreEqual(1, environment.workItems.Count, "Queue contains the refresh action");

            var updated = false;

            predictor.PredictionChanged += (s, e) => updated = true;
            environment.workItems[0]();
            Assert.IsTrue(updated);
            environment.workItems.RemoveAt(0);

            Assert.AreEqual(0, environment.workItems.Count, "Queue is now empty");
        }