databinding

T4.FileManager .NET Framework Report

Last execution time: 24.04.2024 15:26:49

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:15
Duration

1 Unused Steps

ClassMethod
FileAutomationStepsThen the following files exists:
ThenFollowingFilesExists (IList`1 files)

Summary

Functionality Tests Ok Error Others Manual Duration
UT001 Generate Code
100%
10 10 0 0 0 00:01:01
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:02
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.246
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.508
When I run the script
00:00.171
Then the following files are generated:
File
PersonDto.g.cs
OrderDto.g.cs
00:00.000

Background
Given the file manager
00:00.142
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.422
When I run the script
00:00.178
Then the following files are generated:
File
TFMPersonDto.g.cs
TFMOrderDto.g.cs
00:00.000

Background
Given the file manager
00:00.036
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.413
When I run the script
00:00.170
Then the following files are generated:
File
PersonTxtDto.g.cs
OrderTxtDto.g.cs
TestMissingFileExtension.txt
00:00.000

Background
Given the file manager
00:00.052
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:00.628
When I run the script
00:00.193
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.278
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.454
When I run the script
00:00.303
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:23.277
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:10.056
When I run the script
00:03.430
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.161

Background
Given the file manager
00:02.036
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.437
When I run the script
00:00.183
Then the file "FileDefaultEncoding.g.cs" is encoded in "UTF-8"
00:00.017

Background
Given the file manager
00:00.162
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.514
When I run the script
00:00.168
Then the file "TestUTF16Encoding.g.cs" is encoded in "UTF-16"
00:00.010

Background
Given the file manager
00:00.155
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:00.521
When I run the script
00:00.180
Then the file "TesBigEndianEncoding.g.sql" is encoded in "UTF-16BE"
00:00.010

Background
Given the file manager
00:00.181
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.351
When I run the script
00:06.793
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.251
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.431
When I run the script
00:00.185
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.174
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.446
When I run the script
00:00.187
And I change the line
From To
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder"); fileManager.StartNewFile(itm + ".g.cs","","TestSubfolderNew");
00:00.583
And I run the script again
00:00.086
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.142
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.530
And I select the target project "T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject"
00:00.000
When I run the script
00:00.167
Then the following files are generated:
File
PersonDto.g.cs
OrderDto.g.cs
00:00.001

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.176

Background
Given the file manager
00:00.085
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:00.664
When I run the script
00:00.181
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.049

Background
Given the file manager
00:00.107
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.553
When I run the script
00:00.177
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.060

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.145
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.474
When I run the script
00:00.175
Then the file "PersonDtoWithGlobal.g.cs" starts with header:
// ------------------------- // databinding - T4 // -------------------------
00:00.013
And the file "PersonDtoWithGlobal.g.cs" starts with header:
// ------------------------- // databinding - T4 // -------------------------
00:00.000

Background
Given the file manager
00:00.091
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.406
When I run the script
00:00.182
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.014

Background
Given the file manager
00:00.106
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.508
When I run the script
00:00.185
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.013
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.012

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.104
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.406
When I run the script
00:00.170
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.437
When I run the script
00:00.065
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.164
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.061
Given I run the script
00:00.064
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.489
When I run the script
00:00.067
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.105
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.410
Given I run the script
00:00.172
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.207
When I run the script
00:00.058
Then the following files are generated:
File Contains Folder
TestNoDelete.g.cs // first run template TestOverwrite
00:00.013

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.189
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.433
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.780
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.098
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.441
When I run the script
00:00.179
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.009

Background
Given the file manager
00:00.194
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.469
When I run the script
00:00.196
Then the file "TestWithCustomLog.txt" contains following log fragments
Textfragment
My custom log info for OrderDto
My custom log info for PersonDto
00:00.010