void GeneratedSpecificationSpecificClassWithoutMatchingTypeInSut(GivenClass excelGivenClass) { var code = new SpecificationSpecificUnmatchedClassGenerator( excelCsharpPropertyMatcher, excelGivenClass) .CsharpCode( projectRootNamespace, usings ); AddGeneratedFile(excelGivenClass, code); }
void GenerateSpecificationSpecificRootClass(GivenClass excelGivenClass) { var code = new SpecificationSpecificRootClassGenerator( excelCsharpPropertyMatcher, excelGivenClass) .CsharpCode( projectRootNamespace, usings ); AddGeneratedFile(excelGivenClass, code); }
void GenerateLeafClass(GivenClass excelGivenClass) { var matchingType = typesUnderTest .Where(t => excelCsharpClassMatcher.Matches(t, excelGivenClass).Matches) .OrderByDescending(t => excelCsharpClassMatcher.Matches(t, excelGivenClass).PercentMatchingProperties) .FirstOrDefault(); if (matchingType != null) { GeneratedSpecificationSpecificMatchedClass(excelGivenClass, matchingType); } else { GeneratedSpecificationSpecificClassWithoutMatchingTypeInSut(excelGivenClass); } }
void GenerateSpecificationSpecificSetupClass(GivenClass excelGivenClass) { if (excelGivenClass.IsRootClass) { GenerateSpecificationSpecificRootClass(excelGivenClass); } else { // don't generate classes that already exist within the framework if (ClassNameMatcher.IsFramworkSuppliedClass(excelGivenClass.Name)) { return; } GenerateLeafClass(excelGivenClass); } }
void AddGeneratedFile(GivenClass excelGivenClass, string code) { var projectRelativePath = Path.Combine("Setup", excelGivenClass.Name); AddFile(code, $"{projectRelativePath}.cs"); }