public void Create_Cached_Plugin_File() { var types = new[] { typeof(TypeLoader), typeof(TypeLoaderTests), typeof(UmbracoContext) }; var typeList1 = new TypeLoader.TypeList(typeof(object), null); foreach (var type in types) { typeList1.Add(type); } _typeLoader.AddTypeList(typeList1); _typeLoader.WriteCache(); var plugins = _typeLoader.TryGetCached(typeof(object), null); var 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()); var shouldContain = types.Select(x => x.AssemblyQualifiedName); //ensure they are all found Assert.IsTrue(plugins.Result.ContainsAll(shouldContain)); }
public void TypeList_Resolves_Explicit_Types() { var types = new HashSet <TypeLoader.TypeList>(); var propEditors = new TypeLoader.TypeList(typeof(DataEditor), null); propEditors.Add(typeof(LabelPropertyEditor)); types.Add(propEditors); var found = types.SingleOrDefault(x => x.BaseType == typeof(DataEditor) && x.AttributeType == null); Assert.IsNotNull(found); //This should not find a type list of this type var shouldNotFind = types.SingleOrDefault(x => x.BaseType == typeof(IDataEditor) && x.AttributeType == null); Assert.IsNull(shouldNotFind); }