예제 #1
0
        public void Create_Cached_Plugin_File()
        {
            Type[] types = new[] { typeof(TypeLoader), typeof(TypeLoaderTests), typeof(IUmbracoContext) };

            var typeList1 = new TypeLoader.TypeList(typeof(object), null);

            foreach (Type type in types)
            {
                typeList1.Add(type);
            }

            _typeLoader.AddTypeList(typeList1);
            _typeLoader.WriteCache();

            Attempt <IEnumerable <string> > plugins  = _typeLoader.TryGetCached(typeof(object), null);
            Attempt <IEnumerable <string> > diffType = _typeLoader.TryGetCached(typeof(object), typeof(ObsoleteAttribute));

            Assert.IsTrue(plugins.Success);

            // This will be false since there is no cache of that type resolution kind
            Assert.IsFalse(diffType.Success);

            Assert.AreEqual(3, plugins.Result.Count());
            IEnumerable <string> shouldContain = types.Select(x => x.AssemblyQualifiedName);

            // Ensure they are all found
            Assert.IsTrue(plugins.Result.ContainsAll(shouldContain));
        }