-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from godrose/fb-use-single-assemblies-source
Fb use single assemblies source
- Loading branch information
Showing
40 changed files
with
533 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Solid.Core.Tests | ||
{ | ||
public class PatternsCalculatorTests | ||
{ | ||
public class InputData | ||
{ | ||
public InputData(string[] prefixes, string[] namespaces, string[] extensions) | ||
{ | ||
Prefixes = prefixes; | ||
Namespaces = namespaces; | ||
Extensions = extensions; | ||
} | ||
|
||
public string[] Prefixes { get; } | ||
public string[] Namespaces { get; } | ||
public string[] Extensions { get; } | ||
} | ||
|
||
public static IEnumerable<object[]> NonEmptyCollectionsData => | ||
new List<object[]> | ||
{ | ||
new object[] | ||
{ | ||
new InputData(new[] {"Prefix"}, new[] {"Namespace"}, new[] {"ext"}), | ||
new[] {new PatternDescription("Prefix", "Namespace", "ext")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(new[] {"Prefix"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext"}), | ||
new[] | ||
{ | ||
new PatternDescription("Prefix", "Namespace1", "ext"), | ||
new PatternDescription("Prefix", "Namespace2", "ext") | ||
} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(new[] {"Prefix"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext1", "ext2"}), | ||
new[] | ||
{ | ||
new PatternDescription("Prefix", "Namespace1", "ext1"), | ||
new PatternDescription("Prefix", "Namespace1", "ext2"), | ||
new PatternDescription("Prefix", "Namespace2", "ext1"), | ||
new PatternDescription("Prefix", "Namespace2", "ext2") | ||
} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(new[] {"Prefix1", "Prefix2"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext1", "ext2"}), | ||
new[] | ||
{ | ||
new PatternDescription("Prefix1", "Namespace1", "ext1"), | ||
new PatternDescription("Prefix1", "Namespace1", "ext2"), | ||
new PatternDescription("Prefix1", "Namespace2", "ext1"), | ||
new PatternDescription("Prefix1", "Namespace2", "ext2"), | ||
new PatternDescription("Prefix2", "Namespace1", "ext1"), | ||
new PatternDescription("Prefix2", "Namespace1", "ext2"), | ||
new PatternDescription("Prefix2", "Namespace2", "ext1"), | ||
new PatternDescription("Prefix2", "Namespace2", "ext2") | ||
} | ||
} | ||
}; | ||
|
||
public static IEnumerable<object[]> EmptyCollectionsData => | ||
new List<object[]> | ||
{ | ||
new object[] | ||
{ | ||
new InputData(new string[] {}, new[] {"Namespace"}, new[] {"ext"}), | ||
new[] {new PatternDescription("*", "Namespace", "ext")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(null, new[] {"Namespace"}, new[] {"ext"}), | ||
new[] {new PatternDescription("*", "Namespace", "ext")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(new string[] {}, new string[] {}, new[] {"ext"}), | ||
new[] {new PatternDescription("*", "*", "ext")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(null, null, new[] {"ext"}), | ||
new[] {new PatternDescription("*", "*", "ext")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(new string[] {}, new string[] {}, new string[] {}), | ||
new[] {new PatternDescription("*", "*", "*")} | ||
}, | ||
new object[] | ||
{ | ||
new InputData(null, null, null), | ||
new[] {new PatternDescription("*", "*", "*")} | ||
} | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(NonEmptyCollectionsData))] | ||
[MemberData(nameof(EmptyCollectionsData))] | ||
public void Calculate_VariousInputsAreSupplied_ExpectedOutputsAreReturned(InputData input, | ||
PatternDescription[] expectedOutput) | ||
{ | ||
var searcher = new PatternsCalculator(); | ||
var paths = searcher.Calculate(input.Prefixes, input.Namespaces, input.Extensions).ToArray(); | ||
|
||
paths.Should().BeEquivalentTo(expectedOutput); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.6.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Solid.Core\Solid.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Solid.Core | ||
{ | ||
internal static class CollectionExtensions | ||
{ | ||
internal static string[] Patch(this string[] input) | ||
{ | ||
return input == null || input.Length == 0 ? new[] { Consts.WildCard } : input; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Solid.Core | ||
{ | ||
/// <summary> | ||
/// Constant values. | ||
/// </summary> | ||
public static class Consts | ||
{ | ||
/// <summary> | ||
/// Wildcard value. | ||
/// </summary> | ||
public const string WildCard = "*"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Solid.Core | ||
{ | ||
/// <summary> | ||
/// The file path pattern description. | ||
/// </summary> | ||
public struct PatternDescription | ||
{ | ||
/// <summary> | ||
/// Initializes an instance of <see cref="PatternDescription"/> | ||
/// </summary> | ||
/// <param name="prefix">The prefix.</param> | ||
/// <param name="contents">The contents.</param> | ||
/// <param name="postfix">The postfix.</param> | ||
public PatternDescription(string prefix, string contents, string postfix) | ||
{ | ||
Prefix = prefix; | ||
Contents = contents; | ||
Postfix = postfix; | ||
} | ||
|
||
/// <summary> | ||
/// The prefix. | ||
/// </summary> | ||
public string Prefix { get; } | ||
|
||
/// <summary> | ||
/// The contents. | ||
/// </summary> | ||
public string Contents { get; } | ||
|
||
/// <summary> | ||
/// The postfix. | ||
/// </summary> | ||
public string Postfix { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Solid.Core | ||
{ | ||
/// <summary> | ||
/// Calculates patterns for file paths. | ||
/// </summary> | ||
public class PatternsCalculator | ||
{ | ||
/// <summary> | ||
/// Calculates patterns for file paths based on the required conditions. | ||
/// </summary> | ||
/// <param name="prefixes">The list of allowed prefixes. Leave empty if all are allowed.</param> | ||
/// <param name="namespaces">The list of allowed namespaces. Leave empty if all are allowed.</param> | ||
/// <param name="extensions">The list of allowed extensions. Leave empty if all are allowed.</param> | ||
/// <returns>The list of allowed patterns.</returns> | ||
public IEnumerable<PatternDescription> Calculate(string[] prefixes, string[] namespaces, string[] extensions) | ||
{ | ||
prefixes = prefixes.Patch(); | ||
namespaces = namespaces.Patch(); | ||
extensions = extensions.Patch(); | ||
|
||
foreach (var prefix in prefixes) | ||
{ | ||
foreach (var ns in namespaces) | ||
{ | ||
foreach (var extension in extensions) | ||
{ | ||
yield return new PatternDescription(prefix, ns, extension); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 2 additions & 9 deletions
11
Solid.Patterns.ChainOfResponsibility/Solid.Patterns.ChainOfResponsibility.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.