Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Unitverse.Core/Helpers/DetectedGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@ public DetectedGenerationOptions(IGenerationOptions baseOptions, bool? usefluent
public bool OmitTestClassAttribute => _baseOptions.OmitTestClassAttribute;

public bool UseSeparateChecksForNullAndEmpty => _baseOptions.UseSeparateChecksForNullAndEmpty;

public bool IncludeSourceProjectAsFolder => _baseOptions.IncludeSourceProjectAsFolder;
}
}
2 changes: 2 additions & 0 deletions src/Unitverse.Core/Options/IGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ public interface IGenerationOptions
bool OmitTestClassAttribute { get; }

bool UseSeparateChecksForNullAndEmpty { get; }

bool IncludeSourceProjectAsFolder { get; }
}
}
3 changes: 3 additions & 0 deletions src/Unitverse.Core/Options/MutableGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public MutableGenerationOptions(IGenerationOptions options)
EmitMultilinePocoInitializers = options.EmitMultilinePocoInitializers;
UseFieldsForConstructorParameterTests = options.UseFieldsForConstructorParameterTests;
UseSeparateChecksForNullAndEmpty = options.UseSeparateChecksForNullAndEmpty;
IncludeSourceProjectAsFolder = options.IncludeSourceProjectAsFolder;
}

public TestFrameworkTypes FrameworkType { get; set; }
Expand Down Expand Up @@ -125,5 +126,7 @@ public MutableGenerationOptions(IGenerationOptions options)
public bool OmitTestClassAttribute { get; set; }

public bool UseSeparateChecksForNullAndEmpty { get; set; }

public bool IncludeSourceProjectAsFolder { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Unitverse.Tests.Common/DefaultGenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ public class DefaultGenerationOptions : IGenerationOptions
public bool OmitTestClassAttribute { get; set; } = false;

public bool UseSeparateChecksForNullAndEmpty { get; set; } = false;

public bool IncludeSourceProjectAsFolder { get; set; } = false;
}
}
11 changes: 11 additions & 0 deletions src/Unitverse/Commands/GenerationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using EnvDTE;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.Shell;
Expand All @@ -25,6 +26,16 @@ public GenerationItem(ProjectItemModel source, ProjectMapping mapping)

var nameParts = VsProjectHelper.GetFolderParts(source.Item);

if (mapping.Options.GenerationOptions.IncludeSourceProjectAsFolder)
{
var sourceName = mapping.SourceProject.Name;
var sourceNameParts = sourceName.Split('.');
foreach (var sourceNamePart in sourceNameParts.Reverse())
{
nameParts.Add(sourceNamePart);
}
}

var targetProject = mapping.TargetProject;
TargetProjectItems = TargetFinder.FindTargetFolder(targetProject, nameParts, true, out _targetPath);

Expand Down
5 changes: 5 additions & 0 deletions src/Unitverse/Options/GenerationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,10 @@ public class GenerationOptions : DialogPage, IGenerationOptions
[DisplayName("Use separate checks for null and empty")]
[Description("Whether to emit separate methods for null and empty string checks")]
public bool UseSeparateChecksForNullAndEmpty { get; set; } = false;

[Category("Naming")]
[DisplayName("Include source project as target folder")]
[Description("Whether to include the source project as part of the target folder structure")]
public bool IncludeSourceProjectAsFolder { get; set; } = false;
}
}
Loading