コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: sigomatix/MyCode
        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);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: sigomatix/MyCode
        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);
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: sigomatix/MyCode
        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);
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: sigomatix/MyCode
        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);
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: sigomatix/MyCode
        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]);
        }