public void FindMemberByNameTest() { CodeTypeMemberCollection collection = null; Assert.Throws(typeof(ArgumentNullException), () => collection.FindMemberByName(null)); Assert.Throws(typeof(ArgumentNullException), () => collection.FindMemberByName("name")); collection = new CodeTypeMemberCollection(new[] { new CodeTypeMember(), }); Assert.Throws(typeof(ArgumentNullException), () => collection.FindMemberByName(null)); Assert.Throws(typeof(ArgumentException), () => collection.FindMemberByName("")); Assert.IsNull(collection.FindMemberByName("AnyString")); collection.Add(CreateMemberProperty("Fish")); collection.Add(CreateMemberProperty("Cat")); collection.Add(CreateMemberProperty("Tree")); collection.Add(CreateMemberProperty("House")); CodeTypeMember willAlsoFind = new CodeMemberMethod(); willAlsoFind.Name = "WillAlsoFindMethod"; collection.Add(willAlsoFind); willAlsoFind = new CodeMemberField(); willAlsoFind.Name = "WillAlsoFindField"; collection.Add(willAlsoFind); willAlsoFind = new CodeMemberEvent(); willAlsoFind.Name = "WillAlsoFindEvent"; collection.Add(willAlsoFind); Assert.IsNull(collection.FindMemberByName("AnyString")); Assert.IsNotNull(collection.FindMemberByName("WillAlsoFindMethod")); Assert.IsNotNull(collection.FindMemberByName("WillAlsoFindField")); Assert.IsNotNull(collection.FindMemberByName("WillAlsoFindEvent")); Assert.IsNotNull(collection.FindMemberByName("Fish")); Assert.IsNotNull(collection.FindMemberByName("Cat")); Assert.IsNotNull(collection.FindMemberByName("Tree")); Assert.IsNotNull(collection.FindMemberByName("House")); Assert.AreEqual("Fish", collection.FindMemberByName("Fish").Name); Assert.AreEqual("Cat", collection.FindMemberByName("Cat").Name); Assert.AreEqual("Tree", collection.FindMemberByName("Tree").Name); Assert.AreEqual("House", collection.FindMemberByName("House").Name); }