58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
|
|
using FsCheck;
|
||
|
|
using FsCheck.Xunit;
|
||
|
|
using SolutionCleanupTool.Models;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace SolutionCleanupTool.Tests
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// Property-based tests for data model integrity
|
||
|
|
/// Feature: fix-missing-project-references, Property 1: Complete Missing Project Detection
|
||
|
|
/// </summary>
|
||
|
|
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<string, string>((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();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|