public void testUserRescorer()
        {
            IDRescorer rescorer = NullRescorer.getUserInstance();

            Assert.NotNull(rescorer);
            Assert.AreEqual(1.0, rescorer.rescore(1L, 1.0), EPSILON);
            Assert.AreEqual(1.0, rescorer.rescore(0L, 1.0), EPSILON);
            Assert.AreEqual(0.0, rescorer.rescore(1L, 0.0), EPSILON);
            Assert.True(Double.IsNaN(rescorer.rescore(1L, Double.NaN)));
        }
        public void testRecommender()
        {
            var mockRecommender = new MockRecommender(0);

            IRecommender cachingRecommender = new CachingRecommender(mockRecommender);

            cachingRecommender.Recommend(1, 1);
            Assert.AreEqual(1, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1);
            Assert.AreEqual(2, mockRecommender.recommendCount);
            cachingRecommender.Recommend(1, 1);
            Assert.AreEqual(2, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1);
            Assert.AreEqual(2, mockRecommender.recommendCount);
            cachingRecommender.Refresh(null);
            cachingRecommender.Recommend(1, 1);
            Assert.AreEqual(3, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1);
            Assert.AreEqual(4, mockRecommender.recommendCount);
            cachingRecommender.Recommend(3, 1);
            Assert.AreEqual(5, mockRecommender.recommendCount);

            // Results from this recommend() method can be cached...
            IDRescorer rescorer = NullRescorer.getItemInstance();

            cachingRecommender.Refresh(null);
            cachingRecommender.Recommend(1, 1, rescorer);
            Assert.AreEqual(6, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1, rescorer);
            Assert.AreEqual(7, mockRecommender.recommendCount);
            cachingRecommender.Recommend(1, 1, rescorer);
            Assert.AreEqual(7, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1, rescorer);
            Assert.AreEqual(7, mockRecommender.recommendCount);

            // until you switch Rescorers
            cachingRecommender.Recommend(1, 1, null);
            Assert.AreEqual(8, mockRecommender.recommendCount);
            cachingRecommender.Recommend(2, 1, null);
            Assert.AreEqual(9, mockRecommender.recommendCount);

            cachingRecommender.Refresh(null);
            cachingRecommender.EstimatePreference(1, 1);
            Assert.AreEqual(10, mockRecommender.recommendCount);
            cachingRecommender.EstimatePreference(1, 2);
            Assert.AreEqual(11, mockRecommender.recommendCount);
            cachingRecommender.EstimatePreference(1, 2);
            Assert.AreEqual(11, mockRecommender.recommendCount);
        }