51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
public static class MinWallThicknessAutoCalcTests
|
|
{
|
|
public static int Main()
|
|
{
|
|
try
|
|
{
|
|
AutoCalculationUsesToleranceWorstCase();
|
|
Console.WriteLine("Min wall thickness auto calculation tests passed.");
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.Error.WriteLine(ex.Message);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
private static void AutoCalculationUsesToleranceWorstCase()
|
|
{
|
|
var sourcePath = Path.Combine("UI", "DrawingParamsForm.cs");
|
|
var source = File.ReadAllText(sourcePath);
|
|
|
|
if (!source.Contains("private const string KeyOuterDiameter1TolMinus = \"OuterDiameter1TolMinus\";") ||
|
|
!source.Contains("private const string KeyInnerDiameter2TolPlus = \"InnerDiameter2TolPlus\";"))
|
|
{
|
|
throw new InvalidOperationException(sourcePath + ": min wall thickness auto calculation must know outer lower tolerance and inner upper tolerance keys.");
|
|
}
|
|
|
|
if (!source.Contains("string.Equals(key, KeyOuterDiameter1TolMinus, StringComparison.OrdinalIgnoreCase)") ||
|
|
!source.Contains("string.Equals(key, KeyInnerDiameter2TolPlus, StringComparison.OrdinalIgnoreCase)"))
|
|
{
|
|
throw new InvalidOperationException(sourcePath + ": tolerance input changes must update min wall thickness.");
|
|
}
|
|
|
|
if (!source.Contains("var outerLower = GetNumericValue(KeyOuterDiameter1TolMinus);") ||
|
|
!source.Contains("var innerUpper = GetNumericValue(KeyInnerDiameter2TolPlus);") ||
|
|
!source.Contains("var t = ((phi1 + outerLower) - (phi2 + innerUpper)) / 2.0;"))
|
|
{
|
|
throw new InvalidOperationException(sourcePath + ": min wall thickness must be calculated as ((outer diameter + lower tolerance) - (inner diameter + upper tolerance)) / 2.");
|
|
}
|
|
|
|
if (source.Contains("var t = (phi1 - phi2) / 2.0;"))
|
|
{
|
|
throw new InvalidOperationException(sourcePath + ": nominal-only min wall thickness formula must not remain.");
|
|
}
|
|
}
|
|
}
|