public void GivenClassRecorderRecordsSimpleProperties() { var givenClassRecorder = new GivenClassRecorder(); var sheetConverter = new ExcelToCode.ExcelToCode(new CodeNameToExcelNameConverter(ANY_STRING)); sheetConverter.AddVisitor(givenClassRecorder); using (var workbook = Workbook(@"TestExcelFiles\PropertyTypes.xlsx")) { sheetConverter.GenerateCSharpTestCode( NO_USINGS, workbook.GetPage(0), ANY_ROOT_NAMESPACE, ANY_WORKBOOKNAME); Assert.AreEqual(1, givenClassRecorder.Classes.Count); var rootClass = givenClassRecorder.Classes.First(); // probably want the name with and without the "_of". the sut will have it without the _of, but the specification specific class will have it with the of // might want to think about functions as well, but this will probably do for now. AssertContains(rootClass.Properties, "Null", ExcelPropertyType.Null); AssertContains(rootClass.Properties, "DateTime", ExcelPropertyType.DateTime); AssertContains(rootClass.Properties, "Enum", ExcelPropertyType.Enum); AssertContains(rootClass.Properties, "Number", ExcelPropertyType.Number); AssertContains(rootClass.Properties, "Decimal", ExcelPropertyType.Decimal); AssertContains(rootClass.Properties, "False", ExcelPropertyType.Boolean); AssertContains(rootClass.Properties, "True", ExcelPropertyType.Boolean); AssertContains(rootClass.Properties, "String", ExcelPropertyType.String); AssertContains(rootClass.Properties, "QuotedString", ExcelPropertyType.String); } }
public void GivenClassRecorderRecordsTableProperties() { var givenClassRecorder = new GivenClassRecorder(); var sheetConverter = new ExcelToCode.ExcelToCode(new CodeNameToExcelNameConverter(ANY_STRING)); sheetConverter.AddVisitor(givenClassRecorder); using (var workbook = Workbook(@"TestExcelFiles\VisitGivenTableProperties.xlsx")) { sheetConverter.GenerateCSharpTestCode(NO_USINGS, workbook.GetPage(1), ANY_ROOT_NAMESPACE, ANY_WORKBOOKNAME); CollectionAssert.Contains( givenClassRecorder.Classes, new GivenClass( "ThingToSetup", new List <IGivenClassProperty> { new GivenClassComplexListProperty("TableProperty", "TableClass"), }, new List <GivenClassSimpleProperty>(), new List <GivenClassComplexProperty>(), new List <GivenClassFunction>(), new List <GivenClassComplexListProperty>() ) ); CollectionAssert.Contains( givenClassRecorder.Classes, new GivenClass( "TableClass", new List <IGivenClassProperty> { new GivenClassComplexProperty("ComplexProperty", "ComplexClass"), new GivenClassSimpleProperty("SimpleProperty", ExcelPropertyType.String) }, new List <GivenClassSimpleProperty>(), new List <GivenClassComplexProperty>(), new List <GivenClassFunction>(), new List <GivenClassComplexListProperty>() ) ); CollectionAssert.Contains( givenClassRecorder.Classes, new GivenClass( "ComplexClass", new List <IGivenClassProperty> { new GivenClassSimpleProperty("ComplexProperty1", ExcelPropertyType.String), new GivenClassSimpleProperty("ComplexProperty2", ExcelPropertyType.String) }, new List <GivenClassSimpleProperty>(), new List <GivenClassComplexProperty>(), new List <GivenClassFunction>(), new List <GivenClassComplexListProperty>() ) ); } }
public InMemoryGenerateCSharpFromExcel( ILogger logger, IEnumerable <ITabularBook> workbooks, string projectRootNamespace, IEnumerable <string> usings, IEnumerable <Type> typesUnderTest, string assertionClassPrefix) { givenClassRecorder = new GivenClassRecorder(); excelCsharpPropertyMatcher = new ExcelCsharpPropertyMatcher(); excelCsharpClassMatcher = new ExcelCsharpClassMatcher(excelCsharpPropertyMatcher); this.logger = logger; this.workbooks = workbooks; this.projectRootNamespace = projectRootNamespace; this.usings = usings; this.typesUnderTest = typesUnderTest; this.assertionClassPrefix = assertionClassPrefix; generatedFiles = new List <CsharpProjectFileToSave>(); }
public void GivenClassRecorderIgnoresSimplePropertyDuplicates() { var visitRecorder = new GivenClassRecorder(); var givenComplexProperty = new VisitedGivenComplexProperty( "Leg", "Leg" ); var givenSimpleProperty = new VisitedGivenSimpleProperty( "Origin of", "Origin", ExcelPropertyType.String ); visitRecorder.VisitGivenComplexPropertyDeclaration(givenComplexProperty); visitRecorder.VisitGivenSimpleProperty(givenSimpleProperty); visitRecorder.VisitGivenSimpleProperty(givenSimpleProperty); visitRecorder.VisitGivenComplexPropertyFinalisation(); Assert.AreEqual(1, visitRecorder.Classes.Single().Properties.Count()); }