feature/Enhanced_Writer_NoSeparator_AndName

This commit is contained in:
Michal Buzik 2025-09-26 15:10:34 +02:00
parent 4b33da565c
commit 357df87f49
6 changed files with 631 additions and 407 deletions

View File

@ -127,11 +127,16 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
/// </summary> /// </summary>
/// <param name="time">Date and time</param> /// <param name="time">Date and time</param>
/// <returns>File name</returns> /// <returns>File name</returns>
string GetFilename(string destinationPath, Results.Entities.Batch batch) public string GetFilename(string destinationPath, Results.Entities.Batch batch, DateTime now)
{ {
string directory = destinationPath; /// Ends with "\\"; string directory = destinationPath; /// Ends with "\\";
DateTime time = batch.EndTime; DateTime time = batch.EndTime;
if (writerCfg.FileNameFormat.Contains("{5:"))
{
time = now; //define path and file name now
}
switch (writerCfg.YearFolders) switch (writerCfg.YearFolders)
{ {
case YearFolders.FourDigit: case YearFolders.FourDigit:
@ -195,7 +200,7 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
else else
{ {
TBF.Rig.GenericDevices.IBenchInfo bi = TBF.Rig.Sequences.ProcessData.BenchInfo; TBF.Rig.GenericDevices.IBenchInfo bi = TBF.Rig.Sequences.ProcessData.BenchInfo;
return directory + string.Format(writerCfg.FileNameFormat, batch.EndTime, batch.StartTime, batch.BatchNr, bi.TestBenchName, bi.TestBenchId); return directory + string.Format(writerCfg.FileNameFormat, batch.EndTime, batch.StartTime, batch.BatchNr, bi.TestBenchName, bi.TestBenchId, time);
} }
} }
catch catch
@ -248,6 +253,7 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
} }
void WriteRslts(Results.Entities.Batch batch, string destination) void WriteRslts(Results.Entities.Batch batch, string destination)
{ {
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0) return; if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0) return;
@ -257,8 +263,9 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
StreamWriter writer = StreamWriter.Null; StreamWriter writer = StreamWriter.Null;
try try
{ {
writer = File.AppendText(GetFilename(destination, batch)); DateTime now = DateTime.Now; // Common time for '{5:' possibility of output
WriteRsltsEx(batch, writer); writer = File.AppendText(GetFilename(destination, batch, now));
WriteRsltsEx(batch, writer,now);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination); log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
} }
catch catch
@ -273,7 +280,7 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
} }
void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr) public void WriteRsltsEx(Results.Entities.Batch batch, StreamWriter wrtr, DateTime now)
{ {
///---------- ///----------
/// Header /// Header
@ -291,7 +298,15 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
foreach (var v in commonItems) foreach (var v in commonItems)
{ {
leftColumn[cnt] = v.Caption; leftColumn[cnt] = v.Caption;
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty; if (v.Uid == 72 && writerCfg.FileNameFormat.Contains("{5:"))
{
rightColumn[cnt] = string.Format(v.Format, now);
}
else
{
rightColumn[cnt] = (batch.WaterMeters.Count > 0) ? v.Print(batch.WaterMeters[0]) : string.Empty;
}
cnt++; cnt++;
} }
@ -308,7 +323,11 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
{ {
wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3)); wrtr.Write(new string(' ', maxLen - leftColumn[i].Length + 3));
} }
wrtr.Write(separatorStr);
if (!writerCfg.NoSeparatorBetweenItems)
{
wrtr.Write(separatorStr);
}
wrtr.WriteLine(rightColumn[i]); wrtr.WriteLine(rightColumn[i]);
} }

View File

@ -33,6 +33,13 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
public string[] SelectedItems; public string[] SelectedItems;
public string Footer; public string Footer;
[XmlIgnore]
private bool? noSeparatorBetweenItems;
public bool NoSeparatorBetweenItems {
get { return noSeparatorBetweenItems.HasValue ? noSeparatorBetweenItems.Value : false; }
set { noSeparatorBetweenItems = value;}
}
[XmlIgnore] [XmlIgnore]
public MetersKind MetersKind; public MetersKind MetersKind;
@ -61,11 +68,12 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
SaveGoodOnly = false; SaveGoodOnly = false;
Header = string.Empty; Header = string.Empty;
Footer = string.Empty; Footer = string.Empty;
NoSeparatorBetweenItems = false;
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("{0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, NoSpaces={7}, GoodOnly={8}", return string.Format("{0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, NoSpaces={7}, GoodOnly={8}, NoSeparatorBetweenItems={9}",
Name, Name,
DestinationPath, DestinationPath,
YearFolders, YearFolders,
@ -74,7 +82,8 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
FileNameFormat, FileNameFormat,
Separator, Separator,
EliminateSpaces, EliminateSpaces,
SaveGoodOnly); SaveGoodOnly,
NoSeparatorBetweenItems);
} }
} }
} }

View File

@ -69,6 +69,7 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
separatorLabel.Text = "Separator"; separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces"; eliminateSpacesCheckBox.Text = "No spaces";
goodOnlyCheckBox.Text = "Good only"; goodOnlyCheckBox.Text = "Good only";
noSeparatorCICheckBox.Text = "No separ. `Common i`";
headerButton.Text = Strings.Header; headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items"; commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items"; testItemsButton.Text = "Test items";
@ -96,7 +97,8 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
separatorComboBox.Text = config.Separator.ToString(); separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces; eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
goodOnlyCheckBox.Checked = config.SaveGoodOnly; goodOnlyCheckBox.Checked = config.SaveGoodOnly;
} noSeparatorCICheckBox.Checked = config.NoSeparatorBetweenItems;
}
public void Unlock() public void Unlock()
{ {
@ -118,6 +120,7 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
commonItemsButton.Enabled = true; commonItemsButton.Enabled = true;
testItemsButton.Enabled = true; testItemsButton.Enabled = true;
footerButton.Enabled = true; footerButton.Enabled = true;
noSeparatorCICheckBox.Enabled = true;
} }
public CfgUpdateFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
@ -255,6 +258,12 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
config.SaveGoodOnly = goodOnlyCheckBox.Checked; config.SaveGoodOnly = goodOnlyCheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange); flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
} }
if (config.NoSeparatorBetweenItems != noSeparatorCICheckBox.Checked)
{
config.NoSeparatorBetweenItems = noSeparatorCICheckBox.Checked;
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
}
if (config.Header != header) if (config.Header != header)
{ {

View File

@ -25,409 +25,459 @@ namespace TBF.Rig.Output.FileWriters.Enhanced
#region Component Designer generated code #region Component Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label(); this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.destinationTextBox = new System.Windows.Forms.TextBox(); this.destinationTextBox = new System.Windows.Forms.TextBox();
this.destinationLabel = new System.Windows.Forms.Label(); this.destinationLabel = new System.Windows.Forms.Label();
this.destinationButton = new System.Windows.Forms.Button(); this.destinationButton = new System.Windows.Forms.Button();
this.separatorLabel = new System.Windows.Forms.Label(); this.separatorLabel = new System.Windows.Forms.Label();
this.separatorComboBox = new System.Windows.Forms.ComboBox(); this.separatorComboBox = new System.Windows.Forms.ComboBox();
this.testItemsButton = new System.Windows.Forms.Button(); this.testItemsButton = new System.Windows.Forms.Button();
this.yearFoldersLabel = new System.Windows.Forms.Label(); this.yearFoldersLabel = new System.Windows.Forms.Label();
this.monthFoldersLabel = new System.Windows.Forms.Label(); this.monthFoldersLabel = new System.Windows.Forms.Label();
this.dayFoldersLabel = new System.Windows.Forms.Label(); this.dayFoldersLabel = new System.Windows.Forms.Label();
this.yearFoldersComboBox = new System.Windows.Forms.ComboBox(); this.yearFoldersComboBox = new System.Windows.Forms.ComboBox();
this.monthFoldersComboBox = new System.Windows.Forms.ComboBox(); this.monthFoldersComboBox = new System.Windows.Forms.ComboBox();
this.dayFoldersComboBox = new System.Windows.Forms.ComboBox(); this.dayFoldersComboBox = new System.Windows.Forms.ComboBox();
this.destination2Button = new System.Windows.Forms.Button(); this.destination2Button = new System.Windows.Forms.Button();
this.destination2TextBox = new System.Windows.Forms.TextBox(); this.destination2TextBox = new System.Windows.Forms.TextBox();
this.destination2Label = new System.Windows.Forms.Label(); this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox(); this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label(); this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox(); this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.headerButton = new System.Windows.Forms.Button(); this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button(); this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button(); this.commonItemsButton = new System.Windows.Forms.Button();
this.upgradeWizardButton = new System.Windows.Forms.Button(); this.upgradeWizardButton = new System.Windows.Forms.Button();
this.cultureComboBox = new System.Windows.Forms.ComboBox(); this.cultureComboBox = new System.Windows.Forms.ComboBox();
this.cultureLabel = new System.Windows.Forms.Label(); this.cultureLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox(); this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.subtitleFmtTextBox = new System.Windows.Forms.TextBox(); this.subtitleFmtTextBox = new System.Windows.Forms.TextBox();
this.subtitleFmtLabel = new System.Windows.Forms.Label(); this.subtitleFmtLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.noSeparatorCICheckBox = new System.Windows.Forms.CheckBox();
// this.SuspendLayout();
// nameTextBox //
// // nameTextBox
this.nameTextBox.Enabled = false; //
this.nameTextBox.Location = new System.Drawing.Point(108, 28); this.nameTextBox.Enabled = false;
this.nameTextBox.Name = "nameTextBox"; this.nameTextBox.Location = new System.Drawing.Point(162, 43);
this.nameTextBox.Size = new System.Drawing.Size(146, 20); this.nameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.nameTextBox.TabIndex = 2; this.nameTextBox.Name = "nameTextBox";
// this.nameTextBox.Size = new System.Drawing.Size(217, 26);
// nameLabel this.nameTextBox.TabIndex = 2;
// //
this.nameLabel.AutoSize = true; // nameLabel
this.nameLabel.Location = new System.Drawing.Point(17, 31); //
this.nameLabel.Name = "nameLabel"; this.nameLabel.AutoSize = true;
this.nameLabel.Size = new System.Drawing.Size(35, 13); this.nameLabel.Location = new System.Drawing.Point(26, 48);
this.nameLabel.TabIndex = 1; this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.nameLabel.Text = "Name"; this.nameLabel.Name = "nameLabel";
// this.nameLabel.Size = new System.Drawing.Size(51, 20);
// classNameLabel this.nameLabel.TabIndex = 1;
// this.nameLabel.Text = "Name";
this.classNameLabel.AutoSize = true; //
this.classNameLabel.Location = new System.Drawing.Point(105, 6); // classNameLabel
this.classNameLabel.Name = "classNameLabel"; //
this.classNameLabel.Size = new System.Drawing.Size(83, 13); this.classNameLabel.AutoSize = true;
this.classNameLabel.TabIndex = 0; this.classNameLabel.Location = new System.Drawing.Point(158, 9);
this.classNameLabel.Text = "ComonentName"; this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
// this.classNameLabel.Name = "classNameLabel";
// destinationTextBox this.classNameLabel.Size = new System.Drawing.Size(125, 20);
// this.classNameLabel.TabIndex = 0;
this.destinationTextBox.Enabled = false; this.classNameLabel.Text = "ComonentName";
this.destinationTextBox.Location = new System.Drawing.Point(108, 49); //
this.destinationTextBox.Name = "destinationTextBox"; // destinationTextBox
this.destinationTextBox.Size = new System.Drawing.Size(146, 20); //
this.destinationTextBox.TabIndex = 4; this.destinationTextBox.Enabled = false;
// this.destinationTextBox.Location = new System.Drawing.Point(162, 75);
// destinationLabel this.destinationTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.destinationTextBox.Name = "destinationTextBox";
this.destinationLabel.AutoSize = true; this.destinationTextBox.Size = new System.Drawing.Size(217, 26);
this.destinationLabel.Location = new System.Drawing.Point(17, 52); this.destinationTextBox.TabIndex = 4;
this.destinationLabel.Name = "destinationLabel"; //
this.destinationLabel.Size = new System.Drawing.Size(60, 13); // destinationLabel
this.destinationLabel.TabIndex = 3; //
this.destinationLabel.Text = "Destination"; this.destinationLabel.AutoSize = true;
// this.destinationLabel.Location = new System.Drawing.Point(26, 80);
// destinationButton this.destinationLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
// this.destinationLabel.Name = "destinationLabel";
this.destinationButton.Enabled = false; this.destinationLabel.Size = new System.Drawing.Size(90, 20);
this.destinationButton.Location = new System.Drawing.Point(269, 49); this.destinationLabel.TabIndex = 3;
this.destinationButton.Name = "destinationButton"; this.destinationLabel.Text = "Destination";
this.destinationButton.Size = new System.Drawing.Size(30, 20); //
this.destinationButton.TabIndex = 5; // destinationButton
this.destinationButton.Text = "..."; //
this.destinationButton.UseVisualStyleBackColor = true; this.destinationButton.Enabled = false;
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click); this.destinationButton.Location = new System.Drawing.Point(404, 75);
// this.destinationButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// separatorLabel this.destinationButton.Name = "destinationButton";
// this.destinationButton.Size = new System.Drawing.Size(45, 31);
this.separatorLabel.AutoSize = true; this.destinationButton.TabIndex = 5;
this.separatorLabel.Location = new System.Drawing.Point(17, 224); this.destinationButton.Text = "...";
this.separatorLabel.Name = "separatorLabel"; this.destinationButton.UseVisualStyleBackColor = true;
this.separatorLabel.Size = new System.Drawing.Size(53, 13); this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
this.separatorLabel.TabIndex = 19; //
this.separatorLabel.Text = "Separator"; // separatorLabel
// //
// separatorComboBox this.separatorLabel.AutoSize = true;
// this.separatorLabel.Location = new System.Drawing.Point(26, 345);
this.separatorComboBox.Enabled = false; this.separatorLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.separatorComboBox.FormattingEnabled = true; this.separatorLabel.Name = "separatorLabel";
this.separatorComboBox.Location = new System.Drawing.Point(108, 221); this.separatorLabel.Size = new System.Drawing.Size(80, 20);
this.separatorComboBox.Name = "separatorComboBox"; this.separatorLabel.TabIndex = 19;
this.separatorComboBox.Size = new System.Drawing.Size(146, 21); this.separatorLabel.Text = "Separator";
this.separatorComboBox.TabIndex = 20; //
// // separatorComboBox
// testItemsButton //
// this.separatorComboBox.Enabled = false;
this.testItemsButton.Enabled = false; this.separatorComboBox.FormattingEnabled = true;
this.testItemsButton.Location = new System.Drawing.Point(108, 296); this.separatorComboBox.Location = new System.Drawing.Point(162, 340);
this.testItemsButton.Name = "testItemsButton"; this.separatorComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.testItemsButton.Size = new System.Drawing.Size(146, 23); this.separatorComboBox.Name = "separatorComboBox";
this.testItemsButton.TabIndex = 25; this.separatorComboBox.Size = new System.Drawing.Size(217, 28);
this.testItemsButton.Text = "Test items"; this.separatorComboBox.TabIndex = 20;
this.testItemsButton.UseVisualStyleBackColor = true; //
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click); // testItemsButton
// //
// yearFoldersLabel this.testItemsButton.Enabled = false;
// this.testItemsButton.Location = new System.Drawing.Point(162, 455);
this.yearFoldersLabel.AutoSize = true; this.testItemsButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 94); this.testItemsButton.Name = "testItemsButton";
this.yearFoldersLabel.Name = "yearFoldersLabel"; this.testItemsButton.Size = new System.Drawing.Size(219, 35);
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13); this.testItemsButton.TabIndex = 25;
this.yearFoldersLabel.TabIndex = 9; this.testItemsButton.Text = "Test items";
this.yearFoldersLabel.Text = "Year folders"; this.testItemsButton.UseVisualStyleBackColor = true;
// this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
// monthFoldersLabel //
// // yearFoldersLabel
this.monthFoldersLabel.AutoSize = true; //
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 116); this.yearFoldersLabel.AutoSize = true;
this.monthFoldersLabel.Name = "monthFoldersLabel"; this.yearFoldersLabel.Location = new System.Drawing.Point(26, 145);
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13); this.yearFoldersLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.monthFoldersLabel.TabIndex = 11; this.yearFoldersLabel.Name = "yearFoldersLabel";
this.monthFoldersLabel.Text = "Month folders"; this.yearFoldersLabel.Size = new System.Drawing.Size(95, 20);
// this.yearFoldersLabel.TabIndex = 9;
// dayFoldersLabel this.yearFoldersLabel.Text = "Year folders";
// //
this.dayFoldersLabel.AutoSize = true; // monthFoldersLabel
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 138); //
this.dayFoldersLabel.Name = "dayFoldersLabel"; this.monthFoldersLabel.AutoSize = true;
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13); this.monthFoldersLabel.Location = new System.Drawing.Point(26, 178);
this.dayFoldersLabel.TabIndex = 13; this.monthFoldersLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.dayFoldersLabel.Text = "Day folders"; this.monthFoldersLabel.Name = "monthFoldersLabel";
// this.monthFoldersLabel.Size = new System.Drawing.Size(106, 20);
// yearFoldersComboBox this.monthFoldersLabel.TabIndex = 11;
// this.monthFoldersLabel.Text = "Month folders";
this.yearFoldersComboBox.Enabled = false; //
this.yearFoldersComboBox.FormattingEnabled = true; // dayFoldersLabel
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 91); //
this.yearFoldersComboBox.Name = "yearFoldersComboBox"; this.dayFoldersLabel.AutoSize = true;
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21); this.dayFoldersLabel.Location = new System.Drawing.Point(26, 212);
this.yearFoldersComboBox.TabIndex = 10; this.dayFoldersLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
// this.dayFoldersLabel.Name = "dayFoldersLabel";
// monthFoldersComboBox this.dayFoldersLabel.Size = new System.Drawing.Size(89, 20);
// this.dayFoldersLabel.TabIndex = 13;
this.monthFoldersComboBox.Enabled = false; this.dayFoldersLabel.Text = "Day folders";
this.monthFoldersComboBox.FormattingEnabled = true; //
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 113); // yearFoldersComboBox
this.monthFoldersComboBox.Name = "monthFoldersComboBox"; //
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21); this.yearFoldersComboBox.Enabled = false;
this.monthFoldersComboBox.TabIndex = 12; this.yearFoldersComboBox.FormattingEnabled = true;
// this.yearFoldersComboBox.Location = new System.Drawing.Point(162, 140);
// dayFoldersComboBox this.yearFoldersComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.yearFoldersComboBox.Name = "yearFoldersComboBox";
this.dayFoldersComboBox.Enabled = false; this.yearFoldersComboBox.Size = new System.Drawing.Size(217, 28);
this.dayFoldersComboBox.FormattingEnabled = true; this.yearFoldersComboBox.TabIndex = 10;
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 135); //
this.dayFoldersComboBox.Name = "dayFoldersComboBox"; // monthFoldersComboBox
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21); //
this.dayFoldersComboBox.TabIndex = 14; this.monthFoldersComboBox.Enabled = false;
// this.monthFoldersComboBox.FormattingEnabled = true;
// destination2Button this.monthFoldersComboBox.Location = new System.Drawing.Point(162, 174);
// this.monthFoldersComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.destination2Button.Enabled = false; this.monthFoldersComboBox.Name = "monthFoldersComboBox";
this.destination2Button.Location = new System.Drawing.Point(269, 70); this.monthFoldersComboBox.Size = new System.Drawing.Size(217, 28);
this.destination2Button.Name = "destination2Button"; this.monthFoldersComboBox.TabIndex = 12;
this.destination2Button.Size = new System.Drawing.Size(30, 20); //
this.destination2Button.TabIndex = 8; // dayFoldersComboBox
this.destination2Button.Text = "..."; //
this.destination2Button.UseVisualStyleBackColor = true; this.dayFoldersComboBox.Enabled = false;
// this.dayFoldersComboBox.FormattingEnabled = true;
// destination2TextBox this.dayFoldersComboBox.Location = new System.Drawing.Point(162, 208);
// this.dayFoldersComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.destination2TextBox.Enabled = false; this.dayFoldersComboBox.Name = "dayFoldersComboBox";
this.destination2TextBox.Location = new System.Drawing.Point(108, 70); this.dayFoldersComboBox.Size = new System.Drawing.Size(217, 28);
this.destination2TextBox.Name = "destination2TextBox"; this.dayFoldersComboBox.TabIndex = 14;
this.destination2TextBox.Size = new System.Drawing.Size(146, 20); //
this.destination2TextBox.TabIndex = 7; // destination2Button
// //
// destination2Label this.destination2Button.Enabled = false;
// this.destination2Button.Location = new System.Drawing.Point(404, 108);
this.destination2Label.AutoSize = true; this.destination2Button.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.destination2Label.Location = new System.Drawing.Point(17, 73); this.destination2Button.Name = "destination2Button";
this.destination2Label.Name = "destination2Label"; this.destination2Button.Size = new System.Drawing.Size(45, 31);
this.destination2Label.Size = new System.Drawing.Size(69, 13); this.destination2Button.TabIndex = 8;
this.destination2Label.TabIndex = 6; this.destination2Button.Text = "...";
this.destination2Label.Text = "Destination 2"; this.destination2Button.UseVisualStyleBackColor = true;
// //
// fileNameFmtTextBox // destination2TextBox
// //
this.fileNameFmtTextBox.Enabled = false; this.destination2TextBox.Enabled = false;
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 157); this.destination2TextBox.Location = new System.Drawing.Point(162, 108);
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox"; this.destination2TextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20); this.destination2TextBox.Name = "destination2TextBox";
this.fileNameFmtTextBox.TabIndex = 16; this.destination2TextBox.Size = new System.Drawing.Size(217, 26);
// this.destination2TextBox.TabIndex = 7;
// fileNameFmtLabel //
// // destination2Label
this.fileNameFmtLabel.AutoSize = true; //
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 160); this.destination2Label.AutoSize = true;
this.fileNameFmtLabel.Name = "fileNameFmtLabel"; this.destination2Label.Location = new System.Drawing.Point(26, 112);
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13); this.destination2Label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.fileNameFmtLabel.TabIndex = 15; this.destination2Label.Name = "destination2Label";
this.fileNameFmtLabel.Text = "File name format"; this.destination2Label.Size = new System.Drawing.Size(103, 20);
// this.destination2Label.TabIndex = 6;
// eliminateSpacesCheckBox this.destination2Label.Text = "Destination 2";
// //
this.eliminateSpacesCheckBox.AutoSize = true; // fileNameFmtTextBox
this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(20, 262); //
this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox"; this.fileNameFmtTextBox.Enabled = false;
this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17); this.fileNameFmtTextBox.Location = new System.Drawing.Point(162, 242);
this.eliminateSpacesCheckBox.TabIndex = 21; this.fileNameFmtTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.eliminateSpacesCheckBox.Text = "No spaces"; this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true; this.fileNameFmtTextBox.Size = new System.Drawing.Size(217, 26);
// this.fileNameFmtTextBox.TabIndex = 16;
// headerButton //
// // fileNameFmtLabel
this.headerButton.Enabled = false; //
this.headerButton.Location = new System.Drawing.Point(108, 246); this.fileNameFmtLabel.AutoSize = true;
this.headerButton.Name = "headerButton"; this.fileNameFmtLabel.Location = new System.Drawing.Point(26, 246);
this.headerButton.Size = new System.Drawing.Size(146, 23); this.fileNameFmtLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.headerButton.TabIndex = 23; this.fileNameFmtLabel.Name = "fileNameFmtLabel";
this.headerButton.Text = "Header"; this.fileNameFmtLabel.Size = new System.Drawing.Size(128, 20);
this.headerButton.UseVisualStyleBackColor = true; this.fileNameFmtLabel.TabIndex = 15;
this.headerButton.Click += new System.EventHandler(this.headerButton_Click); this.fileNameFmtLabel.Text = "File name format";
// //
// footerButton // eliminateSpacesCheckBox
// //
this.footerButton.Enabled = false; this.eliminateSpacesCheckBox.AutoSize = true;
this.footerButton.Location = new System.Drawing.Point(108, 321); this.eliminateSpacesCheckBox.Enabled = false;
this.footerButton.Name = "footerButton"; this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(30, 403);
this.footerButton.Size = new System.Drawing.Size(146, 23); this.eliminateSpacesCheckBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.footerButton.TabIndex = 26; this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.footerButton.Text = "Footer"; this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(110, 24);
this.footerButton.UseVisualStyleBackColor = true; this.eliminateSpacesCheckBox.TabIndex = 21;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click); this.eliminateSpacesCheckBox.Text = "No spaces";
// this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
// commonItemsButton //
// // headerButton
this.commonItemsButton.Enabled = false; //
this.commonItemsButton.Location = new System.Drawing.Point(108, 271); this.headerButton.Enabled = false;
this.commonItemsButton.Name = "commonItemsButton"; this.headerButton.Location = new System.Drawing.Point(162, 378);
this.commonItemsButton.Size = new System.Drawing.Size(146, 23); this.headerButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commonItemsButton.TabIndex = 24; this.headerButton.Name = "headerButton";
this.commonItemsButton.Text = "Common items"; this.headerButton.Size = new System.Drawing.Size(219, 35);
this.commonItemsButton.UseVisualStyleBackColor = true; this.headerButton.TabIndex = 23;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click); this.headerButton.Text = "Header";
// this.headerButton.UseVisualStyleBackColor = true;
// upgradeWizardButton this.headerButton.Click += new System.EventHandler(this.headerButton_Click);
// //
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 271); // footerButton
this.upgradeWizardButton.Name = "upgradeWizardButton"; //
this.upgradeWizardButton.Size = new System.Drawing.Size(80, 48); this.footerButton.Enabled = false;
this.upgradeWizardButton.TabIndex = 27; this.footerButton.Location = new System.Drawing.Point(162, 494);
this.upgradeWizardButton.Text = "Upgrade wizard"; this.footerButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.upgradeWizardButton.UseVisualStyleBackColor = true; this.footerButton.Name = "footerButton";
this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click); this.footerButton.Size = new System.Drawing.Size(219, 35);
// this.footerButton.TabIndex = 26;
// cultureComboBox this.footerButton.Text = "Footer";
// this.footerButton.UseVisualStyleBackColor = true;
this.cultureComboBox.Enabled = false; this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
this.cultureComboBox.FormattingEnabled = true; //
this.cultureComboBox.Location = new System.Drawing.Point(108, 178); // commonItemsButton
this.cultureComboBox.Name = "cultureComboBox"; //
this.cultureComboBox.Size = new System.Drawing.Size(146, 21); this.commonItemsButton.Enabled = false;
this.cultureComboBox.TabIndex = 18; this.commonItemsButton.Location = new System.Drawing.Point(162, 417);
// this.commonItemsButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// cultureLabel this.commonItemsButton.Name = "commonItemsButton";
// this.commonItemsButton.Size = new System.Drawing.Size(219, 35);
this.cultureLabel.AutoSize = true; this.commonItemsButton.TabIndex = 24;
this.cultureLabel.Location = new System.Drawing.Point(17, 181); this.commonItemsButton.Text = "Common items";
this.cultureLabel.Name = "cultureLabel"; this.commonItemsButton.UseVisualStyleBackColor = true;
this.cultureLabel.Size = new System.Drawing.Size(42, 13); this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
this.cultureLabel.TabIndex = 17; //
this.cultureLabel.Text = "Cullture"; // upgradeWizardButton
// //
// goodOnlyCheckBox this.upgradeWizardButton.Location = new System.Drawing.Point(404, 417);
// this.upgradeWizardButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.goodOnlyCheckBox.AutoSize = true; this.upgradeWizardButton.Name = "upgradeWizardButton";
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 285); this.upgradeWizardButton.Size = new System.Drawing.Size(120, 74);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; this.upgradeWizardButton.TabIndex = 27;
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17); this.upgradeWizardButton.Text = "Upgrade wizard";
this.goodOnlyCheckBox.TabIndex = 22; this.upgradeWizardButton.UseVisualStyleBackColor = true;
this.goodOnlyCheckBox.Text = "Good only"; this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click);
this.goodOnlyCheckBox.UseVisualStyleBackColor = true; //
// // cultureComboBox
// subtitleFmtTextBox //
// this.cultureComboBox.Enabled = false;
this.subtitleFmtTextBox.Enabled = false; this.cultureComboBox.FormattingEnabled = true;
this.subtitleFmtTextBox.Location = new System.Drawing.Point(108, 200); this.cultureComboBox.Location = new System.Drawing.Point(162, 274);
this.subtitleFmtTextBox.Name = "subtitleFmtTextBox"; this.cultureComboBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.subtitleFmtTextBox.Size = new System.Drawing.Size(146, 20); this.cultureComboBox.Name = "cultureComboBox";
this.subtitleFmtTextBox.TabIndex = 29; this.cultureComboBox.Size = new System.Drawing.Size(217, 28);
// this.cultureComboBox.TabIndex = 18;
// subtitleFmtLabel //
// // cultureLabel
this.subtitleFmtLabel.AutoSize = true; //
this.subtitleFmtLabel.Location = new System.Drawing.Point(17, 203); this.cultureLabel.AutoSize = true;
this.subtitleFmtLabel.Name = "subtitleFmtLabel"; this.cultureLabel.Location = new System.Drawing.Point(26, 278);
this.subtitleFmtLabel.Size = new System.Drawing.Size(74, 13); this.cultureLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.subtitleFmtLabel.TabIndex = 28; this.cultureLabel.Name = "cultureLabel";
this.subtitleFmtLabel.Text = "Subtitle format"; this.cultureLabel.Size = new System.Drawing.Size(63, 20);
// this.cultureLabel.TabIndex = 17;
// label1 this.cultureLabel.Text = "Cullture";
// //
this.label1.AutoSize = true; // goodOnlyCheckBox
this.label1.Location = new System.Drawing.Point(257, 211); //
this.label1.Name = "label1"; this.goodOnlyCheckBox.AutoSize = true;
this.label1.Size = new System.Drawing.Size(174, 13); this.goodOnlyCheckBox.Enabled = false;
this.label1.TabIndex = 30; this.goodOnlyCheckBox.Location = new System.Drawing.Point(30, 438);
this.label1.Text = "4:wmStr 5:s/n 6:main s/n 7:aux.s/n"; this.goodOnlyCheckBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
// label2 this.goodOnlyCheckBox.Size = new System.Drawing.Size(107, 24);
// this.goodOnlyCheckBox.TabIndex = 22;
this.label2.AutoSize = true; this.goodOnlyCheckBox.Text = "Good only";
this.label2.Location = new System.Drawing.Point(257, 198); this.goodOnlyCheckBox.UseVisualStyleBackColor = false;
this.label2.Name = "label2"; //
this.label2.Size = new System.Drawing.Size(168, 13); // subtitleFmtTextBox
this.label2.TabIndex = 31; //
this.label2.Text = "0:pos 1:s/n 2:aux.s/n 3:compl.s/n"; this.subtitleFmtTextBox.Enabled = false;
// this.subtitleFmtTextBox.Location = new System.Drawing.Point(162, 308);
// label3 this.subtitleFmtTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.subtitleFmtTextBox.Name = "subtitleFmtTextBox";
this.label3.AutoSize = true; this.subtitleFmtTextBox.Size = new System.Drawing.Size(217, 26);
this.label3.Location = new System.Drawing.Point(257, 155); this.subtitleFmtTextBox.TabIndex = 29;
this.label3.Name = "label3"; //
this.label3.Size = new System.Drawing.Size(138, 13); // subtitleFmtLabel
this.label3.TabIndex = 32; //
this.label3.Text = "0:end t. 1:start t. 2:batch nr."; this.subtitleFmtLabel.AutoSize = true;
// this.subtitleFmtLabel.Location = new System.Drawing.Point(26, 312);
// label4 this.subtitleFmtLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
// this.subtitleFmtLabel.Name = "subtitleFmtLabel";
this.label4.AutoSize = true; this.subtitleFmtLabel.Size = new System.Drawing.Size(113, 20);
this.label4.Location = new System.Drawing.Point(257, 168); this.subtitleFmtLabel.TabIndex = 28;
this.label4.Name = "label4"; this.subtitleFmtLabel.Text = "Subtitle format";
this.label4.Size = new System.Drawing.Size(128, 13); //
this.label4.TabIndex = 33; // label1
this.label4.Text = "3:bench name 4:bench id"; //
// this.label1.AutoSize = true;
// WriterCfgCtrl this.label1.Location = new System.Drawing.Point(386, 325);
// this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.label1.Name = "label1";
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.label1.Size = new System.Drawing.Size(248, 20);
this.Controls.Add(this.label4); this.label1.TabIndex = 30;
this.Controls.Add(this.label3); this.label1.Text = "4:wmStr 5:s/n 6:main s/n 7:aux.s/n";
this.Controls.Add(this.label2); //
this.Controls.Add(this.label1); // label2
this.Controls.Add(this.subtitleFmtTextBox); //
this.Controls.Add(this.subtitleFmtLabel); this.label2.AutoSize = true;
this.Controls.Add(this.goodOnlyCheckBox); this.label2.Location = new System.Drawing.Point(386, 305);
this.Controls.Add(this.cultureComboBox); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Controls.Add(this.cultureLabel); this.label2.Name = "label2";
this.Controls.Add(this.upgradeWizardButton); this.label2.Size = new System.Drawing.Size(237, 20);
this.Controls.Add(this.commonItemsButton); this.label2.TabIndex = 31;
this.Controls.Add(this.footerButton); this.label2.Text = "0:pos 1:s/n 2:aux.s/n 3:compl.s/n";
this.Controls.Add(this.headerButton); //
this.Controls.Add(this.eliminateSpacesCheckBox); // label3
this.Controls.Add(this.fileNameFmtTextBox); //
this.Controls.Add(this.fileNameFmtLabel); this.label3.AutoSize = true;
this.Controls.Add(this.destination2Button); this.label3.Location = new System.Drawing.Point(386, 238);
this.Controls.Add(this.destination2TextBox); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Controls.Add(this.destination2Label); this.label3.Name = "label3";
this.Controls.Add(this.dayFoldersComboBox); this.label3.Size = new System.Drawing.Size(203, 20);
this.Controls.Add(this.monthFoldersComboBox); this.label3.TabIndex = 32;
this.Controls.Add(this.yearFoldersComboBox); this.label3.Text = "0:end t. 1:start t. 2:batch nr.";
this.Controls.Add(this.dayFoldersLabel); //
this.Controls.Add(this.monthFoldersLabel); // label4
this.Controls.Add(this.yearFoldersLabel); //
this.Controls.Add(this.testItemsButton); this.label4.AutoSize = true;
this.Controls.Add(this.separatorComboBox); this.label4.Location = new System.Drawing.Point(386, 258);
this.Controls.Add(this.separatorLabel); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Controls.Add(this.destinationButton); this.label4.Name = "label4";
this.Controls.Add(this.destinationTextBox); this.label4.Size = new System.Drawing.Size(239, 20);
this.Controls.Add(this.destinationLabel); this.label4.TabIndex = 33;
this.Controls.Add(this.nameTextBox); this.label4.Text = "3:bench name 4:bench id, 5:Now";
this.Controls.Add(this.nameLabel); //
this.Controls.Add(this.classNameLabel); // noSeparatorCICheckBox
this.Name = "WriterCfgCtrl"; //
this.Size = new System.Drawing.Size(440, 350); this.noSeparatorCICheckBox.Enabled = false;
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load); this.noSeparatorCICheckBox.Location = new System.Drawing.Point(30, 470);
this.ResumeLayout(false); this.noSeparatorCICheckBox.Name = "noSeparatorCICheckBox";
this.PerformLayout(); this.noSeparatorCICheckBox.Size = new System.Drawing.Size(125, 59);
this.noSeparatorCICheckBox.TabIndex = 34;
this.noSeparatorCICheckBox.Text = "No separ. \"Common i.\"";
this.noSeparatorCICheckBox.UseVisualStyleBackColor = true;
//
// WriterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.noSeparatorCICheckBox);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.subtitleFmtTextBox);
this.Controls.Add(this.subtitleFmtLabel);
this.Controls.Add(this.goodOnlyCheckBox);
this.Controls.Add(this.cultureComboBox);
this.Controls.Add(this.cultureLabel);
this.Controls.Add(this.upgradeWizardButton);
this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton);
this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button);
this.Controls.Add(this.destination2TextBox);
this.Controls.Add(this.destination2Label);
this.Controls.Add(this.dayFoldersComboBox);
this.Controls.Add(this.monthFoldersComboBox);
this.Controls.Add(this.yearFoldersComboBox);
this.Controls.Add(this.dayFoldersLabel);
this.Controls.Add(this.monthFoldersLabel);
this.Controls.Add(this.yearFoldersLabel);
this.Controls.Add(this.testItemsButton);
this.Controls.Add(this.separatorComboBox);
this.Controls.Add(this.separatorLabel);
this.Controls.Add(this.destinationButton);
this.Controls.Add(this.destinationTextBox);
this.Controls.Add(this.destinationLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(660, 538);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
} }
private System.Windows.Forms.CheckBox noSeparatorCICheckBox;
#endregion #endregion
private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.TextBox nameTextBox;

View File

@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Results;
using TBF.Rig.GenericDevices;
using TBF.Rig.Output.FileWriters.Enhanced;
using TBF.Rig.Sequences;
namespace TBFTests.Rig.Output.FileWriters.Enhanced
{
[TestClass]
[TestSubject(typeof(Writer))]
public class WriterTest
{
[TestInitialize]
public void Setup()
{
// Mock IBenchInfo and assign it to static field
var mockBenchInfo = new Mock<IBenchInfo>();
// Optional: Setup mock behavior if GetName or similar is used
mockBenchInfo.Setup(b => b.TestBenchName).Returns("TestBench");
mockBenchInfo.Setup(b => b.TestBenchId).Returns(1);
ProcessData.BenchInfo = mockBenchInfo.Object;
}
[TestCleanup]
public void Cleanup()
{
// Clean up the static reference
ProcessData.BenchInfo = null;
}
[TestMethod]
public void GetFilenameTest()
{
FactorySingle factory = new FactorySingle();
WriterCfg defaultConfig = factory.DefaultConfig() as WriterCfg;
string dateFormat = "yyMMdd-HHmm";
defaultConfig.FileNameFormat = $"{{5:{dateFormat}}}.txt";
Writer writer = new Writer( defaultConfig);
Results.Entities.Batch batch = new Results.Entities.Batch();
DateTime time = DateTime.Now;
batch.EndTime = time;
string filename = writer.GetFilename("C:\\TBF\\Results\\", batch, time);
// Assert
Assert.IsNotNull(filename, "Filename should not be null.");
Assert.IsTrue(filename.StartsWith("C:\\TBF\\Results\\"), "Filename should start with base path.");
//test extension
Assert.IsTrue(filename.EndsWith(".txt") , "Filename should have correct extension.");
//test path - Format path like \2025\7\28\
string path = $@"\{time.Year}\{time.Month}\{time.Day}\";
Assert.IsTrue( filename.Contains(path));
//test file name
string expected = string.Format($"{{0:{dateFormat}}}.txt", time);
Assert.IsTrue( filename.Contains(expected));
}
[TestMethod]
public void WriteRsltsExTest()
{
FactorySingle factory = new FactorySingle();
WriterCfg defaultConfig = factory.DefaultConfig() as WriterCfg;
string dateFormat = "yyMMdd-HHmm";
defaultConfig.FileNameFormat = $"{{5:{dateFormat}}}.txt";
defaultConfig.Header = "Header :)";
Writer writer = new Writer( defaultConfig);
var field = typeof(Writer).GetField("commonItems", BindingFlags.NonPublic | BindingFlags.Instance);
var fieldHeader = typeof(Writer).GetField("header", BindingFlags.NonPublic | BindingFlags.Instance);
fieldHeader?.SetValue(writer, defaultConfig.Header);
var mockList = new List<Results.WMeterRsltItemSpec>
{
new WMeterRsltItemSpec (ItemID.Batch_end_time, "End", null,Common.Quantity.DateTime, Common.ItemCategory.Other, null)
};
mockList[0].Caption = "Date and time";
string formatCommonTime = "yyyy.MM.dd HH:mm";
mockList[0].Format = $"{{0:{formatCommonTime}}}";
field?.SetValue(writer, mockList);
Results.Entities.Batch batch = new Results.Entities.Batch();
DateTime time = DateTime.Now;
batch.EndTime = time;
using (var memStream = new MemoryStream())
using (var writerStream = new StreamWriter(memStream))
{
writer.WriteRsltsEx(batch, writerStream, time);
writerStream.Flush();
// Get the actual content
memStream.Position = 0;
using (var reader = new StreamReader(memStream))
{
string content = reader.ReadToEnd();
// Assert on the actual content
Assert.IsNotNull(content);
Assert.IsTrue(content.Contains(defaultConfig.Header));
Assert.IsTrue(content.Contains("Date and time"));
string expectedCommonTime = string.Format($"{{0:{formatCommonTime}}}", time);
Assert.IsTrue(content.Contains(expectedCommonTime));
}
}
}
}
}

View File

@ -101,6 +101,7 @@
<Compile Include="Rig\Network\Camera\CJMS11\CameraTest.cs" /> <Compile Include="Rig\Network\Camera\CJMS11\CameraTest.cs" />
<Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraTest.cs" /> <Compile Include="Rig\Network\Camera\KeyenceIV3G120\CameraTest.cs" />
<Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiTest.cs" /> <Compile Include="Rig\Network\Camera\RoiForFixedStartKeyence\RoiTest.cs" />
<Compile Include="Rig\Output\FileWriters\Enhanced\WriterTest.cs" />
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\CliRunnerTest.cs" /> <Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\CliRunnerTest.cs" />
<Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\PoseidonReaderTest.cs" /> <Compile Include="Rig\RegisterReaders\PoseidonCmdStartStop\PoseidonReaderTest.cs" />
</ItemGroup> </ItemGroup>
@ -109,10 +110,18 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\Config\Config.csproj"> <ProjectReference Include="..\Config\Config.csproj">
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project> <Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
<Name>Config</Name> <Name>Config</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Results\Results.csproj">
<Project>{9d0dcc88-dc81-47eb-9fdd-4c3907871bfb}</Project>
<Name>Results</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj"> <ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}</Project> <Project>{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}</Project>
<Name>TBF</Name> <Name>TBF</Name>