databinding

T4.FileManager .NET Framework Report

Last execution time: 25.03.2024 20:34:32

Build: 4.0.1

State: Ok

100%

Indicators

25
Total
25
100.00% Ok
0
0.00% Error
0
0.00% Others
0
0.00% Manual
00:01:38
Duration

19 Unused Steps

ClassMethod
FileAutomationStepsGiven the file manager
GivenTheFileManager ()
FileAutomationStepsGiven I select the target project "(.*)"
GivenTargetProjectForToGenerateFiles (String name)
FileAutomationStepsGiven the script "(.*)" with the following content
GivenTheScriptWithFollowingContentForAutomation (String filename, String templateContent)
FileAutomationStepsGiven I change the line
GivenIChangeTheLine (IList`1 changes)
FileAutomationStepsWhen I change the line
GivenIChangeTheLine (IList`1 changes)
FileAutomationStepsWhen I run the script
WhenIRunTheScriptForAutomation ()
FileAutomationStepsWhen I run the script again
WhenIRunTheScriptForAutomation ()
FileAutomationStepsGiven I run the script
WhenIRunTheScriptForAutomation ()
FileAutomationStepsGiven the following files are generated:
ThenFollowingFilesExists (IList`1 files)
FileAutomationStepsThen the following files are generated:
ThenFollowingFilesExists (IList`1 files)
FileAutomationStepsThen the following files exists:
ThenFollowingFilesExists (IList`1 files)
FileAutomationStepsThen the following files are not generated:
ThenFollowingFilesNotExists (IList`1 files)
FileAutomationStepsThen the following files no longer exist:
ThenFollowingFilesNotExists (IList`1 files)
FileAutomationStepsThen the following files are cleaned up:
ThenFollowingFilesNotExists (IList`1 files)
FileAutomationStepsThen the custom tool is set to "(.*)" for the following files:
ThenCustomToolIsSet (String customTool, IList`1 files)
FileAutomationStepsThen the file "(.*)" has following format:
ThenTheFileStartsWithFollowingContent (String file, String expectedContent)
FileAutomationStepsThen the file "(.*)" starts with header:
ThenTheFileStartsWithFollowingContent (String file, String expectedContent)
FileAutomationStepsThen the file "(.*)" contains following log fragments
ThenTheFileContainsFollowingLogFragments (String file, IList`1 expectedContent)
FileAutomationStepsThen the file "([^"]*)" is encoded in "([^"]*)"
ThenTheFileIsEncodedIn (String file, String expectedEncodingString)

Summary

Functionality Tests Ok Error Others Manual Duration
UT001 Generate Code
100%
10 10 0 0 0 00:01:23
UT002 Generate File in subfolder
100%
2 2 0 0 0 00:00:02
UT003 Generate File in other project
100%
1 1 0 0 0 00:00:00
UT004 Generate File with custom tool
100%
3 3 0 0 0 00:00:03
UT006 Generate File with standard header
100%
3 3 0 0 0 00:00:02
UT009 Generate File with cleanup old File
100%
1 1 0 0 0 00:00:01
UT013 Generate File without modifications
100%
2 2 0 0 0 00:00:01
UT013 Generate File with overwrite
100%
1 1 0 0 0 00:00:01
UT016 Log activities
100%
2 2 0 0 0 00:00:01

Feature: UT001 Generate Code

As a developer I can generate code with the T4.FileManager with each class in its own file
Acceptance criterias 10/10 (100%)
Duration

Background
Given the file manager
00:00.133
Given the script "Test.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonDto", "OrderDto" }; var fileManager = T4FileManager.Create(this); foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "",""); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Generate(); #>
00:00.511
When I run the script
00:00.186
Then the following files are generated:
File
PersonDto.g.cs
OrderDto.g.cs
00:00.000

Background
Given the file manager
00:00.127
Given the script "TestTFM.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "TFMPersonDto", "TFMOrderDto" }; var fileManager = T4FileManager.Create(this); foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.cs", "",""); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Process(); #>
00:00.415
When I run the script
00:00.179
Then the following files are generated:
File
TFMPersonDto.g.cs
TFMOrderDto.g.cs
00:00.000

Background
Given the file manager
00:00.532
Given the script "TestMissingFileExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonTxtDto", "OrderTxtDto" }; var fileManager = T4FileManager.Create(this); foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "",""); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Generate(); #>
00:00.757
When I run the script
00:00.246
Then the following files are generated:
File
PersonTxtDto.g.cs
OrderTxtDto.g.cs
TestMissingFileExtension.txt
00:00.000

Background
Given the file manager
00:02.828
Given the script "TestCsExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".cs" #> <# /* **** <====== is ignored **** */ #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonCsDto", "OrderCsDto" }; var fileManager = T4FileManager.Create(this); foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "",""); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Generate(); #>
00:01.232
When I run the script
00:00.229
Then the following files are generated:
File
PersonCsDto.g.cs
OrderCsDto.g.cs
TestCsExtension.txt
00:00.002

Background
Given the file manager
00:00.048
Given the script "TestInvalidFileExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonIvDto", "OrderIvDto" }; var fileManager = T4FileManager.Create(this).DisableTemplateMainOutputFile(); // <=== prevent main output file foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "",""); #> namespace Test { public partial class <#= itm #> { } } <# } fileManager.Generate(); #>
00:00.514
When I run the script
00:00.169
Then the following files are generated:
File
PersonIvDto.g.cs
OrderIvDto.g.cs
00:00.000
But the following files are not generated:
File
TestInvalidFileExtension.txt
00:00.001

Background
Given the file manager
00:32.191
Given the script "TestAutoIndent.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "FileFormat" }; var fileManager = T4FileManager.Create(this).EnableAutoIndent(); // <=== Enable Format Document foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "",""); #> namespace Test { public partial class <#= itm #> { public int Id {get; set;} public string Name {get; set;} } } <# } fileManager.Generate(); #>
00:19.088
When I run the script
00:01.687
Then the file "FileFormat.g.cs" has following format:
namespace Test { public partial class FileFormat { public int Id { get; set; } public string Name { get; set; } } }
00:00.154

Background
Given the file manager
00:02.176
Given the script "TestDefaultEncoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "FileDefaultEncoding" }; var fileManager = T4FileManager.Create(this); foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.cs", "",""); #> namespace Test { public partial class <#= itm #> { public int Id {get; set;} } } <# } fileManager.Process(); #>
00:00.581
When I run the script
00:00.216
Then the file "FileDefaultEncoding.g.cs" is encoded in "UTF-8"
00:00.015

Background
Given the file manager
00:00.142
Given the script "TestUTF16Encoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "TestUTF16Encoding" }; var fileManager = T4FileManager.Create(this).EnableLog().SetOutputFileEncoding(Encoding.Unicode); // <=== Set encoding for output file foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.cs", "",""); #> namespace Test { public partial class <#= itm #> { public int Id {get; set;} } } <# } fileManager.Process(); #>
00:00.560
When I run the script
00:00.180
Then the file "TestUTF16Encoding.g.cs" is encoded in "UTF-16"
00:00.008

Background
Given the file manager
00:00.356
Given the script "TestBigEndianEncoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "TesBigEndianEncoding" }; var fileManager = T4FileManager.Create(this).EnableLog().SetOutputFileEncoding(Encoding.BigEndianUnicode); foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.sql", "",""); #> SELECT 'öäüé' <#=itm#> <# } fileManager.Process(); #>
00:01.014
When I run the script
00:00.173
Then the file "TesBigEndianEncoding.g.sql" is encoded in "UTF-16BE"
00:00.009

Background
Given the file manager
00:00.092
Given the script "TestSystemXml.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="System.Xml" #> <#@ assembly name="System.Xml.Linq" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Xml" #> <#@ import namespace="System.Xml.Linq" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this).EnableAutoIndent(); #> <# fileManager.StartNewFile("text.xml", "",""); var doc = new XmlDocument(); doc.LoadXml("<book>Reading</book>"); #> <#=doc.InnerXml#> <# fileManager.Process(); #>
00:09.630
When I run the script
00:07.134
Then the following files are generated:
File
text.xml
00:00.000

Feature: UT002 Generate File in subfolder

As a developer I can generate code with the T4.FileManager with each class in its own file in a subfolder
Acceptance criterias 2/2 (100%)
Duration

Background
Given the file manager
00:00.266
Given the script "TestSubfolder.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonDto", "OrderDto" }; var fileManager = new T4FileManager(this); foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder"); #> namespace Test.TestSubFolder { public class <#= itm #> { } } <# } fileManager.Process(); #>
00:00.416
When I run the script
00:00.177
Then the following files are generated:
File Folder
PersonDto.g.cs TestSubfolder
OrderDto.g.cs TestSubfolder
00:00.000

Background
Given the file manager
00:00.120
Given the script "TestSubfolderMoving.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonMDto", "OrderMDto" }; var fileManager = new T4FileManager(this); foreach(var itm in files) { fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder"); #> namespace Test.TestSubFolder { public class <#= itm #> { } } <# } fileManager.Process(); #>
00:00.489
When I run the script
00:00.185
And I change the line
From To
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder"); fileManager.StartNewFile(itm + ".g.cs","","TestSubfolderNew");
00:00.638
And I run the script again
00:00.081
Then the following files are generated:
File Folder
PersonMDto.g.cs TestSubfolderNew
OrderMDto.g.cs TestSubfolderNew
00:00.000
And the following files no longer exist:
File Folder
PersonMDto.g.cs TestSubfolder
OrderMDto.g.cs TestSubfolder
00:00.000

Feature: UT003 Generate File in other project

As a developer I can generate code with the T4.FileManager with each class in its own file or in different projects
Acceptance criterias 1/1 (100%)
Duration

Given the file manager
00:00.156
And the script "TestInOtherProject.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonDto", "OrderDto" }; var fileManager = new T4FileManager(this); foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs","T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject",""); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Generate(); #>
00:00.526
And I select the target project "T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject"
00:00.000
When I run the script
00:00.174
Then the following files are generated:
File
PersonDto.g.cs
OrderDto.g.cs
00:00.000

Feature: UT004 Generate File with custom tool

As a developer I can generate code with the T4.FileManager and definied custom tool properties
Acceptance criterias 3/3 (100%)
Duration

Background
Given the file manager
00:00.115

Background
Given the file manager
00:00.005
Given the script "ProjectTestFP.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var document = new List<string[]>(); document.Add(new string[] { "FirstName", "Vorname", "Angaben zum Vornamen"}); document.Add(new string[] { "LastName", "Nachname", "Angaben zum Nachnamen"}); document.Add(new string[] { "Street", "Strasse", "Angaben zur Strasse"}); var fileManager = TemplateFileManager.Create(this); var fp = new FileProperties(); fp.CustomTool = "ResXFileCodeGenerator"; fileManager.CreateNewFile("ProjectTestFP.resx", "", "", fp); // <-- use method of FileProperties only (since Version 2.0.0) #> <?xml version="1.0" encoding="utf-8"?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>1.3</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <# for (int idx = 0; idx < document.Count; idx++) { var item = document[idx]; #> <data name="<#= item[0] #>" xml:space="preserve"> <value><#= item[1] #></value> <comment><#= item[2] #></comment> </data> <#} #> </root> <# fileManager.Generate(); #>
00:02.094
When I run the script
00:00.234
Then the following files are generated:
File
ProjectTestFP.resx
ProjectTestFP.Designer.cs
00:00.000
And the custom tool is set to "ResXFileCodeGenerator" for the following files:
File
ProjectTestFP.resx
00:00.075

Background
Given the file manager
00:00.063
Given the script "TestTFMCustomTool.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var document = new List<string[]>(); document.Add(new string[] { "FirstName", "Vorname", "Angaben zum Vornamen"}); document.Add(new string[] { "LastName", "Nachname", "Angaben zum Nachnamen"}); document.Add(new string[] { "Street", "Strasse", "Angaben zur Strasse"}); var fileManager = TemplateFileManager.Create(this); var fp = new FileProperties(); fp.CustomTool = "ResXFileCodeGenerator"; fileManager.StartNewFile("ProjectTestTFM.resx", "", "", fp); //<-- Backward compatibility for TemplateFileManager #> <?xml version="1.0" encoding="utf-8"?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>1.3</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <# for (int idx = 0; idx < document.Count; idx++) { var item = document[idx]; #> <data name="<#= item[0] #>" xml:space="preserve"> <value><#= item[1] #></value> <comment><#= item[2] #></comment> </data> <#} #> </root> <# fileManager.Process(); #>
00:00.541
When I run the script
00:00.166
Then the following files are generated:
File
ProjectTestTFM.resx
ProjectTestTFM.Designer.cs
00:00.000
And the custom tool is set to "ResXFileCodeGenerator" for the following files:
File
ProjectTestTFM.resx
00:00.054

Feature: UT006 Generate File with standard header

As a developer I can generate code with the T4.FileManager using a standard header
Acceptance criterias 3/3 (100%)
Duration

Background
Given the file manager
00:00.146
Given the script "TestGlobalHeader.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this); fileManager.StartHeader(); #> // ------------------------- // databinding - T4 // ------------------------- <# fileManager.FinishHeader(); fileManager.CreateNewFile("PersonDtoWithGlobal.g.cs","",""); #> namespace Test { public class PersonDtoWithGlobal { } } <# fileManager.CreateNewFile("OrderDtoWithGlobal.g.cs","",""); #> namespace Test { public class OrderDtoWithGlobal { } } <# fileManager.Generate(); #>
00:00.408
When I run the script
00:00.184
Then the file "PersonDtoWithGlobal.g.cs" starts with header:
// ------------------------- // databinding - T4 // -------------------------
00:00.011
And the file "PersonDtoWithGlobal.g.cs" starts with header:
// ------------------------- // databinding - T4 // -------------------------
00:00.000

Background
Given the file manager
00:00.082
Given the script "TestSA1633Header.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this); fileManager.StartHeader(); #> // <copyright file="$filename$" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author> <# fileManager.FinishHeader(); fileManager.CreateNewFile("PersonDtoWithSA1633.g.cs","",""); #> namespace Test { public class PersonDtoWithHeader { } } <# fileManager.CreateNewFile("OrderDtoWithSA1633.g.cs","",""); #> namespace Test { public class OrderDtoWithHeader { } } <# fileManager.Generate(); #>
00:00.433
When I run the script
00:00.205
Then the file "PersonDtoWithSA1633.g.cs" starts with header:
// <copyright file="PersonDtoWithSA1633.g.cs" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author>
00:00.013
And the file "OrderDtoWithSA1633.g.cs" starts with header:
// <copyright file="OrderDtoWithSA1633.g.cs" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author>
00:00.012

Background
Given the file manager
00:00.133
Given the script "TestSA1633HeaderTFM.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this); fileManager.StartHeader(); #> // <copyright file="$filename$" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author> <# fileManager.EndBlock(); fileManager.CreateNewFile("PersonDtoWithSA1633TFM.g.cs","",""); #> namespace Test { public class PersonDtoWithHeader { } } <# fileManager.CreateNewFile("OrderDtoWithSA1633TFM.g.cs","",""); #> namespace Test { public class OrderDtoWithHeader { } } <# fileManager.Process(); #>
00:00.414
When I run the script
00:00.197
Then the file "PersonDtoWithSA1633TFM.g.cs" starts with header:
// <copyright file="PersonDtoWithSA1633TFM.g.cs" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author>
00:00.010
And the file "OrderDtoWithSA1633TFM.g.cs" starts with header:
// <copyright file="OrderDtoWithSA1633TFM.g.cs" company="databinding.gmbh"> // databinding.gmbh - All rights reserved. // </copyright> // <author>Mr. T4</author>
00:00.010

Feature: UT009 Generate File with cleanup old File

As a developer I can generate code with the T4.FileManager without taking care of old generated files
Acceptance criterias 1/1 (100%)
Duration

Background
Given the file manager
00:00.113
And the script "TestOldFilesCleanUp.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this); fileManager.CreateNewFile("TestOldFilesCleanUp.g.cs","",""); #> namespace Test { public class TestOldFilesCleanUp { } } <# fileManager.Generate(); #>
00:00.407
When I run the script
00:00.163
Then the following files are generated:
File
TestOldFilesCleanUp.g.cs
00:00.000
Given I change the line
From To
fileManager.CreateNewFile("TestOldFilesCleanUp.g.cs","","") fileManager.CreateNewFile("TestOldFilesCleanUpRenamed.g.cs","","")
00:00.429
When I run the script
00:00.064
Then the following files are cleaned up:
File
TestOldFilesCleanUp.g.cs
00:00.000
And the following files are generated:
File
TestOldFilesCleanUpRenamed.g.cs
00:00.000

Feature: UT013 Generate File without modifications

As a developer I can generate code with the T4.FileManager and supress changes if the file exist
Acceptance criterias 2/2 (100%)
Duration

Background
Given the file manager
00:00.184
And the script "TestNoDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile(); fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite"); #> namespace Test { public class TestNoDelete { // first run template } } <# fileManager.Generate(); #>
00:00.045
Given I run the script
00:00.070
And the following files are generated:
File Folder
TestNoDelete.g.cs TestOverwrite
00:00.000
And I change the line
From To
fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite"); fileManager.CreateNewFile("TestNoDelete2.g.cs","","TestOverwrite");
public class TestNoDelete public class TestNoDelete2
00:00.469
When I run the script
00:00.063
Then the following files are generated:
File Folder
TestNoDelete.g.cs TestOverwrite
TestNoDelete2.g.cs TestOverwrite
00:00.000

Background
Given the file manager
00:00.078
And the script "TestNoDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile(); fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite"); #> namespace Test { public class TestNoDelete { // first run template } } <# fileManager.Generate(); #>
00:00.451
Given I run the script
00:00.159
And the following files are generated:
File Folder
TestNoDelete.g.cs TestOverwrite
00:00.000
And I change the line
From To
// first run template // second run template
00:00.206
When I run the script
00:00.061
Then the following files are generated:
File Contains Folder
TestNoDelete.g.cs // first run template TestOverwrite
00:00.012

Feature: UT013 Generate File with overwrite

As a developer I can change the behaviour of supress changes to overwrite existing files
Acceptance criterias 1/1 (100%)
Duration

Background
Given the file manager
00:00.132
And the script "TestDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile(); fileManager.CreateNewFile("TestDelete.g.cs","","TestOverwrite"); #> namespace Test { public class TestDelete { // first run template } } <# fileManager.Generate(); #>
00:00.401
Given I run the script
00:00.177
And the following files are generated:
File Folder
TestDelete.g.cs TestOverwrite
00:00.000
And I change the line
From To
T4FileManager.Create(this).DisableOverwriteExistingFile(); T4FileManager.Create(this);
fileManager.CreateNewFile("TestDelete.g.cs","","TestOverwrite"); fileManager.CreateNewFile("TestNoDelete3.g.cs","","TestOverwrite");
public class TestDelete public class NewTestDeleteModel
00:00.773
When I run the script
00:00.069
Then the following files are generated:
File Folder
TestNoDelete3.g.cs TestOverwrite
00:00.000
And the following files are cleaned up:
File Folder
TestDelete.g.cs TestOverwrite
00:00.000

Feature: UT016 Log activities

As a developer I can log to the main output file so that I can analyze the generation process
Acceptance criterias 2/2 (100%)
Duration

Background
Given the file manager
00:00.106
Given the script "TestWithLogEnabled.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonDto", "OrderDto" }; var fileManager = new T4FileManager(this).EnableLog(); // <-- log output to main file TestWithLogEnabled.txt foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "", "TestSubfolder"); #> namespace Test { public class <#= itm #> { } } <# } fileManager.Generate(); #>
00:00.433
When I run the script
00:00.182
Then the file "TestWithLogEnabled.txt" contains following log fragments
Textfragment
Log to main output file enabled
Begin CreateNewFile PersonDto.g.cs
Start DeleteExistingFiles
2 files generated
00:00.006

Background
Given the file manager
00:00.159
Given the script "TestWithCustomLog.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ output extension=".txt" #> <#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #> <# var files = new string[] { "PersonDto", "OrderDto" }; var fileManager = new T4FileManager(this).EnableLog(); // <-- log output to main file TestWithLogEnabled.txt foreach(var itm in files) { fileManager.CreateNewFile(itm + ".g.cs", "", "TestSubfolder"); #> namespace Test { public class <#= itm #> { <# fileManager.Log("My custom log info for {0}", itm); #> } } <# } fileManager.Generate(); #>
00:00.490
When I run the script
00:00.180
Then the file "TestWithCustomLog.txt" contains following log fragments
Textfragment
My custom log info for OrderDto
My custom log info for PersonDto
00:00.009