mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Move tests into corresponding namespaces
This commit is contained in:
39
CliFx.Tests/Services/DelegateCommandFactoryTests.cs
Normal file
39
CliFx.Tests/Services/DelegateCommandFactoryTests.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CliFx.Models;
|
||||
using CliFx.Services;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace CliFx.Tests.Services
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class DelegateCommandFactoryTests
|
||||
{
|
||||
private static CommandSchema GetCommandSchema(Type commandType) =>
|
||||
new CommandSchemaResolver().GetCommandSchemas(new[] {commandType}).Single();
|
||||
|
||||
private static IEnumerable<TestCaseData> GetTestCases_CreateCommand()
|
||||
{
|
||||
yield return new TestCaseData(
|
||||
new Func<CommandSchema, ICommand>(schema => (ICommand) Activator.CreateInstance(schema.Type)),
|
||||
GetCommandSchema(typeof(TestCommand))
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(nameof(GetTestCases_CreateCommand))]
|
||||
public void CreateCommand_Test(Func<CommandSchema, ICommand> factoryMethod, CommandSchema commandSchema)
|
||||
{
|
||||
// Arrange
|
||||
var factory = new DelegateCommandFactory(factoryMethod);
|
||||
|
||||
// Act
|
||||
var command = factory.CreateCommand(commandSchema);
|
||||
|
||||
// Assert
|
||||
command.Should().BeOfType(commandSchema.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user