SWPCore/Tests/CommandQueries/CommandTests.cs

63 lines
1.7 KiB
C#
Raw Normal View History

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using SWP.Core.CommandQueries;
namespace SWP.Core.X.TDD.CommandQueries;
[TestClass]
public class CommandTests
{
[TestMethod]
public void Command_ShouldHaveCorrelationId()
{
// Arrange & Act
var correlationId = Guid.NewGuid();
var command = new TestCommand { CorrelationId = correlationId };
// Assert
command.CorrelationId.ShouldBe(correlationId);
}
[TestMethod]
public void Command_ShouldHaveTransactionId()
{
// Arrange & Act
var correlationId = Guid.NewGuid();
var transactionId = Guid.NewGuid();
var command = new TestCommand { CorrelationId = correlationId };
command.TransactionId = transactionId;
// Assert
command.TransactionId.ShouldBe(transactionId);
}
private class TestCommand : Command
{
public string TestProperty { get; set; }
}
}
[TestClass]
public class ProblemDetailsTests
{
[TestMethod]
public void ProblemDetails_ShouldHaveBasicProperties()
{
// Arrange & Act
var problem = new ProblemDetails
{
Type = "ValidationError",
Title = "Validation Failed",
Status = 400,
Detail = "Email is required",
Instance = "/api/users"
};
// Assert
problem.Type.ShouldBe("ValidationError");
problem.Title.ShouldBe("Validation Failed");
problem.Status.ShouldBe(400);
problem.Detail.ShouldBe("Email is required");
problem.Instance.ShouldBe("/api/users");
}
}