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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using BuslyCLI.Commands.NsbCommand;

namespace BuslyCLI.Console.Tests.Commands;

[TestFixture]
public class CommonCommandSettingsTests
{
[Test]
public void ShouldFailWhenDestinationEndpointIsMissing()
{
var settings = new SendCommandSettings
{
ContentType = "application/json",
EnclosedMessageType = "MessageContracts.Commands.CreateOrder",
MessageBody = "{}",
DestinationEndpoint = null!
};

var result = settings.Validate();

Assert.That(result.Successful, Is.False);
Assert.That(result.Message, Does.Contain("must specify a 'destination-endpoint'."));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using BuslyCLI.Commands.NsbEvent;

namespace BuslyCLI.Console.Tests.Commands;

[TestFixture]
public class CommonMessageSettingsTests
{
[Test]
public void ShouldFailWhenContentTypeIsMissing()
{
var settings = new PublishCommandSettings
{
ContentType = null!,
EnclosedMessageType = "MessageContracts.Commands.CreateOrder",
MessageBody = "{}"
};

var result = settings.Validate();

Assert.That(result.Successful, Is.False);
Assert.That(result.Message, Does.Contain("must specify a 'content-type'."));
}

[Test]
public void ShouldFailWhenEnclosedMessageTypeIsMissing()
{
var settings = new PublishCommandSettings
{
ContentType = "application/json",
EnclosedMessageType = null!,
MessageBody = "{}"
};

var result = settings.Validate();

Assert.That(result.Successful, Is.False);
Assert.That(result.Message, Does.Contain("must specify an 'enclosed-message-type'."));
}

[Test]
public void ShouldFailWhenMessageBodyIsMissing()
{
var settings = new PublishCommandSettings
{
ContentType = "application/json",
EnclosedMessageType = "MessageContracts.Commands.CreateOrder",
MessageBody = null!
};

var result = settings.Validate();

Assert.That(result.Successful, Is.False);
Assert.That(result.Message, Does.Contain("must specify a 'message-body'."));
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
// using Microsoft.Extensions.DependencyInjection;
// using BuslyCLI.DependencyInjection;
// using BuslyCLI.Spectre;
// using Spectre.Console.Cli.Extensions.DependencyInjection;
// using Spectre.Console.Testing;
//
// namespace BuslyCLI.Console.Tests.Commands.NsbCommand;
//
// public class SendCommandTests
// {
// private CommandAppTester _sut;
//
// [SetUp]
// public void Setup()
// {
// var registrations = new ServiceCollection();
// registrations.AddBuslyCLIServices();
// using var registrar = new DependencyInjectionRegistrar(registrations);
// _sut = new CommandAppTester(registrar);
// _sut.Configure(AppConfiguration.GetSpectreCommandConfiguration());
// }
//
// [TestCase("Error: must specify a 'content-type'.", "command", "send")]
// [TestCase("Error: Option 'content-type' is defined but no value has been provided.", "command", "send", "--content-type")]
// [TestCase("Error: must specify an 'enclosed-message-type'.", "command", "send", "--content-type", "application/json")]
// [TestCase("Error: Option 'enclosed-message-type' is defined but no value has been provided.", "command", "send", "--content-type", "application/json", "--enclosed-message-type")]
// [TestCase("Error: must specify a 'message-body'.", "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder")]
// [TestCase("Error: Option 'message-body' is defined but no value has been provided.", "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--message-body")]
// [TestCase("Error: must specify a 'destination-endpoint'.", "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--message-body", "test")]
// [TestCase("Error: Option 'destination-endpoint' is defined but no value has been provided.", "command", "send", "--content-type", "application/json", "--enclosed-message-type", "MessageContracts.Commands.CreateOrder", "--message-body", "test", "--destination-endpoint")]
// public async Task ShouldValidateRequiredOptions(string expectedSubstring, params string[] args)
// {
// var result = _sut.Run(args);
//
// Assert.That(result.ExitCode, Is.Not.EqualTo(0));
// Assert.That(result.Output, Does.Contain(expectedSubstring), $"Expected output to contain: {expectedSubstring}");
// }
// }
namespace BuslyCLI.Console.Tests.Commands.NsbCommand;

// Validation of required options is covered in CommonMessageSettingsTests and CommonCommandSettingsTests.
public class SendCommandTests : CommandTestBase
{
}