public void ShouldReturnNullWhenAssemnlyInitializeIsNotPresent() { var assembly = new Mock<IAssembly>(); var searcher = new Mock<IAssemblySearcher>(); IMethodInfo expected = null; searcher.Setup(s => s.FindMethod(assembly.Object, typeof(AssemblyInitializeAttribute))).Returns(expected); var extractor = new MSTestExtractor(assembly.Object, searcher.Object); var actualInit = extractor.GetAssemblyInitialise(); Assert.AreEqual(expected, actualInit); }
public void ShouldGetMethodTestInitializeWhenPresent() { var assembly = new Mock<IAssembly>(); var testMethodOwningType = new Mock<IType>(); var searcher = new Mock<IAssemblySearcher>(); var expectedInit = BuildMethod("SomeClass", "Init"); var testMethod = BuildMethod("SomeClass", "Test"); testMethod.Setup(m => m.DeclaringType).Returns(testMethodOwningType.Object); searcher.Setup(s => s.FindMethod(testMethodOwningType.Object, typeof(TestInitializeAttribute))).Returns(expectedInit.Object); var extractor = new MSTestExtractor(assembly.Object, searcher.Object); var actualCleanup = extractor.GetTestInitialize(testMethod.Object); Assert.AreEqual(expectedInit.Object, actualCleanup); }
public void ShouldGetAssemblyCleanupWhenPresent() { var assembly = new Mock<IAssembly>(); var searcher = new Mock<IAssemblySearcher>(); var expectedCleanup = BuildMethod("SomeClass", "Cleanup"); searcher.Setup(s => s.FindMethod(assembly.Object, typeof(AssemblyCleanupAttribute))).Returns(expectedCleanup.Object); var extractor = new MSTestExtractor(assembly.Object, searcher.Object); var actualCleanup = extractor.GetAssemblyCleanup(); Assert.AreEqual(expectedCleanup.Object, actualCleanup); }
public void ShouldGetAssemblyInitialiseWhenPresent() { var assembly = new Mock<IAssembly>(); var searcher = new Mock<IAssemblySearcher>(); var expectedInit = BuildMethod("SomeClass", "Init"); searcher.Setup(s => s.FindMethod(assembly.Object, typeof(AssemblyInitializeAttribute))).Returns(expectedInit.Object); var extractor = new MSTestExtractor(assembly.Object, searcher.Object); var actualInit = extractor.GetAssemblyInitialise(); Assert.AreEqual(expectedInit.Object, actualInit); }
public void ShouldGetAllTestMethodsWhenPresent() { var assembly = new Mock<IAssembly>(); var testMethodOwningType = new Mock<IType>(); var searcher = new Mock<IAssemblySearcher>(); var expectedCleanup = BuildMethod("SomeClass", "Cleanup"); var testMethod1 = BuildMethod("SomeClass", "Test1"); var testMethod2 = BuildMethod("SomeClass", "Test2"); searcher.Setup(s => s.FindMethods(assembly.Object, typeof(TestMethodAttribute))).Returns(new[] { testMethod1.Object, testMethod2.Object }); var extractor = new MSTestExtractor(assembly.Object, searcher.Object); var actualTestMethods = extractor.GetTestMethods(); Assert.AreEqual(testMethod1.Object, actualTestMethods[0]); Assert.AreEqual(testMethod2.Object, actualTestMethods[1]); }