Beispiel #1
0
        void GeneratedSpecificationSpecificClassWithoutMatchingTypeInSut(GivenClass excelGivenClass)
        {
            var code =
                new SpecificationSpecificUnmatchedClassGenerator(
                    excelCsharpPropertyMatcher,
                    excelGivenClass)
                .CsharpCode(
                    projectRootNamespace,
                    usings
                    );

            AddGeneratedFile(excelGivenClass, code);
        }
Beispiel #2
0
        void GenerateSpecificationSpecificRootClass(GivenClass excelGivenClass)
        {
            var code =
                new SpecificationSpecificRootClassGenerator(
                    excelCsharpPropertyMatcher,
                    excelGivenClass)
                .CsharpCode(
                    projectRootNamespace,
                    usings
                    );

            AddGeneratedFile(excelGivenClass, code);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        void AddGeneratedFile(GivenClass excelGivenClass, string code)
        {
            var projectRelativePath = Path.Combine("Setup", excelGivenClass.Name);

            AddFile(code, $"{projectRelativePath}.cs");
        }