protected override TestGeneratorResult GenerateTestFile(ITestGenerator generator, FeatureFileInput featureFileInput, GenerationSettings generationSettings)
        {
            try
            {
                var result = base.GenerateTestFile(generator, featureFileInput, generationSettings);

                if (result.IsUpToDate)
                {
                    outputFile.Skip();
                }
                else
                {
                    outputFile.Done(task.Errors);
                }

                return(result);
            }
            catch (Exception ex)
            {
                task.RecordException(ex);
                return(new TestGeneratorResult(new TestGenerationError(ex)));
            }
            finally
            {
                outputFile = null;
            }
        }
Example #2
0
 public Entity(string name, ILanguageGenerator generator, ITestGenerator testGenerator) : base(name, generator, testGenerator)
 {
     Name       = name;
     Supers     = new List <Entity>();
     Subs       = new List <Entity>();
     Attributes = new List <AttributeData>();
 }
Example #3
0
        protected override FeatureFileInput CreateFeatureFileInput(FeatureFileInput featureFile, ITestGenerator generator, SpecFlowProject specFlowProject)
        {
            var featureFileInput = base.CreateFeatureFileInput(featureFile, generator, specFlowProject);

            outputFile = task.PrepareOutputFile(generator.GetTestFullPath(featureFileInput));
            featureFileInput.GeneratedTestProjectRelativePath =
                FileSystemHelper.GetRelativePath(outputFile.FilePathForWriting, specFlowProject.ProjectSettings.ProjectFolder);
            return featureFileInput;
        }
 public TestGeneratorAdapterTests()
 {
     testGeneratorDiscoverer = Substitute.For<ITestGeneratorDiscoverer>();
     discoveryContext = Substitute.For<IDiscoveryContext>();
     discoverySink = Substitute.For<ITestCaseDiscoverySink>();
     logger = Substitute.For<IMessageLogger>();
     frameworkHandle = Substitute.For<IFrameworkHandle>();
     runContext = Substitute.For<IRunContext>();
     testGenerator = Substitute.For<ITestGenerator>();
 }
Example #5
0
        public void InitializeProject(string projectPath, string rootNamespace, IEnumerable <string> generatorPlugins)
        {
            _specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(Path.GetFullPath(projectPath), rootNamespace);

            var projectSettings = _specFlowProject.ProjectSettings;

            var testGeneratorFactory = new TestGeneratorFactory();

            _testGenerator = testGeneratorFactory.CreateGenerator(projectSettings, generatorPlugins);
        }
Example #6
0
        protected override TestGeneratorResult GenerateTestFile(ITestGenerator generator, FeatureFileInput featureFileInput, GenerationSettings generationSettings)
        {
            try
            {
                var result = base.GenerateTestFile(generator, featureFileInput, generationSettings);

                if (result.IsUpToDate)
                    outputFile.Skip();
                else
                    outputFile.Done(task.Errors);

                return result;
            }
            catch (Exception ex)
            {
                task.RecordException(ex);
                return new TestGeneratorResult(new TestGenerationError(ex));
            }
            finally
            {
                outputFile = null;
            }
        }
Example #7
0
 protected virtual FeatureFileInput CreateFeatureFileInput(FeatureFileInput featureFile, ITestGenerator generator, SpecFlowProject specFlowProject)
 {
     return(featureFile);
 }
Example #8
0
 protected virtual FeatureFileInput CreateFeatureFileInput(FeatureFileInput featureFile, ITestGenerator generator, SpecFlowProject specFlowProject)
 {
     return featureFile;
 }
Example #9
0
 protected virtual TestGeneratorResult GenerateTestFile(ITestGenerator generator, FeatureFileInput featureFileInput, GenerationSettings generationSettings)
 {
     return generator.GenerateTestFile(featureFileInput, generationSettings);
 }
Example #10
0
 public TypeData(string name, ILanguageGenerator generator, ITestGenerator testGenerator)
 {
     this.generator     = generator;
     this.testGenerator = testGenerator;
     Name = name;
 }
Example #11
0
 public DisposeNotificationTestGenerator(ITestGenerator innerGenerator)
 {
     this.innerGenerator = innerGenerator;
 }
 public FeatureCodeBehindGenerator(ITestGenerator testGenerator)
 {
     _testGenerator = testGenerator;
 }
Example #13
0
 public ExpressListener(ILanguageGenerator generator, ITestGenerator testGenerator)
 {
     this.generator     = generator;
     this.testGenerator = testGenerator;
 }
Example #14
0
 public SelectType(string name, ILanguageGenerator generator, ITestGenerator testGenerator) : base(name, generator, testGenerator)
 {
 }
Example #15
0
 protected virtual TestGeneratorResult GenerateTestFile(ITestGenerator generator, FeatureFileInput featureFileInput, GenerationSettings generationSettings)
 {
     return(generator.GenerateTestFile(featureFileInput, generationSettings));
 }
Example #16
0
 public TestsController(ITestGenerator testGenerator)
 {
     _testGenerator = testGenerator;
 }
        protected override FeatureFileInput CreateFeatureFileInput(FeatureFileInput featureFile, ITestGenerator generator, SpecFlowProject specFlowProject)
        {
            var featureFileInput = base.CreateFeatureFileInput(featureFile, generator, specFlowProject);

            outputFile = task.PrepareOutputFile(generator.GetTestFullPath(featureFileInput));
            featureFileInput.GeneratedTestProjectRelativePath =
                FileSystemHelper.GetRelativePath(outputFile.FilePathForWriting, specFlowProject.ProjectSettings.ProjectFolder);
            return(featureFileInput);
        }
Example #18
0
        private static void Generate(Express.ExpressListener listener, string outDir, string outDirTests, ILanguageGenerator generator, ITestGenerator testGenerator)
        {
            var codePath = Path.Combine(outDir, generator.FileName);
            var testPath = Path.Combine(outDirTests, testGenerator.FileName);

            var codeSb = new StringBuilder();
            var testSb = new StringBuilder();

            codeSb.AppendLine(generator.Begin());
            testSb.AppendLine(testGenerator.Begin());
            foreach (var kvp in listener.TypeGraph)
            {
                var td = kvp.Value;
                codeSb.AppendLine(td.ToString());

                // Only write tests for entities.
                var entity = td as Express.Entity;
                if (entity != null)
                {
                    testSb.AppendLine(entity.ToTestString());
                }
            }
            codeSb.AppendLine(generator.End());
            testSb.AppendLine(testGenerator.End());

            File.WriteAllText(codePath, codeSb.ToString());
            File.WriteAllText(testPath, testSb.ToString());
        }
 public DisposeNotificationTestGenerator(ITestGenerator innerGenerator)
 {
     this.innerGenerator = innerGenerator;
 }
Example #20
0
 public CollectionTypeData(string name, ILanguageGenerator generator, ITestGenerator testGenerator) : base(name, generator, testGenerator)
 {
     Values = new List <string>();
 }