public void Assert_Comments_Are_Only_Loaded_Once() { Assembly testAssembly = GetTestAssembly(); AssemblyCommentsCollection firstLoadedCollection = GetCommentsCollection(testAssembly); AssemblyCommentsCollection secondLoadedCollection = GetCommentsCollection(testAssembly); Boolean isReferenceEqual = Object.ReferenceEquals(firstLoadedCollection, secondLoadedCollection); Assert.IsTrue(isReferenceEqual, "The assembly comments collection has been loaded twice, but shouldn't."); }
/// <summary> /// Retrieves the comments collection for a given assembly /// </summary> /// <param name="assembly">The assembly which we want the comments from</param> /// <returns>The comments collection for this assembly</returns> public AssemblyCommentsCollection Get(Assembly assembly) { AssemblyCommentsCollection res = null; // Tries to get the result from the cache if (!_cache.TryGetValue(assembly, out res)) { res = new CommentsParser(assembly).Parse(); // If the parser returns nothing (ie, no comments file is found), we create a empty collection and store it in the cache if (res == null) { res = new AssemblyCommentsCollection(assembly); } _cache.Add(assembly, res); } return(res); }
public void Assert_Comments_Are_Not_Empty() { AssemblyCommentsCollection comments = GetCommentsCollection(GetTestAssembly()); Assert.IsTrue(comments.Types.Any(), "The test assembly comments have not been successfully loaded."); }