Skip to content

Commit

Permalink
Minor test project refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
adambajguz committed Jul 12, 2021
1 parent e3e8c69 commit f928335
Show file tree
Hide file tree
Showing 137 changed files with 959 additions and 392 deletions.
12 changes: 6 additions & 6 deletions src/Typin/Typin.Core/ApplicationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public class ApplicationConfiguration
/// <summary>
/// Command types defined in this application.
/// </summary>
public IReadOnlyList<Type> CommandTypes { get; }
public IReadOnlyCollection<Type> CommandTypes { get; }

/// <summary>
/// Dynamic command types defined in this application.
/// </summary>
public IReadOnlyList<Type> DynamicCommandTypes { get; }
public IReadOnlyCollection<Type> DynamicCommandTypes { get; }

/// <summary>
/// Custom directives defined in this application.
/// </summary>
public IReadOnlyList<Type> DirectiveTypes { get; }
public IReadOnlyCollection<Type> DirectiveTypes { get; }

/// <summary>
/// Collection of middlewares in application.
Expand All @@ -48,9 +48,9 @@ public class ApplicationConfiguration
/// Initializes an instance of <see cref="ApplicationConfiguration"/>.
/// </summary>
public ApplicationConfiguration(IReadOnlyList<Type> modeTypes,
IReadOnlyList<Type> commandTypes,
IReadOnlyList<Type> dynamicCommandTypes,
IReadOnlyList<Type> customDirectives,
IReadOnlyCollection<Type> commandTypes,
IReadOnlyCollection<Type> dynamicCommandTypes,
IReadOnlyCollection<Type> customDirectives,
LinkedList<Type> middlewareTypes,
Type startupMode,
IEnumerable<ServiceDescriptor> services)
Expand Down
2 changes: 1 addition & 1 deletion src/Typin/Typin.Core/ICliCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface ICliCommandExecutor
/// <summary>
/// Executes a command.
/// </summary>
Task<int> ExecuteCommandAsync(IEnumerable<string> commandLineArguments);
Task<int> ExecuteCommandAsync(IEnumerable<string> commandLineArguments); //TODO: add cancellation token

/// <summary>
/// Executes a command.
Expand Down
6 changes: 6 additions & 0 deletions src/Typin/Typin.Core/Typin.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Typin</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Typin.Tests</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Typin.Tests.Data.Common</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Typin.Tests.Data.Commands
namespace Typin.Tests.Data.Common.Commands
{
using System.Threading;
using System.Threading.Tasks;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Newtonsoft.Json;

internal static class JsonExtensions
public static class JsonExtensions
{
private static readonly JsonSerializerSettings _settings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using System.Collections.Generic;

internal static class TestStringExtenstions
public static class TestStringExtenstions
{
public static string JoinToInteractiveCommand(this IEnumerable<string> commands)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using Typin.AutoCompletion;

internal class TestAutoCompleteHandler : IAutoCompletionHandler
public class TestAutoCompleteHandler : IAutoCompletionHandler
{
public char[] Separators { get; set; } = new[] { ' ', '.', '/', '\\', ':' };

Expand Down
17 changes: 17 additions & 0 deletions src/Typin/Typin.Tests.Data.Common/Typin.Tests.Data.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Typin\Typin.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Typin.Attributes;

[Command("cmd")]
[Command("duplicated-ex")]
public class GenericExceptionCommand : ICommand
{
[Option("msg", 'm')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Typin.Attributes;

[Command("cmd")]
[Command("duplicated-ex")]
public class GenericInnerExceptionCommand : ICommand
{
[Option("msg", 'm')]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Typin.Tests.Data.Common\Typin.Tests.Data.Common.csproj" />
<ProjectReference Include="..\Typin\Typin.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class ConflictWithHelpOptionCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

// Must be default because version option is available only on default commands
[Command]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class DuplicateOptionEnvironmentVariableNamesCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class DuplicateOptionNamesCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class DuplicateOptionShortNamesCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class DuplicateParameterNameCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class DuplicateParameterOrderCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class EmptyOptionNameCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;
using Typin.Tests.Data.CustomTypes.InitializableByConverter;

[Command("cmd")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class InvalidOptionNameCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class InvalidOptionShortNameCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;
using Typin.Tests.Data.CustomTypes.InitializableByConverter;

[Command("cmd")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class MultipleNonScalarParametersCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Typin.Tests.Data.Commands.Invalid
{
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

public class NonAnnotatedCommand : SelfSerializeCommandBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class NonLastNonScalarParameterCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class NonLetterOptionName0Command : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class NonLetterOptionShortName0Command : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command]
public class OtherDefaultCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class SingleCharacterOptionNameCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Typin.Tests.Data.DynamicCommands.Invalid
{
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Typin;
using Typin.Attributes;
using Typin.Console;
using Typin.DynamicCommands;

public class InvalidDynamicCommand : ICommand
{
private readonly IConsole _console;

[Parameter(0)]
public string Param0 { get; init; } = string.Empty;

[Option("opt0")]
public string Opt0 { get; init; } = string.Empty;

[Option("opt1")]
public int Opt1 { get; init; }

public IArgumentCollection Arguments { get; init; } = default!;

public InvalidDynamicCommand(IConsole console)
{
_console = console;
}

public ValueTask ExecuteAsync(CancellationToken cancellationToken)
{
_console.Output.WriteLine(JsonConvert.SerializeObject(this, Formatting.Indented));

return default;
}
}
}
14 changes: 14 additions & 0 deletions src/Typin/Typin.Tests.Data.Invalid/Typin.Tests.Data.Invalid.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Typin.Tests.Data.Common\Typin.Tests.Data.Common.csproj" />
<ProjectReference Include="..\Typin\Typin.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Typin.Tests.Data.Common\Typin.Tests.Data.Common.csproj" />
<ProjectReference Include="..\Typin\Typin.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class WithDefaultValuesAndNamesCommand : SelfSerializeCommandBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using Typin.Attributes;
using Typin.Console;
using Typin.Tests.Data.Commands;
using Typin.Tests.Data.Common.Commands;

[Command("cmd")]
public class WithDefaultValuesCommand : SelfSerializeCommandBase
Expand Down
Loading

0 comments on commit f928335

Please sign in to comment.