63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
using FsCheck;
|
|
using FsCheck.Xunit;
|
|
using SolutionCleanupTool.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace SolutionCleanupTool.Tests
|
|
{
|
|
/// <summary>
|
|
/// Base class for property-based tests with common generators and utilities
|
|
/// </summary>
|
|
public abstract class PropertyTestBase
|
|
{
|
|
/// <summary>
|
|
/// Configuration for property-based tests - minimum 100 iterations as per requirements
|
|
/// </summary>
|
|
protected static readonly Configuration TestConfig = new Configuration { MaxNbOfTest = 100, StartSize = 1, EndSize = 100 };
|
|
|
|
/// <summary>
|
|
/// Generator for valid project GUIDs
|
|
/// </summary>
|
|
public static Arbitrary<Guid> ProjectGuidGenerator()
|
|
{
|
|
return Arb.Generate<Guid>().ToArbitrary();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generator for project references
|
|
/// </summary>
|
|
public static Arbitrary<ProjectReference> ProjectReferenceGenerator()
|
|
{
|
|
return (from name in Arb.Generate<NonEmptyString>()
|
|
from path in Arb.Generate<NonEmptyString>()
|
|
from guid in Arb.Generate<Guid>()
|
|
from typeGuid in Arb.Generate<NonEmptyString>()
|
|
from exists in Arb.Generate<bool>()
|
|
select new ProjectReference
|
|
{
|
|
Name = name.Get,
|
|
RelativePath = path.Get,
|
|
AbsolutePath = Path.Combine("C:\\TestSolution", path.Get),
|
|
ProjectGuid = guid,
|
|
ProjectTypeGuid = typeGuid.Get,
|
|
Exists = exists
|
|
}).ToArbitrary();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generator for solution models
|
|
/// </summary>
|
|
public static Arbitrary<SolutionModel> SolutionModelGenerator()
|
|
{
|
|
return (from path in Arb.Generate<NonEmptyString>()
|
|
from projects in Arb.Generate<List<ProjectReference>>()
|
|
select new SolutionModel
|
|
{
|
|
FilePath = path.Get + ".sln",
|
|
Projects = projects ?? new List<ProjectReference>()
|
|
}).ToArbitrary();
|
|
}
|
|
}
|
|
} |