Esempio n. 1
0
        public void IsUsing_Type_Type_WithCache(int cacheSize, int expectedComparisons)
        {
            // Force flush cache by setting size to zero and asking for usage of some type not previously used
            var fake = CecilProjectTest.CreateProject().FindType(typeof(FakeType).FullName);

            Usage.CacheSize = 0;

            fake.IsUsing(fake);

            Usage.CacheSize = cacheSize;

            // Configure mocks to equal themselves so they pass cache verification
            var source = new Mock <NBrowse.Reflection.Type>();
            var target = new Mock <NBrowse.Reflection.Type>();

            source.Setup(type => type.Equals(source.Object)).Returns(true);
            target.Setup(type => type.Equals(target.Object)).Returns(true);

            // Call "IsUsing" a first time and verify type equality was used exactly once
            Assert.That(source.Object.IsUsing(target.Object), Is.False);

            source.Verify(type => type.Equals(target.Object), Times.Once());

            // Call "IsUsing" a second time and verify type equality was used depending on cache status
            Assert.That(source.Object.IsUsing(target.Object), Is.False);

            source.Verify(type => type.Equals(target.Object), Times.Exactly(expectedComparisons));
        }
Esempio n. 2
0
 private static NBrowse.Reflection.Type GetType(string name)
 {
     return(CecilProjectTest.CreateProject().FindType(name));
 }
Esempio n. 3
0
 private static Method GetMethod(string name)
 {
     return(CecilProjectTest.CreateProject().FindMethod(name));
 }