165 lines
5.6 KiB
C#
165 lines
5.6 KiB
C#
using FluentAssertions;
|
|
using TeleBot.Models;
|
|
using Xunit;
|
|
|
|
namespace TeleBot.Tests.Models
|
|
{
|
|
public class OrderFlowTests
|
|
{
|
|
[Fact]
|
|
public void NewOrderFlow_ShouldHaveDefaultValues()
|
|
{
|
|
// Arrange & Act
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Assert
|
|
orderFlow.ShippingCountry.Should().Be("United Kingdom");
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingName);
|
|
orderFlow.UsePGPEncryption.Should().BeFalse();
|
|
orderFlow.IdentityReference.Should().BeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_ShouldProgressThroughSteps()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act & Assert - Step 1: Name
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingName);
|
|
orderFlow.ShippingName = "John Doe";
|
|
orderFlow.CurrentStep = OrderFlowStep.CollectingAddress;
|
|
|
|
// Step 2: Address
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingAddress);
|
|
orderFlow.ShippingAddress = "123 Main Street";
|
|
orderFlow.CurrentStep = OrderFlowStep.CollectingCity;
|
|
|
|
// Step 3: City
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingCity);
|
|
orderFlow.ShippingCity = "London";
|
|
orderFlow.CurrentStep = OrderFlowStep.CollectingPostCode;
|
|
|
|
// Step 4: PostCode
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingPostCode);
|
|
orderFlow.ShippingPostCode = "SW1A 1AA";
|
|
orderFlow.CurrentStep = OrderFlowStep.CollectingCountry;
|
|
|
|
// Step 5: Country
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.CollectingCountry);
|
|
orderFlow.ShippingCountry = "United Kingdom";
|
|
orderFlow.CurrentStep = OrderFlowStep.ReviewingOrder;
|
|
|
|
// Final validation
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.ReviewingOrder);
|
|
orderFlow.ShippingName.Should().Be("John Doe");
|
|
orderFlow.ShippingAddress.Should().Be("123 Main Street");
|
|
orderFlow.ShippingCity.Should().Be("London");
|
|
orderFlow.ShippingPostCode.Should().Be("SW1A 1AA");
|
|
orderFlow.ShippingCountry.Should().Be("United Kingdom");
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_WithPGPEncryption_ShouldSetFlag()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act
|
|
orderFlow.UsePGPEncryption = true;
|
|
|
|
// Assert
|
|
orderFlow.UsePGPEncryption.Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_WithNotes_ShouldStoreNotes()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act
|
|
orderFlow.Notes = "Please leave at the front door";
|
|
|
|
// Assert
|
|
orderFlow.Notes.Should().Be("Please leave at the front door");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(OrderFlowStep.CollectingName)]
|
|
[InlineData(OrderFlowStep.CollectingAddress)]
|
|
[InlineData(OrderFlowStep.CollectingCity)]
|
|
[InlineData(OrderFlowStep.CollectingPostCode)]
|
|
[InlineData(OrderFlowStep.CollectingCountry)]
|
|
[InlineData(OrderFlowStep.CollectingNotes)]
|
|
[InlineData(OrderFlowStep.ReviewingOrder)]
|
|
[InlineData(OrderFlowStep.SelectingPaymentMethod)]
|
|
[InlineData(OrderFlowStep.ProcessingPayment)]
|
|
[InlineData(OrderFlowStep.Complete)]
|
|
public void OrderFlowStep_AllSteps_ShouldBeDefined(OrderFlowStep step)
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act
|
|
orderFlow.CurrentStep = step;
|
|
|
|
// Assert
|
|
orderFlow.CurrentStep.Should().Be(step);
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_SelectedCurrency_ShouldStore()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act
|
|
orderFlow.SelectedCurrency = "BTC";
|
|
|
|
// Assert
|
|
orderFlow.SelectedCurrency.Should().Be("BTC");
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_IdentityReference_ShouldStore()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData();
|
|
|
|
// Act
|
|
orderFlow.IdentityReference = "ANON-ABC123XYZ";
|
|
|
|
// Assert
|
|
orderFlow.IdentityReference.Should().Be("ANON-ABC123XYZ");
|
|
}
|
|
|
|
[Fact]
|
|
public void OrderFlow_CompleteFlow_ShouldHaveAllRequiredData()
|
|
{
|
|
// Arrange
|
|
var orderFlow = new OrderFlowData
|
|
{
|
|
IdentityReference = "ANON-TEST123",
|
|
ShippingName = "Jane Smith",
|
|
ShippingAddress = "456 Oak Avenue",
|
|
ShippingCity = "Manchester",
|
|
ShippingPostCode = "M1 1AA",
|
|
ShippingCountry = "United Kingdom",
|
|
Notes = "Ring doorbell twice",
|
|
SelectedCurrency = "XMR",
|
|
UsePGPEncryption = true,
|
|
CurrentStep = OrderFlowStep.Complete
|
|
};
|
|
|
|
// Assert
|
|
orderFlow.IdentityReference.Should().NotBeNullOrEmpty();
|
|
orderFlow.ShippingName.Should().NotBeNullOrEmpty();
|
|
orderFlow.ShippingAddress.Should().NotBeNullOrEmpty();
|
|
orderFlow.ShippingCity.Should().NotBeNullOrEmpty();
|
|
orderFlow.ShippingPostCode.Should().NotBeNullOrEmpty();
|
|
orderFlow.ShippingCountry.Should().NotBeNullOrEmpty();
|
|
orderFlow.CurrentStep.Should().Be(OrderFlowStep.Complete);
|
|
}
|
|
}
|
|
} |