public void AssemblySearcherShouldReturnNullIfItCantFindAMethod() { var searcher = new AssemblySearcher(); var assembly = Assembly() .With(Type("SomeClass") .With(Method("SomeFirstMethod")) .With(Method("SomeSecondMethod")) .With(Method("SomeLastMethod"))); var actualMethod = searcher.FindMethod(assembly.Object, typeof(TestMethodAttribute)); Assert.IsNull(actualMethod); }
public void AssemblySearcherShouldReturnNullIfItCanFindTheMethodInType() { var searcher = new AssemblySearcher(); var type = Type("SomeClass") .With(Method("SomeFirstMethod")) .With(Method("SomeTestMethod")) .With(Method("SomeLastMethod")); var actualMethod = searcher.FindMethod(type.Object, typeof(TestMethodAttribute)); Assert.IsNull(actualMethod); }
public void AssemblySearcherShouldLookForAllMethodsInAllTypesWithMatchingAttribute() { var searcher = new AssemblySearcher(); var assembly = Assembly() .With(Type("SomeFirstClass") .With(Method("Method1")) .With(Method("Method2").With(typeof(TestMethodAttribute))) .With(Method("Method3"))) .With(Type("SomeSecondClass") .With(Method("Method4").With(typeof(TestMethodAttribute))) .With(Method("Method5").With(typeof(TestMethodAttribute))) .With(Method("Method6").With(typeof(TestMethodAttribute)))) .With(Type("SomeThirdClass") .With(Method("Method7")) .With(Method("Method8")) .With(Method("Method9"))); var actualMethods = searcher.FindMethods(assembly.Object, typeof(TestMethodAttribute)); var expectedMethods = new List<string> { "Method2", "Method4", "Method5", "Method6" }; Assert.IsTrue(expectedMethods.SequenceEqual(actualMethods.OrderBy(m => m.Name).Select(m => m.Name))); }
public void AssemblySearcherShouldLookForTheMethodInAllTypes() { var searcher = new AssemblySearcher(); var assembly = Assembly() .With(Type("SomeFirstClass") .With(Method("SomeFirstMethod")) .With(Method("SomeSecondMethod")) .With(Method("SomeLastMethod"))) .With(Type("SomeSecondClass") .With(Method("SomeFirstMethod")) .With(Method("SomeTestMethod").With(typeof(TestMethodAttribute))) .With(Method("SomeLastMethod"))) .With(Type("SomeThirdClass") .With(Method("SomeFirstMethod")) .With(Method("SomeSecondMethod")) .With(Method("SomeLastMethod"))); var actualMethod = searcher.FindMethod(assembly.Object, typeof(TestMethodAttribute)); Assert.AreEqual("SomeTestMethod", actualMethod.Name); }
public void AssemblySearcherShouldFindFirstMethodOfMatchingAttributeInType() { var searcher = new AssemblySearcher(); var type = Type("SomeClass") .With(Method("SomeFirstMethod")) .With(Method("SomeTestMethod").With(typeof(TestMethodAttribute))) .With(Method("SomeLastMethod")); var actualMethod = searcher.FindMethod(type.Object, typeof(TestMethodAttribute)); Assert.AreEqual("SomeTestMethod", actualMethod.Name); }