예제 #1
0
 public void Setup()
 {
     _assembly  = typeof(ReflectionCacheBenchmark).Assembly;
     _types     = _assembly.GetTypes().ToArray();
     _assistant = new ReflectionCache()
                  .AddTypes(_assembly)
                  .Prepare()
     ;
     _assistantBitArray = new ReflectionCacheUsingBitArray()
                          .AddTypes(_assembly)
                          .Prepare()
     ;
 }
예제 #2
0
        public void Lookup_ExistingGeneric_ReturnsValid()
        {
            var assistant = new ReflectionCache();

            assistant.AddTypes(GetType().Assembly);
            assistant.Prepare();

            var actual = assistant
                         .Lookup(typeof(ISampleGenericContract <int>))
                         .ToArray()
            ;

            Assert.Single(actual);
            Assert.Equal(typeof(SampleInstance), actual.Single());
        }
예제 #3
0
        public void Lookup_ValidatorForSpecificType_ReturnsValidatorForContract()
        {
            var assistant = new ReflectionCache();

            assistant.AddTypes(GetType().Assembly);
            assistant.Prepare();

            var actual = assistant
                         .Lookup(typeof(IValidator <ValidatedRequest>))
                         .ToArray()
            ;

            Assert.Single(actual);
            Assert.Equal(typeof(SomeValidator), actual.Single());
        }