Пример #1
0
        public void ShouldGenerateDependencyFiles()
        {
            // mock
            var filePath = FixtureHelper.CreateOrOverwriteFixtureFile(@".\_Fixtures\Generator\ProjectFile_UltimateRealScenario.csproj");
            var featureFile = "FeatureFile_UltimateRealScenarios.feature";

            // prepare
            var generator = new SpecificationTestGenerator();
            generator.ProjectPath = filePath;

            // do
            generator.Generate();
            var fileContent = FixtureHelper.ReadFileContent(filePath);

            // check
            var hasTests = fileContent.Contains(string.Concat(featureFile, VisualStudioProjectFileDependencyIncludesExpert.DependencyTestsFileExtension));
            Assert.IsTrue(hasTests);

            var hasSteps = fileContent.Contains(string.Concat(featureFile, ".Steps"));
            Assert.IsTrue(hasSteps);

            var hasTestsFile = HasAnyFileWithNamePart(filePath, VisualStudioProjectFileDependencyIncludesExpert.DependencyTestsFileExtension);
            Assert.IsTrue(hasTestsFile);

            var hasStepFile = HasAnyFileWithNamePart(filePath, ".Steps.");
            Assert.IsTrue(hasStepFile);
        }
Пример #2
0
        public void ShouldBeAbleToFindFeaturesInProjectFileStream()
        {
            // mock
            const string DefaultDeimiter = ":";

            var mockFeatureParser = new Mock<FeatureFileParser>();
            mockFeatureParser
                .Setup(x => x.Declaration)
                .Returns(() => new FeatureFileDeclarationComponent(DefaultDeimiter) { Raw = "CENÁRIO: BLA BLA BLA" });

            mockFeatureParser
                .Setup(x => x.Scenarions)
                .Returns(() => new FeatureFileScenarioComponent[0]);

            var mockProjectParser = new Mock<ProjectFileParser>();
            mockProjectParser
                .Setup(x => x.ProjectBasePath)
                .Returns(@".\_Fixtures\Generator\");

            mockProjectParser
                .Setup(x => x.ReadFeatureFiles())
                .Returns(new[] {
                    "FeatureFile_OneScenario.feature",
                    "FeatureFile_TwoScenarios.feature"
                });

            // prepare
            var generator = new SpecificationTestGenerator();
            generator.ProjectParser = mockProjectParser.Object;

            // do
            var features = generator.Features;

            // check
            Assert.IsNotNull(features);
            Assert.AreNotEqual(0, features.Count());
        }