[Fact]
public async Task VerifyEmailAndCreateAccount_ValidCode_CreatesCustomerAccount()
{
// Arrange
var testCustomer = _testCustomer;
string verificationCode = "123456";
var emailVerification = new EmailVerification
{
Email = testCustomer.Email,
Code = "123456"
};
// Setup the cache mock to return a valid customer and verification code
_mockMemoryCache.Setup(cache => cache.TryGetValue("pendingCustomer", out testCustomer))
.Returns(true);
_mockMemoryCache.Setup(cache => cache.TryGetValue("verificationCode", out verificationCode))
.Returns(true);
// Act: Call the API method
var result = await _controller.VerifyEmailAndCreateAccount(emailVerification);
// Assert
var okResult = Assert.IsType<OkObjectResult>(result);
Assert.Equal("Email successfully verified and account created.", okResult.Value);
}
[Fact]
public async Task VerifyEmailAndCreateAccount_ValidCode_CreatesCustomerAccount()
{
// Arrange
var testCustomer = _testCustomer;
string verificationCode = "123456";
var emailVerification = new EmailVerification
{
Email = testCustomer.Email,
Code = "123456"
};
// Setup the cache mock to return a valid customer and verification code
_mockMemoryCache.Setup(cache => cache.TryGetValue("pendingCustomer", out testCustomer))
.Returns(true);
_mockMemoryCache.Setup(cache => cache.TryGetValue("verificationCode", out verificationCode))
.Returns(true);
// Act: Call the API method
var result = await _controller.VerifyEmailAndCreateAccount(emailVerification);
// Assert
var okResult = Assert.IsType<OkObjectResult>(result);
Assert.Equal("Email successfully verified and account created.", okResult.Value);
}