using FsCheck;
using FsCheck.Xunit;
using SolutionCleanupTool.Models;
using Xunit;
namespace SolutionCleanupTool.Tests
{
///
/// Property-based tests for data model integrity
/// Feature: fix-missing-project-references, Property 1: Complete Missing Project Detection
///
public class DataModelTests : PropertyTestBase
{
[Property]
public Property ProjectReference_ShouldMaintainConsistency()
{
return Prop.ForAll(ProjectReferenceGenerator(), project =>
{
// A project reference should maintain its basic properties
return !string.IsNullOrEmpty(project.Name) &&
!string.IsNullOrEmpty(project.RelativePath) &&
project.ProjectGuid != Guid.Empty;
});
}
[Property]
public Property SolutionModel_ShouldHaveValidStructure()
{
return Prop.ForAll(SolutionModelGenerator(), solution =>
{
// A solution model should have a valid file path and project list
return !string.IsNullOrEmpty(solution.FilePath) &&
solution.Projects != null &&
solution.Configurations != null &&
solution.GlobalSections != null;
});
}
[Property]
public Property DependencyGraph_ShouldDetectCircularReferences()
{
return Prop.ForAll((project1, project2) =>
{
if (string.IsNullOrEmpty(project1) || string.IsNullOrEmpty(project2) || project1 == project2)
return true; // Skip invalid inputs
var graph = new DependencyGraph();
// Add circular dependency: project1 -> project2 -> project1
graph.AddDependency(project1, project2);
graph.AddDependency(project2, project1);
// Should detect the circular reference
return graph.HasCircularReferences();
});
}
}
}