using MarketAlly.ProjectDetector;
namespace MarketAlly.AIPlugin.Tests;
///
/// Tests for ProjectFileLocator
///
public class ProjectFileLocatorTests
{
[Fact]
public void FindProjectFiles_WithNullPath_ShouldThrowArgumentNullException()
{
// Arrange & Act
Action act = () => ProjectFileLocator.FindProjectFiles(null!);
// Assert
act.Should().Throw()
.WithParameterName("startPath");
}
[Fact]
public void FindProjectFiles_WithEmptyPath_ShouldThrowArgumentException()
{
// Arrange & Act
Action act = () => ProjectFileLocator.FindProjectFiles("");
// Assert
act.Should().Throw();
}
[Fact]
public void FindProjectFiles_WithNonExistentPath_ShouldReturnEmptyList()
{
// Arrange
var nonExistentPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
// Act
var result = ProjectFileLocator.FindProjectFiles(nonExistentPath);
// Assert
result.Should().NotBeNull();
result.Should().BeEmpty();
}
[Fact]
public void FindProjectFiles_WithValidTempDirectory_ShouldNotThrow()
{
// Arrange
var tempPath = Path.GetTempPath();
// Act
Action act = () => ProjectFileLocator.FindProjectFiles(tempPath);
// Assert
act.Should().NotThrow();
}
[Fact]
public void FindProjectFiles_WithCustomOptions_ShouldRespectMaxDepth()
{
// Arrange
var tempPath = Path.GetTempPath();
var options = new ProjectDetectorOptions { MaxDepth = 0 };
// Act
var result = ProjectFileLocator.FindProjectFiles(tempPath, options);
// Assert
result.Should().NotBeNull();
// With MaxDepth = 0, should only search the immediate directory
}
[Fact]
public void FindProjectFiles_WithCustomOptions_ShouldRespectMaxResults()
{
// Arrange
var tempPath = Path.GetTempPath();
var options = new ProjectDetectorOptions { MaxResults = 1 };
// Act
var result = ProjectFileLocator.FindProjectFiles(tempPath, options);
// Assert
result.Should().NotBeNull();
result.Count.Should().BeLessOrEqualTo(1);
}
[Fact]
public void FindSolutionFiles_WithNullPath_ShouldThrowArgumentNullException()
{
// Arrange & Act
Action act = () => ProjectFileLocator.FindSolutionFiles(null!);
// Assert
act.Should().Throw()
.WithParameterName("startPath");
}
[Fact]
public void FindSolutionFiles_WithValidPath_ShouldNotThrow()
{
// Arrange
var tempPath = Path.GetTempPath();
// Act
Action act = () => ProjectFileLocator.FindSolutionFiles(tempPath);
// Assert
act.Should().NotThrow();
}
}