public void TestCachingOfSentence() {

            var generator = new CachedFeatureGenerator(identityGenerator);

            const int testIndex = 0;
            const int testIndex2 = testIndex + 1;

            // after this call features are cached for testIndex
            generator.CreateFeatures(features, testSentence1, testIndex, null);

            Assert.AreEqual(1, generator.NumberOfCacheMisses);
            Assert.AreEqual(0, generator.NumberOfCacheHits);

            Assert.True(features.Contains(testSentence1[testIndex]));

            features.Clear();

            // check if features are really cached

            var expectedToken = testSentence1[testIndex];

            testSentence1[testIndex] = null;

            generator.CreateFeatures(features, testSentence1, testIndex, null);

            Assert.AreEqual(1, generator.NumberOfCacheMisses);
            Assert.AreEqual(1, generator.NumberOfCacheHits);

            Assert.True(features.Contains(expectedToken));

            Assert.AreEqual(1, features.Count);

            features.Clear();

            // try caching with an other index

            generator.CreateFeatures(features, testSentence1, testIndex2, null);

            Assert.AreEqual(2, generator.NumberOfCacheMisses);
            Assert.AreEqual(1, generator.NumberOfCacheHits);

            Assert.True(features.Contains(testSentence1[testIndex2]));

            features.Clear();

            // now check if cache still contains feature for testIndex

            generator.CreateFeatures(features, testSentence1, testIndex, null);

            Assert.True(features.Contains(expectedToken));

        }
        public void TestCacheClearAfterSentenceChange() {

            var generator = new CachedFeatureGenerator(identityGenerator);

            const int testIndex = 0;

            // use generator with sentence 1
            generator.CreateFeatures(features, testSentence1, testIndex, null);

            features.Clear();

            // use another sentence but same index
            generator.CreateFeatures(features, testSentence2, testIndex, null);

            Assert.AreEqual(2, generator.NumberOfCacheMisses);
            Assert.AreEqual(0, generator.NumberOfCacheHits);

            Assert.True(features.Contains(testSentence2[testIndex]));

            Assert.AreEqual(1, features.Count);

            features.Clear();

            // check if features are really cached
            var expectedToken = testSentence2[testIndex];

            testSentence2[testIndex] = null;

            generator.CreateFeatures(features, testSentence2, testIndex, null);

            Assert.True(features.Contains(expectedToken));

            Assert.AreEqual(1, features.Count);

        }