public void WhenSourceIsTheBruteLibrary_ShouldIgnoreITestGeneratorInterface()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.TestAdapter.dll" }, logger);

            Assert.Equal(0, result.Count());
        }
        public void WhenAssemblyFileInSourcesContainsSingleImplementationOfITestGeneratorInterface_ShouldRegisterTestCasesForAllTestsGenerated()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.SingleTestGenerator.dll" }, logger);

            Assert.Equal(1, result.Count());
        }
        public void WhenAssemblyFileInSourcesContainsNoImplementationOfITestGeneratorInterface_ShouldNotRegisterAnyTestCases()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.NoTestGenerator.dll" }, logger);

            Assert.Empty(result);
        }
        public void WhenAssemblyFileInSourcesContainsMultipleImplementationsOfITestGeneratorInterface_ShouldRegisterTestCasesForEveryImplementation()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.MultipleTestGenerators.dll" }, logger);

            Assert.True(result.Any(t => t.DisplayName == FirstTestGenerator.TestCaseName));
            Assert.True(result.Any(t => t.DisplayName == SecondTestGenerator.TestCaseName));
        }
        public void WhenMultipleSourcesAreGiven_ShouldLoadTestGeneratorsFromAllSources()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.SingleTestGenerator.dll", "Brute.AssemblyStubs.MultipleTestGenerators.dll" }, logger);

            Assert.True(result.Any(t => t.DisplayName == SingleTestGenerator.TestCaseName));
            Assert.True(result.Any(t => t.DisplayName == FirstTestGenerator.TestCaseName));
            Assert.True(result.Any(t => t.DisplayName == SecondTestGenerator.TestCaseName));
        }
        public void WhenTestCaseIsGenerated_ShouldBeRegisteredWithCodeFilePathSetToSourceFileReturnedInTest()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.SingleTestGenerator.dll" }, logger);

            Assert.True(result.Any(tc => tc.CodeFilePath == SingleTestGenerator.SourceFile));
        }
        public void WhenTestGeneratorReturnsMultipleTests_ShouldReturnTestCasesForEveryTest()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.MultipleTestsGenerator.dll" }, logger);

            Assert.True(result.Any(t => t.DisplayName == MultipleTestsGenerator.TestCaseName1));
            Assert.True(result.Any(t => t.DisplayName == MultipleTestsGenerator.TestCaseName2));
            Assert.True(result.Any(t => t.DisplayName == MultipleTestsGenerator.TestCaseName3));
            Assert.True(result.Any(t => t.DisplayName == MultipleTestsGenerator.TestCaseName4));
        }
        public void WhenTestCaseIsGenerated_ShouldSetFullyQualifiedNameToFullNameOfTestGeneratorTypePlusTheTestCaseNameWithoutSpacesSeparatedByHashTag()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.SingleTestGenerator.dll" }, logger);

            Assert.True(result.Any(tc => tc.FullyQualifiedName == String.Format("{0}#{1}", typeof(SingleTestGenerator).FullName, SingleTestGenerator.TestCaseName.Replace(" ", ""))));
        }
        public void WhenTestCaseIsGenerated_ShouldBeRegisteredWithLineNumberGivenInTest()
        {
            AssemblyReflectionTestGeneratorDiscoverer discoverer = new AssemblyReflectionTestGeneratorDiscoverer();

            IEnumerable<TestCase> result = discoverer.Discover(new string[] { "Brute.AssemblyStubs.SingleTestGenerator.dll" }, logger);

            Assert.True(result.Any(tc => tc.LineNumber == SingleTestGenerator.LineNumber));
        }